@webflow/designer-extension-typings 2.0.29 → 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 +355 -166
- package/components.d.ts +173 -0
- package/element-settings-generated.d.ts +49 -0
- package/element-settings.d.ts +17 -0
- package/elements-generated.d.ts +1440 -556
- package/package.json +1 -1
- package/pages.d.ts +47 -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
|
|
@@ -149,34 +114,12 @@ interface WebflowApi {
|
|
|
149
114
|
position?: 'before' | 'after' | 'append' | 'prepend' | 'replace'
|
|
150
115
|
): Promise<AnyElement>;
|
|
151
116
|
|
|
152
|
-
/**
|
|
153
|
-
* Get the current media query breakpoint ID.
|
|
154
|
-
* @returns A Promise that resolves to a BreakpointId which is a string representing the current media query
|
|
155
|
-
* breakpoint. A BreakpointId is one of 'tiny', 'small', 'medium', 'main', 'large', 'xl', 'xxl'.
|
|
156
|
-
* @example
|
|
157
|
-
* ```ts
|
|
158
|
-
* const breakpoint = await webflow.getMediaQuery();
|
|
159
|
-
* console.log('Current Media Query:', breakpoint);
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
getMediaQuery(): Promise<BreakpointId>;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Get the current pseudo mode.
|
|
166
|
-
* @returns A Promise that resolves to a PseudoStateKey which is a string representing the current pseudo mode.
|
|
167
|
-
* @example
|
|
168
|
-
* ```ts
|
|
169
|
-
* const pseudoMode = await webflow.getPseudoMode();
|
|
170
|
-
* console.log('Current Pseudo Mode:', pseudoMode);
|
|
171
|
-
* ```
|
|
172
|
-
*/
|
|
173
|
-
getPseudoMode(): Promise<null | PseudoStateKey>;
|
|
174
|
-
|
|
175
117
|
/**
|
|
176
118
|
* Create a component by promoting a Root Element.
|
|
177
119
|
* @param name - The name of the component.
|
|
178
120
|
* @param root - An Element that will become the Root Element of the Component.
|
|
179
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.
|
|
180
123
|
* @example
|
|
181
124
|
* ```ts
|
|
182
125
|
* const element = webflow.createDOM('div')
|
|
@@ -207,6 +150,50 @@ interface WebflowApi {
|
|
|
207
150
|
* ```
|
|
208
151
|
*/
|
|
209
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>;
|
|
210
197
|
/**
|
|
211
198
|
* Delete a component from the Designer. If there are any instances of the Component within the site, they will
|
|
212
199
|
* be converted to regular Elements.
|
|
@@ -237,6 +224,76 @@ interface WebflowApi {
|
|
|
237
224
|
* ```
|
|
238
225
|
*/
|
|
239
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>;
|
|
240
297
|
/**
|
|
241
298
|
* Focus the designer on a Component. When a component is in focus, all Globals pertain specifically to that
|
|
242
299
|
* Component, not the entire Site.
|
|
@@ -258,6 +315,38 @@ interface WebflowApi {
|
|
|
258
315
|
* ```
|
|
259
316
|
*/
|
|
260
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>;
|
|
261
350
|
/**
|
|
262
351
|
* Get Root element. When the designer is focused or "entered" into a Component, this method will get the
|
|
263
352
|
* outermost element in the Component.
|
|
@@ -349,16 +438,6 @@ interface WebflowApi {
|
|
|
349
438
|
* ```
|
|
350
439
|
*/
|
|
351
440
|
getAllStyles(): Promise<Array<Style>>;
|
|
352
|
-
/**
|
|
353
|
-
* Fetch the currently active page in the Webflow designer.
|
|
354
|
-
* @returns A Promise that resolves to a Page object representing the current page open in the Designer.
|
|
355
|
-
* @example
|
|
356
|
-
* ```ts
|
|
357
|
-
* const currentPage = await webflow.getCurrentPage();
|
|
358
|
-
* console.log('Current Page:', currentPage);
|
|
359
|
-
* ```
|
|
360
|
-
*/
|
|
361
|
-
getCurrentPage(): Promise<Page>;
|
|
362
441
|
/**
|
|
363
442
|
* Fetch an array of all pages and folders in the Webflow project.
|
|
364
443
|
* @returns A Promise that resolves to an array of Page and Folder objects representing all the pages
|
|
@@ -393,17 +472,6 @@ interface WebflowApi {
|
|
|
393
472
|
* ```
|
|
394
473
|
*/
|
|
395
474
|
createPage(): Promise<Page>;
|
|
396
|
-
/**
|
|
397
|
-
* @param page - The Page object representing the target page to switch to.
|
|
398
|
-
* @returns A Promise that resolves when the page switch is successful.
|
|
399
|
-
* @example
|
|
400
|
-
* ```ts
|
|
401
|
-
* const targetPage = <Get the target page>;
|
|
402
|
-
* await webflow.switchPage(targetPage);
|
|
403
|
-
* // Page switched successfully
|
|
404
|
-
* ```
|
|
405
|
-
*/
|
|
406
|
-
switchPage(page: Page): Promise<null>;
|
|
407
475
|
/**
|
|
408
476
|
* Access the default variable collection.
|
|
409
477
|
* @returns A Promise that resolves into a Collection.
|
|
@@ -459,6 +527,160 @@ interface WebflowApi {
|
|
|
459
527
|
*/
|
|
460
528
|
removeVariableCollection(id: VariableCollectionId): Promise<boolean>;
|
|
461
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>;
|
|
462
684
|
/**
|
|
463
685
|
* Sets the extension size to one of predefined sizes or a custom size. If the specified custom size is larger than
|
|
464
686
|
* the user's viewport size, the extension will default to the width/height of the browser's viewport.
|
|
@@ -593,88 +815,25 @@ interface WebflowApi {
|
|
|
593
815
|
event: 'currentcmsitem',
|
|
594
816
|
callback: (cmsItemId: null | string) => void
|
|
595
817
|
): Unsubscribe;
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
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;
|
|
599
828
|
subscribe(
|
|
600
829
|
event: 'pseudomode',
|
|
601
830
|
callback: (pseudoMode: null | PseudoStateKey) => void
|
|
602
831
|
): Unsubscribe;
|
|
603
|
-
|
|
604
|
-
getIdToken(): Promise<string>;
|
|
605
|
-
getAppSubscriptions(): Promise<Array<AppSubscription>>;
|
|
606
|
-
elementPresets: ElementPresets;
|
|
607
|
-
/**
|
|
608
|
-
* Removes the Style from the site.
|
|
609
|
-
* @example
|
|
610
|
-
* ```ts
|
|
611
|
-
* await webflow.removeStyle(style);
|
|
612
|
-
* ```
|
|
613
|
-
*/
|
|
614
|
-
removeStyle(style: Style): Promise<null>;
|
|
615
|
-
|
|
616
|
-
/**
|
|
617
|
-
* Create a new asset, associated with the site
|
|
618
|
-
* @example
|
|
619
|
-
* ```ts
|
|
620
|
-
* const fileBlob = new File([blob], 'cat.png', { type: 'image/png' });
|
|
621
|
-
* const asset = await webflow.createAsset(fileBlob);
|
|
622
|
-
* ```
|
|
623
|
-
*/
|
|
624
|
-
createAsset(fileBlob: File): Promise<Asset>;
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* Gets an asset by its id
|
|
628
|
-
* @example
|
|
629
|
-
* ```ts
|
|
630
|
-
* const asset = await webflow.getAssetById('1234');
|
|
631
|
-
* ```
|
|
632
|
-
* @param id
|
|
633
|
-
*/
|
|
634
|
-
getAssetById(id: AssetId): Promise<null | Asset>;
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* Gets all assets for the site
|
|
638
|
-
* @example
|
|
639
|
-
* ```ts
|
|
640
|
-
* const assets = await webflow.getAllAssets();
|
|
641
|
-
* ```
|
|
642
|
-
*/
|
|
643
|
-
getAllAssets(): Promise<Array<Asset>>;
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* Gets all asset folders for the site
|
|
647
|
-
* @example
|
|
648
|
-
* ```ts
|
|
649
|
-
* const assetFolders = await webflow.getAssetFolders();
|
|
650
|
-
* console.log('Asset folders:', assetFolders);
|
|
651
|
-
* ```
|
|
652
|
-
* @returns A Promise that resolves to an array of AssetFolder objects
|
|
653
|
-
*/
|
|
654
|
-
getAllAssetFolders(): Promise<Array<AssetFolder>>;
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* Creates a new asset folder within a given site
|
|
658
|
-
* @param name - The name of the new asset folder.
|
|
659
|
-
* @param parentFolderId - Optional. The ID of the parent folder. If not provided, the folder will be created at the root level.
|
|
660
|
-
* @returns A Promise that resolves to the newly created AssetFolder object.
|
|
661
|
-
* @example
|
|
662
|
-
* ```ts
|
|
663
|
-
* const newFolder = await webflow.createAssetFolder('My New Folder');
|
|
664
|
-
* console.log('New folder created:', newFolder.id);
|
|
665
|
-
* ```
|
|
666
|
-
*/
|
|
667
|
-
createAssetFolder(
|
|
668
|
-
name: string,
|
|
669
|
-
parentFolderId?: string
|
|
670
|
-
): Promise<AssetFolder>;
|
|
671
|
-
|
|
672
832
|
/**
|
|
673
833
|
* Checks if the user has the ability to perform the given App Mode
|
|
674
834
|
* @param appModes
|
|
675
835
|
*/
|
|
676
836
|
canForAppMode(appModes: Array<AppMode>): Promise<{[key in AppMode]: boolean}>;
|
|
677
|
-
|
|
678
837
|
/**
|
|
679
838
|
* The list of App Modes that are available to be queried
|
|
680
839
|
* ```ts
|
|
@@ -682,7 +841,17 @@ interface WebflowApi {
|
|
|
682
841
|
* ```
|
|
683
842
|
*/
|
|
684
843
|
appModes: {[key in AppMode]: AppMode};
|
|
685
|
-
|
|
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>;
|
|
686
855
|
/**
|
|
687
856
|
* Closes the extension
|
|
688
857
|
* ```ts
|
|
@@ -690,7 +859,6 @@ interface WebflowApi {
|
|
|
690
859
|
* ```
|
|
691
860
|
*/
|
|
692
861
|
closeExtension(): Promise<null>;
|
|
693
|
-
|
|
694
862
|
/**
|
|
695
863
|
* Gets the current App connection
|
|
696
864
|
* ```ts
|
|
@@ -698,7 +866,6 @@ interface WebflowApi {
|
|
|
698
866
|
* ```
|
|
699
867
|
*/
|
|
700
868
|
getCurrentAppConnection(): Promise<null | string>;
|
|
701
|
-
|
|
702
869
|
/**
|
|
703
870
|
* Gets the current App connection resource
|
|
704
871
|
* ```ts
|
|
@@ -706,7 +873,6 @@ interface WebflowApi {
|
|
|
706
873
|
* ```
|
|
707
874
|
*/
|
|
708
875
|
getCurrentAppConnectionResource(): Promise<null | AppConnectionResource>;
|
|
709
|
-
|
|
710
876
|
/**
|
|
711
877
|
* Gets the current App launch context (i.e how the app was launched)
|
|
712
878
|
* ```ts
|
|
@@ -716,4 +882,27 @@ interface WebflowApi {
|
|
|
716
882
|
getLaunchContext(): Promise<null | LaunchContext>;
|
|
717
883
|
}
|
|
718
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
|
+
|
|
719
900
|
type Unsubscribe = () => void;
|
|
901
|
+
|
|
902
|
+
interface OpenCanvasByComponentId {
|
|
903
|
+
componentId: string;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
interface OpenCanvasByPageId {
|
|
907
|
+
pageId: string;
|
|
908
|
+
}
|