@webflow/designer-extension-typings 2.0.27 → 2.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.d.ts +403 -165
- package/components.d.ts +197 -0
- package/element-presets-generated.d.ts +0 -7
- package/element-settings-generated.d.ts +49 -0
- package/element-settings.d.ts +17 -0
- package/elements-generated.d.ts +1441 -1214
- package/elements.d.ts +1 -0
- package/package.json +1 -1
- package/pages.d.ts +47 -0
- package/slots.d.ts +16 -0
package/api.d.ts
CHANGED
|
@@ -8,10 +8,19 @@
|
|
|
8
8
|
/// <reference path="./variables.d.ts" />
|
|
9
9
|
/// <reference path="./app-subscription.d.ts" />
|
|
10
10
|
/// <reference path="./assets.d.ts" />
|
|
11
|
+
/// <reference path="./element-settings-generated.d.ts" />
|
|
12
|
+
/// <reference path="./element-settings.d.ts" />
|
|
11
13
|
/// <reference path="./app-modes-generated.d.ts" />
|
|
12
14
|
/// <reference path="./app-connections.d.ts" />
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
type AppModeName = 'design' | 'build' | 'preview' | 'edit' | 'comment';
|
|
17
|
+
|
|
18
|
+
interface AppModeChangeEvent {
|
|
19
|
+
mode: AppModeName | null;
|
|
20
|
+
appModes: {[key in AppMode]: boolean};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface SharedApi {
|
|
15
24
|
/**
|
|
16
25
|
* Get metadata about the current Site.
|
|
17
26
|
* @returns A Promise that resolves to a record containing information about the site that is open in the
|
|
@@ -52,50 +61,6 @@ interface WebflowApi {
|
|
|
52
61
|
stage: 'staging' | 'production';
|
|
53
62
|
}>;
|
|
54
63
|
}>;
|
|
55
|
-
/**
|
|
56
|
-
* Get the currently selected element in the Webflow Designer.
|
|
57
|
-
* @returns A promise that resolves to one of the following:
|
|
58
|
-
* - null: If no element is currently selected in the Designer
|
|
59
|
-
* - AnyElement: an object representing the selected element, which can be of any type.
|
|
60
|
-
* @example
|
|
61
|
-
* ```ts
|
|
62
|
-
* const selectedElement = await webflow.getSelectedElement();
|
|
63
|
-
* if (selectedElement) {
|
|
64
|
-
* // Handle the selected element
|
|
65
|
-
* } else {
|
|
66
|
-
* // No element is currently selected
|
|
67
|
-
* }
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
getSelectedElement(): Promise<null | AnyElement>;
|
|
71
|
-
/**
|
|
72
|
-
* Sets the currently selected element in the Webflow Designer.
|
|
73
|
-
* @returns A promise that resolves to one of the following:
|
|
74
|
-
* - null: If no element is able to be currently selected in the Designer
|
|
75
|
-
* - AnyElement: an object representing the selected element, which can be of any type.
|
|
76
|
-
* @example
|
|
77
|
-
* ```ts
|
|
78
|
-
* await webflow.setSelectedElement(element);
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
setSelectedElement(element: AnyElement): Promise<null | AnyElement>;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Captures a screenshot of the specified element.
|
|
85
|
-
* @returns A promise that resolves to a base64 string representing the screenshot of the element.
|
|
86
|
-
* @example
|
|
87
|
-
* ```ts
|
|
88
|
-
* const selectedElement = await webflow.getSelectedElement();
|
|
89
|
-
* if (selectedElement) {
|
|
90
|
-
* const screenshot = await webflow.getElementSnapshot(selectedElement);
|
|
91
|
-
* console.log('Screenshot:', screenshot);
|
|
92
|
-
* }else{
|
|
93
|
-
* console.log('No element selected');
|
|
94
|
-
* }
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
getElementSnapshot(element: AnyElement): Promise<null | string>;
|
|
98
|
-
|
|
99
64
|
/**
|
|
100
65
|
* Renders the specified element to WHTML format.
|
|
101
66
|
* @param element - The element to render
|
|
@@ -117,34 +82,44 @@ interface WebflowApi {
|
|
|
117
82
|
): Promise<null | {whtml: string; shortIdMap: Record<string, string[]>}>;
|
|
118
83
|
|
|
119
84
|
elementBuilder(elementPreset: ElementPreset<AnyElement>): BuilderElement;
|
|
120
|
-
/**
|
|
121
|
-
* Get the current media query breakpoint ID.
|
|
122
|
-
* @returns A Promise that resolves to a BreakpointId which is a string representing the current media query
|
|
123
|
-
* breakpoint. A BreakpointId is one of 'tiny', 'small', 'medium', 'main', 'large', 'xl', 'xxl'.
|
|
124
|
-
* @example
|
|
125
|
-
* ```ts
|
|
126
|
-
* const breakpoint = await webflow.getMediaQuery();
|
|
127
|
-
* console.log('Current Media Query:', breakpoint);
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
getMediaQuery(): Promise<BreakpointId>;
|
|
131
85
|
|
|
132
86
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* @
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
|
|
141
|
-
|
|
87
|
+
* Parse a WHTML string and insert the resulting element as a child of the anchor element.
|
|
88
|
+
* The newly created element will be appended to the end of the anchor's children.
|
|
89
|
+
* @param whtml - The WHTML string to parse into an element
|
|
90
|
+
* @param anchor - The parent element to append the parsed WHTML element to
|
|
91
|
+
* @param position - The position relative to the anchor element where the new element will be inserted.
|
|
92
|
+
* - 'before': Insert as a sibling before the anchor element
|
|
93
|
+
* - 'after': Insert as a sibling after the anchor element
|
|
94
|
+
* - 'append': Insert as the last child of the anchor element (default)
|
|
95
|
+
* - 'prepend': Insert as the first child of the anchor element
|
|
96
|
+
* - 'replace': Replace the anchor element with the new element
|
|
97
|
+
* @returns A Promise that resolves to the newly inserted AnyElement
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const whtml = '<ul><li>Item 1</li><li>Item 2</li></ul>';
|
|
101
|
+
* const body = await allElements.find((el) => el.type === 'Body');
|
|
102
|
+
* // Append as last child (default)
|
|
103
|
+
* const element = await webflow.insertElementFromWHTML(whtml, body);
|
|
104
|
+
* // Or insert before an existing element
|
|
105
|
+
* const existingElement = await webflow.getSelectedElement();
|
|
106
|
+
* const newElement = await webflow.insertElementFromWHTML(whtml, existingElement, 'before');
|
|
107
|
+
* // Or replace an existing element
|
|
108
|
+
* const replacedElement = await webflow.insertElementFromWHTML(whtml, existingElement, 'replace');
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
insertElementFromWHTML?(
|
|
112
|
+
whtml: string,
|
|
113
|
+
anchor: AnyElement,
|
|
114
|
+
position?: 'before' | 'after' | 'append' | 'prepend' | 'replace'
|
|
115
|
+
): Promise<AnyElement>;
|
|
142
116
|
|
|
143
117
|
/**
|
|
144
118
|
* Create a component by promoting a Root Element.
|
|
145
119
|
* @param name - The name of the component.
|
|
146
|
-
* @param
|
|
120
|
+
* @param root - An Element that will become the Root Element of the Component.
|
|
147
121
|
* @returns A Promise resolving to an object containing the newly created Component - with the id property.
|
|
122
|
+
* @deprecated Use `registerComponent(options, root)` instead to provide richer metadata.
|
|
148
123
|
* @example
|
|
149
124
|
* ```ts
|
|
150
125
|
* const element = webflow.createDOM('div')
|
|
@@ -158,6 +133,67 @@ interface WebflowApi {
|
|
|
158
133
|
name: string,
|
|
159
134
|
root: AnyElement | ElementPreset<AnyElement> | Component
|
|
160
135
|
): Promise<Component>;
|
|
136
|
+
/**
|
|
137
|
+
* Create a blank component.
|
|
138
|
+
* @param options - Options for creating the blank component.
|
|
139
|
+
* @returns A Promise resolving to an object containing the newly created Component - with the id property.
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* const component = await webflow.registerComponent({name: 'Hero Section'})
|
|
143
|
+
*
|
|
144
|
+
* // With optional group and description
|
|
145
|
+
* const grouped = await webflow.registerComponent({
|
|
146
|
+
* name: 'Hero Section',
|
|
147
|
+
* group: 'Sections',
|
|
148
|
+
* description: 'A hero section component',
|
|
149
|
+
* })
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
registerComponent(options: ComponentOptions): Promise<Component>;
|
|
153
|
+
/**
|
|
154
|
+
* Duplicate an existing component.
|
|
155
|
+
* @param options - Options for the new component, including a required name.
|
|
156
|
+
* @param source - The existing Component to duplicate.
|
|
157
|
+
* @returns A Promise resolving to the newly created Component.
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* const [original] = await webflow.getAllComponents()
|
|
161
|
+
* const copy = await webflow.registerComponent({name: 'Hero Copy'}, original)
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
registerComponent(
|
|
165
|
+
options: ComponentOptions,
|
|
166
|
+
source: Component
|
|
167
|
+
): Promise<Component>;
|
|
168
|
+
/**
|
|
169
|
+
* Convert an element or element preset into a component. Equivalent to the
|
|
170
|
+
* "Convert selection" action in the Designer's "New component" menu.
|
|
171
|
+
* Elements do not need to be on the page. You can build the tree with
|
|
172
|
+
* `createDOM` first and pass it directly.
|
|
173
|
+
*
|
|
174
|
+
* When `root` is a canvas `AnyElement`, the source element is replaced
|
|
175
|
+
* in-place by a new component instance by default. Pass `replace: false`
|
|
176
|
+
* in `options` to skip this substitution and keep the original element.
|
|
177
|
+
* @param options - Options for the new component. `name` is required;
|
|
178
|
+
* `group`, `description`, and `replace` are optional.
|
|
179
|
+
* @param root - The element, element preset, or builder element that becomes the component root.
|
|
180
|
+
* @returns A Promise resolving to the newly created Component.
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* // Convert a canvas element and replace it with a component instance (default)
|
|
184
|
+
* const el = await webflow.getSelectedElement()
|
|
185
|
+
* const card = await webflow.registerComponent({name: 'Card', group: 'UI'}, el)
|
|
186
|
+
*
|
|
187
|
+
* // Convert without replacing the original element in the canvas
|
|
188
|
+
* const card2 = await webflow.registerComponent(
|
|
189
|
+
* {name: 'Card 2', replace: false},
|
|
190
|
+
* el
|
|
191
|
+
* )
|
|
192
|
+
*/
|
|
193
|
+
registerComponent(
|
|
194
|
+
options: ComponentOptions,
|
|
195
|
+
root: AnyElement | ElementPreset<AnyElement> | BuilderElement
|
|
196
|
+
): Promise<Component>;
|
|
161
197
|
/**
|
|
162
198
|
* Delete a component from the Designer. If there are any instances of the Component within the site, they will
|
|
163
199
|
* be converted to regular Elements.
|
|
@@ -188,6 +224,76 @@ interface WebflowApi {
|
|
|
188
224
|
* ```
|
|
189
225
|
*/
|
|
190
226
|
getAllComponents(): Promise<Array<Component>>;
|
|
227
|
+
/**
|
|
228
|
+
* Search site components with optional fuzzy filtering.
|
|
229
|
+
* Returns a flat array of {@link ComponentSearchResult} objects in the same order as the
|
|
230
|
+
* Components panel (insertion order). When `options.q` is provided, results are filtered
|
|
231
|
+
* using FlexSearch (`tokenize: 'full'`) — the same algorithm used by the Components panel.
|
|
232
|
+
*
|
|
233
|
+
* @param options - Optional search options.
|
|
234
|
+
* @param options.q - Search query string. Omit or leave empty to return all components.
|
|
235
|
+
* @returns A Promise resolving to an array of {@link ComponentSearchResult} objects.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```ts
|
|
239
|
+
* // Get all components
|
|
240
|
+
* const all = await webflow.searchComponents();
|
|
241
|
+
*
|
|
242
|
+
* // Filter by name
|
|
243
|
+
* const heroes = await webflow.searchComponents({ q: 'Hero' });
|
|
244
|
+
* heroes.forEach(c => {
|
|
245
|
+
* console.log(c.name, c.instances, c.canEdit, c.library);
|
|
246
|
+
* });
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
searchComponents(
|
|
250
|
+
options?: SearchComponentsOptions
|
|
251
|
+
): Promise<ComponentSearchResult[]>;
|
|
252
|
+
/**
|
|
253
|
+
* Returns a component reference when the user is editing in-context or on the component canvas, or null if no component is being edited.
|
|
254
|
+
* @returns A Promise that resolves to a Component reference or null.
|
|
255
|
+
* @example
|
|
256
|
+
* ```ts
|
|
257
|
+
* const component = await webflow.getCurrentComponent();
|
|
258
|
+
* if (component) {
|
|
259
|
+
* const name = await component.getName();
|
|
260
|
+
* console.log(`Currently editing: ${name}`);
|
|
261
|
+
* }
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
getCurrentComponent(): Promise<Component | null>;
|
|
265
|
+
/**
|
|
266
|
+
* Get a Component by its unique identifier.
|
|
267
|
+
* @param id - The unique identifier of the component.
|
|
268
|
+
* @returns A Promise that resolves to the Component with the given id.
|
|
269
|
+
* @example
|
|
270
|
+
* ```ts
|
|
271
|
+
* const componentId = '4a669354-353a-97eb-795c-4471b406e043';
|
|
272
|
+
* const component = await webflow.getComponent(componentId);
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
getComponent(id: ComponentId): Promise<Component>;
|
|
276
|
+
/**
|
|
277
|
+
* Get a Component by its display name. Only returns native site components.
|
|
278
|
+
* Throws if the matching component is a code component.
|
|
279
|
+
* @param name - The display name of the component.
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* const component = await webflow.getComponentByName('Hero');
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
getComponentByName(name: string): Promise<Component>;
|
|
286
|
+
/**
|
|
287
|
+
* Get a Component by its group and display name. Only returns native site components.
|
|
288
|
+
* Throws if the matching component is a code component.
|
|
289
|
+
* @param group - The group name the component belongs to.
|
|
290
|
+
* @param name - The display name of the component.
|
|
291
|
+
* @example
|
|
292
|
+
* ```ts
|
|
293
|
+
* const component = await webflow.getComponentByName('Marketing', 'Hero');
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
getComponentByName(group: string, name: string): Promise<Component>;
|
|
191
297
|
/**
|
|
192
298
|
* Focus the designer on a Component. When a component is in focus, all Globals pertain specifically to that
|
|
193
299
|
* Component, not the entire Site.
|
|
@@ -209,6 +315,38 @@ interface WebflowApi {
|
|
|
209
315
|
* ```
|
|
210
316
|
*/
|
|
211
317
|
exitComponent(): Promise<null>;
|
|
318
|
+
/**
|
|
319
|
+
* Navigate the Designer to a component canvas or page.
|
|
320
|
+
* @param options - An object with either pageId or componentId.
|
|
321
|
+
* @returns A Promise that resolves when the navigation is complete.
|
|
322
|
+
* @example
|
|
323
|
+
* ```ts
|
|
324
|
+
* // Open a component canvas by component id
|
|
325
|
+
* await webflow.openCanvas({componentId: '4a669354-353a-97eb-795c-4471b406e043'});
|
|
326
|
+
*
|
|
327
|
+
* // Open a component canvas by page id
|
|
328
|
+
* await webflow.openCanvas({pageId: '123'});
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
openCanvas(
|
|
332
|
+
options: OpenCanvasByComponentId | OpenCanvasByPageId
|
|
333
|
+
): Promise<void>;
|
|
334
|
+
/**
|
|
335
|
+
* Navigate the Designer to a component canvas or page using a reference.
|
|
336
|
+
* @param reference - A Component, ComponentElement, or Page reference.
|
|
337
|
+
* @returns A Promise that resolves when the navigation is complete.
|
|
338
|
+
* @example
|
|
339
|
+
* ```ts
|
|
340
|
+
* // Open a component canvas by component
|
|
341
|
+
* const heroComponent = await webflow.getComponent('4a669354-353a-97eb-795c-4471b406e043');
|
|
342
|
+
* await webflow.openCanvas(heroComponent);
|
|
343
|
+
*
|
|
344
|
+
* // Open a component canvas by page
|
|
345
|
+
* const myPage = await webflow.getPage('123');
|
|
346
|
+
* await webflow.openCanvas(myPage);
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
openCanvas(reference: Component | ComponentElement | Page): Promise<void>;
|
|
212
350
|
/**
|
|
213
351
|
* Get Root element. When the designer is focused or "entered" into a Component, this method will get the
|
|
214
352
|
* outermost element in the Component.
|
|
@@ -246,7 +384,7 @@ interface WebflowApi {
|
|
|
246
384
|
/**
|
|
247
385
|
* Creates a new style with the provided name.
|
|
248
386
|
* @param name - The name for the new style
|
|
249
|
-
* @param
|
|
387
|
+
* @param options - Options for the new style. An object containing the following properties:
|
|
250
388
|
* - parent: A Style object representing the parent style block. Used for creating a combo class.
|
|
251
389
|
* @returns a Promise that resolves to the Style object representing the newly created style.
|
|
252
390
|
* @example
|
|
@@ -300,16 +438,6 @@ interface WebflowApi {
|
|
|
300
438
|
* ```
|
|
301
439
|
*/
|
|
302
440
|
getAllStyles(): Promise<Array<Style>>;
|
|
303
|
-
/**
|
|
304
|
-
* Fetch the currently active page in the Webflow designer.
|
|
305
|
-
* @returns A Promise that resolves to a Page object representing the current page open in the Designer.
|
|
306
|
-
* @example
|
|
307
|
-
* ```ts
|
|
308
|
-
* const currentPage = await webflow.getCurrentPage();
|
|
309
|
-
* console.log('Current Page:', currentPage);
|
|
310
|
-
* ```
|
|
311
|
-
*/
|
|
312
|
-
getCurrentPage(): Promise<Page>;
|
|
313
441
|
/**
|
|
314
442
|
* Fetch an array of all pages and folders in the Webflow project.
|
|
315
443
|
* @returns A Promise that resolves to an array of Page and Folder objects representing all the pages
|
|
@@ -344,17 +472,6 @@ interface WebflowApi {
|
|
|
344
472
|
* ```
|
|
345
473
|
*/
|
|
346
474
|
createPage(): Promise<Page>;
|
|
347
|
-
/**
|
|
348
|
-
* @param page - The Page object representing the target page to switch to.
|
|
349
|
-
* @returns A Promise that resolves when the page switch is successful.
|
|
350
|
-
* @example
|
|
351
|
-
* ```ts
|
|
352
|
-
* const targetPage = <Get the target page>;
|
|
353
|
-
* await webflow.switchPage(targetPage);
|
|
354
|
-
* // Page switched successfully
|
|
355
|
-
* ```
|
|
356
|
-
*/
|
|
357
|
-
switchPage(page: Page): Promise<null>;
|
|
358
475
|
/**
|
|
359
476
|
* Access the default variable collection.
|
|
360
477
|
* @returns A Promise that resolves into a Collection.
|
|
@@ -410,6 +527,160 @@ interface WebflowApi {
|
|
|
410
527
|
*/
|
|
411
528
|
removeVariableCollection(id: VariableCollectionId): Promise<boolean>;
|
|
412
529
|
|
|
530
|
+
getIdToken(): Promise<string>;
|
|
531
|
+
getAppSubscriptions(): Promise<Array<AppSubscription>>;
|
|
532
|
+
elementPresets: ElementPresets;
|
|
533
|
+
/**
|
|
534
|
+
* Removes the Style from the site.
|
|
535
|
+
* @example
|
|
536
|
+
* ```ts
|
|
537
|
+
* await webflow.removeStyle(style);
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
removeStyle(style: Style): Promise<null>;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Create a new asset, associated with the site
|
|
544
|
+
* @example
|
|
545
|
+
* ```ts
|
|
546
|
+
* const fileBlob = new File([blob], 'cat.png', { type: 'image/png' });
|
|
547
|
+
* const asset = await webflow.createAsset(fileBlob);
|
|
548
|
+
* ```
|
|
549
|
+
*/
|
|
550
|
+
createAsset(fileBlob: File): Promise<Asset>;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Gets an asset by its id
|
|
554
|
+
* @example
|
|
555
|
+
* ```ts
|
|
556
|
+
* const asset = await webflow.getAssetById('1234');
|
|
557
|
+
* ```
|
|
558
|
+
* @param id
|
|
559
|
+
*/
|
|
560
|
+
getAssetById(id: AssetId): Promise<null | Asset>;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Gets all assets for the site
|
|
564
|
+
* @example
|
|
565
|
+
* ```ts
|
|
566
|
+
* const assets = await webflow.getAllAssets();
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
569
|
+
getAllAssets(): Promise<Array<Asset>>;
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Gets all asset folders for the site
|
|
573
|
+
* @example
|
|
574
|
+
* ```ts
|
|
575
|
+
* const assetFolders = await webflow.getAssetFolders();
|
|
576
|
+
* console.log('Asset folders:', assetFolders);
|
|
577
|
+
* ```
|
|
578
|
+
* @returns A Promise that resolves to an array of AssetFolder objects
|
|
579
|
+
*/
|
|
580
|
+
getAllAssetFolders(): Promise<Array<AssetFolder>>;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Creates a new asset folder within a given site
|
|
584
|
+
* @param name - The name of the new asset folder.
|
|
585
|
+
* @param parentFolderId - Optional. The ID of the parent folder. If not provided, the folder will be created at the root level.
|
|
586
|
+
* @returns A Promise that resolves to the newly created AssetFolder object.
|
|
587
|
+
* @example
|
|
588
|
+
* ```ts
|
|
589
|
+
* const newFolder = await webflow.createAssetFolder('My New Folder');
|
|
590
|
+
* console.log('New folder created:', newFolder.id);
|
|
591
|
+
* ```
|
|
592
|
+
*/
|
|
593
|
+
createAssetFolder(
|
|
594
|
+
name: string,
|
|
595
|
+
parentFolderId?: string
|
|
596
|
+
): Promise<AssetFolder>;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
interface DesignerOnlyApi {
|
|
600
|
+
/**
|
|
601
|
+
* Get the currently selected element in the Webflow Designer.
|
|
602
|
+
* @returns A promise that resolves to one of the following:
|
|
603
|
+
* - null: If no element is currently selected in the Designer
|
|
604
|
+
* - AnyElement: an object representing the selected element, which can be of any type.
|
|
605
|
+
* @example
|
|
606
|
+
* ```ts
|
|
607
|
+
* const selectedElement = await webflow.getSelectedElement();
|
|
608
|
+
* if (selectedElement) {
|
|
609
|
+
* // Handle the selected element
|
|
610
|
+
* } else {
|
|
611
|
+
* // No element is currently selected
|
|
612
|
+
* }
|
|
613
|
+
* ```
|
|
614
|
+
*/
|
|
615
|
+
getSelectedElement(): Promise<null | AnyElement>;
|
|
616
|
+
/**
|
|
617
|
+
* Sets the currently selected element in the Webflow Designer.
|
|
618
|
+
* @returns A promise that resolves to one of the following:
|
|
619
|
+
* - null: If no element is able to be currently selected in the Designer
|
|
620
|
+
* - AnyElement: an object representing the selected element, which can be of any type.
|
|
621
|
+
* @example
|
|
622
|
+
* ```ts
|
|
623
|
+
* await webflow.setSelectedElement(element);
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
626
|
+
setSelectedElement(element: AnyElement): Promise<null | AnyElement>;
|
|
627
|
+
/**
|
|
628
|
+
* Captures a screenshot of the specified element.
|
|
629
|
+
* @returns A promise that resolves to a base64 string representing the screenshot of the element.
|
|
630
|
+
* @example
|
|
631
|
+
* ```ts
|
|
632
|
+
* const selectedElement = await webflow.getSelectedElement();
|
|
633
|
+
* if (selectedElement) {
|
|
634
|
+
* const screenshot = await webflow.getElementSnapshot(selectedElement);
|
|
635
|
+
* console.log('Screenshot:', screenshot);
|
|
636
|
+
* }else{
|
|
637
|
+
* console.log('No element selected');
|
|
638
|
+
* }
|
|
639
|
+
* ```
|
|
640
|
+
*/
|
|
641
|
+
getElementSnapshot(element: AnyElement): Promise<null | string>;
|
|
642
|
+
/**
|
|
643
|
+
* Get the current media query breakpoint ID.
|
|
644
|
+
* @returns A Promise that resolves to a BreakpointId which is a string representing the current media query
|
|
645
|
+
* breakpoint. A BreakpointId is one of 'tiny', 'small', 'medium', 'main', 'large', 'xl', 'xxl'.
|
|
646
|
+
* @example
|
|
647
|
+
* ```ts
|
|
648
|
+
* const breakpoint = await webflow.getMediaQuery();
|
|
649
|
+
* console.log('Current Media Query:', breakpoint);
|
|
650
|
+
* ```
|
|
651
|
+
*/
|
|
652
|
+
getMediaQuery(): Promise<BreakpointId>;
|
|
653
|
+
/**
|
|
654
|
+
* Get the current pseudo mode.
|
|
655
|
+
* @returns A Promise that resolves to a PseudoStateKey which is a string representing the current pseudo mode.
|
|
656
|
+
* @example
|
|
657
|
+
* ```ts
|
|
658
|
+
* const pseudoMode = await webflow.getPseudoMode();
|
|
659
|
+
* console.log('Current Pseudo Mode:', pseudoMode);
|
|
660
|
+
* ```
|
|
661
|
+
*/
|
|
662
|
+
getPseudoMode(): Promise<null | PseudoStateKey>;
|
|
663
|
+
/**
|
|
664
|
+
* Fetch the currently active page in the Webflow designer.
|
|
665
|
+
* @returns A Promise that resolves to a Page object representing the current page open in the Designer.
|
|
666
|
+
* @example
|
|
667
|
+
* ```ts
|
|
668
|
+
* const currentPage = await webflow.getCurrentPage();
|
|
669
|
+
* console.log('Current Page:', currentPage);
|
|
670
|
+
* ```
|
|
671
|
+
*/
|
|
672
|
+
getCurrentPage(): Promise<Page>;
|
|
673
|
+
/**
|
|
674
|
+
* @param page - The Page object representing the target page to switch to.
|
|
675
|
+
* @returns A Promise that resolves when the page switch is successful.
|
|
676
|
+
* @example
|
|
677
|
+
* ```ts
|
|
678
|
+
* const targetPage = <Get the target page>;
|
|
679
|
+
* await webflow.switchPage(targetPage);
|
|
680
|
+
* // Page switched successfully
|
|
681
|
+
* ```
|
|
682
|
+
*/
|
|
683
|
+
switchPage(page: Page): Promise<null>;
|
|
413
684
|
/**
|
|
414
685
|
* Sets the extension size to one of predefined sizes or a custom size. If the specified custom size is larger than
|
|
415
686
|
* the user's viewport size, the extension will default to the width/height of the browser's viewport.
|
|
@@ -544,88 +815,25 @@ interface WebflowApi {
|
|
|
544
815
|
event: 'currentcmsitem',
|
|
545
816
|
callback: (cmsItemId: null | string) => void
|
|
546
817
|
): Unsubscribe;
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
818
|
+
/**
|
|
819
|
+
* Subscribe to app mode changes. The callback receives the current mode
|
|
820
|
+
* and the full appModes capability map.
|
|
821
|
+
* @param event - The name of the event to subscribe to, specifically 'currentappmode'.
|
|
822
|
+
* @param callback - A callback function receiving the current AppModeChangeEvent.
|
|
823
|
+
*/
|
|
824
|
+
subscribe(
|
|
825
|
+
event: 'currentappmode',
|
|
826
|
+
callback: (event: AppModeChangeEvent) => void
|
|
827
|
+
): Unsubscribe;
|
|
550
828
|
subscribe(
|
|
551
829
|
event: 'pseudomode',
|
|
552
830
|
callback: (pseudoMode: null | PseudoStateKey) => void
|
|
553
831
|
): Unsubscribe;
|
|
554
|
-
|
|
555
|
-
getIdToken(): Promise<string>;
|
|
556
|
-
getAppSubscriptions(): Promise<Array<AppSubscription>>;
|
|
557
|
-
elementPresets: ElementPresets;
|
|
558
|
-
/**
|
|
559
|
-
* Removes the Style from the site.
|
|
560
|
-
* @example
|
|
561
|
-
* ```ts
|
|
562
|
-
* await webflow.removeStyle(style);
|
|
563
|
-
* ```
|
|
564
|
-
*/
|
|
565
|
-
removeStyle(style: Style): Promise<null>;
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Create a new asset, associated with the site
|
|
569
|
-
* @example
|
|
570
|
-
* ```ts
|
|
571
|
-
* const fileBlob = new File([blob], 'cat.png', { type: 'image/png' });
|
|
572
|
-
* const asset = await webflow.createAsset(fileBlob);
|
|
573
|
-
* ```
|
|
574
|
-
*/
|
|
575
|
-
createAsset(fileBlob: File): Promise<Asset>;
|
|
576
|
-
|
|
577
|
-
/**
|
|
578
|
-
* Gets an asset by its id
|
|
579
|
-
* @example
|
|
580
|
-
* ```ts
|
|
581
|
-
* const asset = await webflow.getAssetById('1234');
|
|
582
|
-
* ```
|
|
583
|
-
* @param id
|
|
584
|
-
*/
|
|
585
|
-
getAssetById(id: AssetId): Promise<null | Asset>;
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* Gets all assets for the site
|
|
589
|
-
* @example
|
|
590
|
-
* ```ts
|
|
591
|
-
* const assets = await webflow.getAllAssets();
|
|
592
|
-
* ```
|
|
593
|
-
*/
|
|
594
|
-
getAllAssets(): Promise<Array<Asset>>;
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* Gets all asset folders for the site
|
|
598
|
-
* @example
|
|
599
|
-
* ```ts
|
|
600
|
-
* const assetFolders = await webflow.getAssetFolders();
|
|
601
|
-
* console.log('Asset folders:', assetFolders);
|
|
602
|
-
* ```
|
|
603
|
-
* @returns A Promise that resolves to an array of AssetFolder objects
|
|
604
|
-
*/
|
|
605
|
-
getAllAssetFolders(): Promise<Array<AssetFolder>>;
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* Creates a new asset folder within a given site
|
|
609
|
-
* @param name - The name of the new asset folder.
|
|
610
|
-
* @param parentFolderId - Optional. The ID of the parent folder. If not provided, the folder will be created at the root level.
|
|
611
|
-
* @returns A Promise that resolves to the newly created AssetFolder object.
|
|
612
|
-
* @example
|
|
613
|
-
* ```ts
|
|
614
|
-
* const newFolder = await webflow.createAssetFolder('My New Folder');
|
|
615
|
-
* console.log('New folder created:', newFolder.id);
|
|
616
|
-
* ```
|
|
617
|
-
*/
|
|
618
|
-
createAssetFolder(
|
|
619
|
-
name: string,
|
|
620
|
-
parentFolderId?: string
|
|
621
|
-
): Promise<AssetFolder>;
|
|
622
|
-
|
|
623
832
|
/**
|
|
624
833
|
* Checks if the user has the ability to perform the given App Mode
|
|
625
834
|
* @param appModes
|
|
626
835
|
*/
|
|
627
836
|
canForAppMode(appModes: Array<AppMode>): Promise<{[key in AppMode]: boolean}>;
|
|
628
|
-
|
|
629
837
|
/**
|
|
630
838
|
* The list of App Modes that are available to be queried
|
|
631
839
|
* ```ts
|
|
@@ -633,7 +841,17 @@ interface WebflowApi {
|
|
|
633
841
|
* ```
|
|
634
842
|
*/
|
|
635
843
|
appModes: {[key in AppMode]: AppMode};
|
|
636
|
-
|
|
844
|
+
/**
|
|
845
|
+
* Checks if the current Designer mode matches the given mode name.
|
|
846
|
+
* @param mode - The mode name to check against (e.g., 'design', 'build', 'preview')
|
|
847
|
+
* @returns True if the Designer is currently in the specified mode
|
|
848
|
+
*/
|
|
849
|
+
isMode(mode: AppModeName): Promise<boolean>;
|
|
850
|
+
/**
|
|
851
|
+
* Gets the current Designer mode name.
|
|
852
|
+
* @returns The current mode name, or null if the mode cannot be determined
|
|
853
|
+
*/
|
|
854
|
+
getCurrentMode(): Promise<AppModeName | null>;
|
|
637
855
|
/**
|
|
638
856
|
* Closes the extension
|
|
639
857
|
* ```ts
|
|
@@ -641,7 +859,6 @@ interface WebflowApi {
|
|
|
641
859
|
* ```
|
|
642
860
|
*/
|
|
643
861
|
closeExtension(): Promise<null>;
|
|
644
|
-
|
|
645
862
|
/**
|
|
646
863
|
* Gets the current App connection
|
|
647
864
|
* ```ts
|
|
@@ -649,7 +866,6 @@ interface WebflowApi {
|
|
|
649
866
|
* ```
|
|
650
867
|
*/
|
|
651
868
|
getCurrentAppConnection(): Promise<null | string>;
|
|
652
|
-
|
|
653
869
|
/**
|
|
654
870
|
* Gets the current App connection resource
|
|
655
871
|
* ```ts
|
|
@@ -657,7 +873,6 @@ interface WebflowApi {
|
|
|
657
873
|
* ```
|
|
658
874
|
*/
|
|
659
875
|
getCurrentAppConnectionResource(): Promise<null | AppConnectionResource>;
|
|
660
|
-
|
|
661
876
|
/**
|
|
662
877
|
* Gets the current App launch context (i.e how the app was launched)
|
|
663
878
|
* ```ts
|
|
@@ -667,4 +882,27 @@ interface WebflowApi {
|
|
|
667
882
|
getLaunchContext(): Promise<null | LaunchContext>;
|
|
668
883
|
}
|
|
669
884
|
|
|
885
|
+
interface WebflowApi extends SharedApi, DesignerOnlyApi {}
|
|
886
|
+
|
|
887
|
+
interface WebflowPageApi extends SharedApi {}
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* Thrown when an API call fails because the Designer is in the wrong mode.
|
|
891
|
+
* Use `err.cause.tag` to identify the error programmatically.
|
|
892
|
+
* Use `err.message` for the human-readable description of what went wrong.
|
|
893
|
+
*/
|
|
894
|
+
interface AppModeForbiddenError extends Error {
|
|
895
|
+
cause: {
|
|
896
|
+
tag: 'ModeForbidden';
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
|
|
670
900
|
type Unsubscribe = () => void;
|
|
901
|
+
|
|
902
|
+
interface OpenCanvasByComponentId {
|
|
903
|
+
componentId: string;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
interface OpenCanvasByPageId {
|
|
907
|
+
pageId: string;
|
|
908
|
+
}
|