-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypes.ts
More file actions
240 lines (218 loc) · 6.57 KB
/
types.ts
File metadata and controls
240 lines (218 loc) · 6.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
import { ICollabConfig } from "../visualBuilder/types/collab.types";
export declare interface IEditEntrySearchParams {
hash?: string;
entry_uid?: string;
content_type_uid?: string;
/**
* @deprecated pass this value as hash instead
*/
live_preview?: string;
}
export declare interface IClientUrlParams {
protocol: "http" | "https";
host: string;
port: string | number;
url: string;
}
export declare interface IStackSdk {
live_preview: { [key: string]: any } & Partial<IConfig>;
[key: string]: any;
environment: string;
}
export declare interface IStackDetails {
apiKey: string;
environment: string;
contentTypeUid: string;
entryUid: string;
branch: string;
/**
* This locale is currently used by the visual builder to
* redirect to the correct locale if the no data-cslp tag
* is present in the HTML to extract the locale.
*/
locale: string;
masterLocale: string;
}
export declare interface IInitStackDetails {
apiKey: string;
environment: string;
branch: string;
/**
* This locale is currently used by the visual builder to
* redirect to the correct locale if the no data-cslp tag
* is present in the HTML to extract the locale.
*/
locale: string;
}
export declare type ILivePreviewMode = "builder" | "preview";
//? We kept it as number so that we could disable only the unrequired features,
//? since the "Builder" mode will contain all the features of the "Preview" mode.
export enum ILivePreviewModeConfig {
PREVIEW = 1,
BUILDER = 2,
}
export enum ILivePreviewWindowType {
PREVIEW = "preview",
PREVIEW_SHARE = "preview-share",
BUILDER = "builder",
INDEPENDENT = "independent",
}
export declare interface IConfig {
ssr: boolean;
enable: boolean;
/**
* @default false
*/
debug: boolean;
cleanCslpOnProduction: boolean;
stackDetails: IStackDetails;
clientUrlParams: IClientUrlParams;
stackSdk: IStackSdk;
onChange: () => void;
runScriptsOnUpdate: boolean;
windowType: ILivePreviewWindowType;
hash: string;
editButton: IConfigEditButton;
editInVisualBuilderButton: IConfigEditInVisualBuilderButton;
overlayPropagation: IConfigOverlayPropagation;
mode: ILivePreviewModeConfig;
elements: {
highlightedElement: HTMLElement | null;
};
collab: ICollabConfig["collab"];
enableLivePreviewOutsideIframe: boolean | undefined;
}
export declare interface IConfigEditInVisualBuilderButton {
enable: boolean;
position?:
| "top-left"
| "top-right"
| "bottom-left"
| "bottom-right"
}
export declare interface IConfigOverlayPropagation {
/**
* When `true`, Visual Builder hover/click detection falls back to
* `document.elementsFromPoint()` if the immediate `event.target` has no
* ancestor with `data-cslp`. This allows the SDK to pierce sibling
* elements (e.g. empty CSS-grid spacer cells) that visually overlap a
* `data-cslp` field and would otherwise intercept the mouse event.
*
* @default false
*/
enable: boolean;
}
export declare interface IConfigEditButton {
enable: boolean;
exclude?: ("insideLivePreviewPortal" | "outsideLivePreviewPortal")[];
includeByQueryParameter?: boolean;
position?:
| "top"
| "bottom"
| "left"
| "right"
| "top-left"
| "top-right"
| "top-center"
| "bottom-left"
| "bottom-right"
| "bottom-center";
}
export declare interface IInitData {
ssr: boolean;
runScriptsOnUpdate: boolean;
enable: boolean;
/**
* @default false
*/
debug: boolean;
cleanCslpOnProduction: boolean;
stackDetails: Partial<IInitStackDetails>;
clientUrlParams: Partial<Omit<IClientUrlParams, "url">>;
stackSdk: IStackSdk;
editButton: IConfigEditButton;
editInVisualBuilderButton: IConfigEditInVisualBuilderButton;
overlayPropagation: IConfigOverlayPropagation;
mode: ILivePreviewMode;
enableLivePreviewOutsideIframe: boolean | undefined; // default: undefined
}
// type PickPartial<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
// export type IInitData =
// | {
// ssr?: true;
// stackSdk?: IStackSdk;
// runScriptsOnUpdate?: boolean;
// enable?: boolean;
// cleanCslpOnProduction?: boolean;
// stackDetails?: Partial<IInitStackDetails>;
// clientUrlParams?: Partial<Omit<IClientUrlParams, "url">>;
// editButton?: IConfigEditButton;
// mode?: "preview";
// }
// | {
// ssr?: true;
// stackSdk?: IStackSdk;
// runScriptsOnUpdate?: boolean;
// enable?: boolean;
// cleanCslpOnProduction?: boolean;
// stackDetails: PickPartial<IInitStackDetails, "branch">;
// clientUrlParams: PickPartial<
// Omit<IClientUrlParams, "url">,
// "port" | "protocol"
// >;
// editButton?: IConfigEditButton;
// mode: "builder";
// }
// | {
// ssr: false;
// runScriptsOnUpdate?: boolean;
// enable?: boolean;
// cleanCslpOnProduction?: boolean;
// stackDetails?: Partial<IInitStackDetails>;
// clientUrlParams?: Partial<Omit<IClientUrlParams, "url">>;
// stackSdk: IStackSdk;
// editButton?: IConfigEditButton;
// mode?: "preview";
// }
// | {
// ssr: false;
// runScriptsOnUpdate?: boolean;
// enable?: boolean;
// cleanCslpOnProduction?: boolean;
// stackDetails: PickPartial<IInitStackDetails, "branch">;
// clientUrlParams: PickPartial<
// Omit<IClientUrlParams, "url">,
// "port" | "protocol"
// >;
// stackSdk: IStackSdk;
// editButton?: IConfigEditButton;
// mode: "builder";
// };
// Post message types
export declare interface ILivePreviewMessageCommon {
from: "live-preview";
}
export declare interface IEditButtonPosition {
upperBoundOfTooltip: number;
leftBoundOfTooltip: number;
}
// end of Post message types
export interface IVisualBuilderInitEvent {
windowType: ILivePreviewWindowType;
stackDetails: {
masterLocale: string;
};
collab?: ICollabConfig["collab"];
}
export type IExportedConfig = Pick<
IConfig,
| "ssr"
| "enable"
| "cleanCslpOnProduction"
| "stackDetails"
| "clientUrlParams"
| "windowType"
| "hash"
| "editButton"
| "mode"
>;