@webflow/designer-extension-typings 2.0.29 → 2.0.31
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 +356 -166
- package/components.d.ts +211 -0
- package/element-presets-generated.d.ts +2 -0
- package/element-settings-generated.d.ts +68 -0
- package/element-settings.d.ts +60 -0
- package/elements-generated.d.ts +1482 -556
- package/instance-props.d.ts +150 -0
- package/package.json +1 -1
- package/pages.d.ts +47 -0
package/api.d.ts
CHANGED
|
@@ -8,10 +8,20 @@
|
|
|
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" />
|
|
13
|
+
/// <reference path="./instance-props.d.ts" />
|
|
11
14
|
/// <reference path="./app-modes-generated.d.ts" />
|
|
12
15
|
/// <reference path="./app-connections.d.ts" />
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
type AppModeName = 'design' | 'build' | 'preview' | 'edit' | 'comment';
|
|
18
|
+
|
|
19
|
+
interface AppModeChangeEvent {
|
|
20
|
+
mode: AppModeName | null;
|
|
21
|
+
appModes: {[key in AppMode]: boolean};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface SharedApi {
|
|
15
25
|
/**
|
|
16
26
|
* Get metadata about the current Site.
|
|
17
27
|
* @returns A Promise that resolves to a record containing information about the site that is open in the
|
|
@@ -52,50 +62,6 @@ interface WebflowApi {
|
|
|
52
62
|
stage: 'staging' | 'production';
|
|
53
63
|
}>;
|
|
54
64
|
}>;
|
|
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
65
|
/**
|
|
100
66
|
* Renders the specified element to WHTML format.
|
|
101
67
|
* @param element - The element to render
|
|
@@ -149,34 +115,12 @@ interface WebflowApi {
|
|
|
149
115
|
position?: 'before' | 'after' | 'append' | 'prepend' | 'replace'
|
|
150
116
|
): Promise<AnyElement>;
|
|
151
117
|
|
|
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
118
|
/**
|
|
176
119
|
* Create a component by promoting a Root Element.
|
|
177
120
|
* @param name - The name of the component.
|
|
178
121
|
* @param root - An Element that will become the Root Element of the Component.
|
|
179
122
|
* @returns A Promise resolving to an object containing the newly created Component - with the id property.
|
|
123
|
+
* @deprecated Use `registerComponent(options, root)` instead to provide richer metadata.
|
|
180
124
|
* @example
|
|
181
125
|
* ```ts
|
|
182
126
|
* const element = webflow.createDOM('div')
|
|
@@ -207,6 +151,50 @@ interface WebflowApi {
|
|
|
207
151
|
* ```
|
|
208
152
|
*/
|
|
209
153
|
registerComponent(options: ComponentOptions): Promise<Component>;
|
|
154
|
+
/**
|
|
155
|
+
* Duplicate an existing component.
|
|
156
|
+
* @param options - Options for the new component, including a required name.
|
|
157
|
+
* @param source - The existing Component to duplicate.
|
|
158
|
+
* @returns A Promise resolving to the newly created Component.
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* const [original] = await webflow.getAllComponents()
|
|
162
|
+
* const copy = await webflow.registerComponent({name: 'Hero Copy'}, original)
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
registerComponent(
|
|
166
|
+
options: ComponentOptions,
|
|
167
|
+
source: Component
|
|
168
|
+
): Promise<Component>;
|
|
169
|
+
/**
|
|
170
|
+
* Convert an element or element preset into a component. Equivalent to the
|
|
171
|
+
* "Convert selection" action in the Designer's "New component" menu.
|
|
172
|
+
* Elements do not need to be on the page. You can build the tree with
|
|
173
|
+
* `createDOM` first and pass it directly.
|
|
174
|
+
*
|
|
175
|
+
* When `root` is a canvas `AnyElement`, the source element is replaced
|
|
176
|
+
* in-place by a new component instance by default. Pass `replace: false`
|
|
177
|
+
* in `options` to skip this substitution and keep the original element.
|
|
178
|
+
* @param options - Options for the new component. `name` is required;
|
|
179
|
+
* `group`, `description`, and `replace` are optional.
|
|
180
|
+
* @param root - The element, element preset, or builder element that becomes the component root.
|
|
181
|
+
* @returns A Promise resolving to the newly created Component.
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* // Convert a canvas element and replace it with a component instance (default)
|
|
185
|
+
* const el = await webflow.getSelectedElement()
|
|
186
|
+
* const card = await webflow.registerComponent({name: 'Card', group: 'UI'}, el)
|
|
187
|
+
*
|
|
188
|
+
* // Convert without replacing the original element in the canvas
|
|
189
|
+
* const card2 = await webflow.registerComponent(
|
|
190
|
+
* {name: 'Card 2', replace: false},
|
|
191
|
+
* el
|
|
192
|
+
* )
|
|
193
|
+
*/
|
|
194
|
+
registerComponent(
|
|
195
|
+
options: ComponentOptions,
|
|
196
|
+
root: AnyElement | ElementPreset<AnyElement> | BuilderElement
|
|
197
|
+
): Promise<Component>;
|
|
210
198
|
/**
|
|
211
199
|
* Delete a component from the Designer. If there are any instances of the Component within the site, they will
|
|
212
200
|
* be converted to regular Elements.
|
|
@@ -237,6 +225,76 @@ interface WebflowApi {
|
|
|
237
225
|
* ```
|
|
238
226
|
*/
|
|
239
227
|
getAllComponents(): Promise<Array<Component>>;
|
|
228
|
+
/**
|
|
229
|
+
* Search site components with optional fuzzy filtering.
|
|
230
|
+
* Returns a flat array of {@link ComponentSearchResult} objects in the same order as the
|
|
231
|
+
* Components panel (insertion order). When `options.q` is provided, results are filtered
|
|
232
|
+
* using FlexSearch (`tokenize: 'full'`) — the same algorithm used by the Components panel.
|
|
233
|
+
*
|
|
234
|
+
* @param options - Optional search options.
|
|
235
|
+
* @param options.q - Search query string. Omit or leave empty to return all components.
|
|
236
|
+
* @returns A Promise resolving to an array of {@link ComponentSearchResult} objects.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```ts
|
|
240
|
+
* // Get all components
|
|
241
|
+
* const all = await webflow.searchComponents();
|
|
242
|
+
*
|
|
243
|
+
* // Filter by name
|
|
244
|
+
* const heroes = await webflow.searchComponents({ q: 'Hero' });
|
|
245
|
+
* heroes.forEach(c => {
|
|
246
|
+
* console.log(c.name, c.instances, c.canEdit, c.library);
|
|
247
|
+
* });
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
searchComponents(
|
|
251
|
+
options?: SearchComponentsOptions
|
|
252
|
+
): Promise<ComponentSearchResult[]>;
|
|
253
|
+
/**
|
|
254
|
+
* Returns a component reference when the user is editing in-context or on the component canvas, or null if no component is being edited.
|
|
255
|
+
* @returns A Promise that resolves to a Component reference or null.
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* const component = await webflow.getCurrentComponent();
|
|
259
|
+
* if (component) {
|
|
260
|
+
* const name = await component.getName();
|
|
261
|
+
* console.log(`Currently editing: ${name}`);
|
|
262
|
+
* }
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
getCurrentComponent(): Promise<Component | null>;
|
|
266
|
+
/**
|
|
267
|
+
* Get a Component by its unique identifier.
|
|
268
|
+
* @param id - The unique identifier of the component.
|
|
269
|
+
* @returns A Promise that resolves to the Component with the given id.
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* const componentId = '4a669354-353a-97eb-795c-4471b406e043';
|
|
273
|
+
* const component = await webflow.getComponent(componentId);
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
getComponent(id: ComponentId): Promise<Component>;
|
|
277
|
+
/**
|
|
278
|
+
* Get a Component by its display name. Only returns native site components.
|
|
279
|
+
* Throws if the matching component is a code component.
|
|
280
|
+
* @param name - The display name of the component.
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts
|
|
283
|
+
* const component = await webflow.getComponentByName('Hero');
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
getComponentByName(name: string): Promise<Component>;
|
|
287
|
+
/**
|
|
288
|
+
* Get a Component by its group and display name. Only returns native site components.
|
|
289
|
+
* Throws if the matching component is a code component.
|
|
290
|
+
* @param group - The group name the component belongs to.
|
|
291
|
+
* @param name - The display name of the component.
|
|
292
|
+
* @example
|
|
293
|
+
* ```ts
|
|
294
|
+
* const component = await webflow.getComponentByName('Marketing', 'Hero');
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
getComponentByName(group: string, name: string): Promise<Component>;
|
|
240
298
|
/**
|
|
241
299
|
* Focus the designer on a Component. When a component is in focus, all Globals pertain specifically to that
|
|
242
300
|
* Component, not the entire Site.
|
|
@@ -258,6 +316,38 @@ interface WebflowApi {
|
|
|
258
316
|
* ```
|
|
259
317
|
*/
|
|
260
318
|
exitComponent(): Promise<null>;
|
|
319
|
+
/**
|
|
320
|
+
* Navigate the Designer to a component canvas or page.
|
|
321
|
+
* @param options - An object with either pageId or componentId.
|
|
322
|
+
* @returns A Promise that resolves when the navigation is complete.
|
|
323
|
+
* @example
|
|
324
|
+
* ```ts
|
|
325
|
+
* // Open a component canvas by component id
|
|
326
|
+
* await webflow.openCanvas({componentId: '4a669354-353a-97eb-795c-4471b406e043'});
|
|
327
|
+
*
|
|
328
|
+
* // Open a component canvas by page id
|
|
329
|
+
* await webflow.openCanvas({pageId: '123'});
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
openCanvas(
|
|
333
|
+
options: OpenCanvasByComponentId | OpenCanvasByPageId
|
|
334
|
+
): Promise<void>;
|
|
335
|
+
/**
|
|
336
|
+
* Navigate the Designer to a component canvas or page using a reference.
|
|
337
|
+
* @param reference - A Component, ComponentElement, or Page reference.
|
|
338
|
+
* @returns A Promise that resolves when the navigation is complete.
|
|
339
|
+
* @example
|
|
340
|
+
* ```ts
|
|
341
|
+
* // Open a component canvas by component
|
|
342
|
+
* const heroComponent = await webflow.getComponent('4a669354-353a-97eb-795c-4471b406e043');
|
|
343
|
+
* await webflow.openCanvas(heroComponent);
|
|
344
|
+
*
|
|
345
|
+
* // Open a component canvas by page
|
|
346
|
+
* const myPage = await webflow.getPage('123');
|
|
347
|
+
* await webflow.openCanvas(myPage);
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
openCanvas(reference: Component | ComponentElement | Page): Promise<void>;
|
|
261
351
|
/**
|
|
262
352
|
* Get Root element. When the designer is focused or "entered" into a Component, this method will get the
|
|
263
353
|
* outermost element in the Component.
|
|
@@ -349,16 +439,6 @@ interface WebflowApi {
|
|
|
349
439
|
* ```
|
|
350
440
|
*/
|
|
351
441
|
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
442
|
/**
|
|
363
443
|
* Fetch an array of all pages and folders in the Webflow project.
|
|
364
444
|
* @returns A Promise that resolves to an array of Page and Folder objects representing all the pages
|
|
@@ -393,17 +473,6 @@ interface WebflowApi {
|
|
|
393
473
|
* ```
|
|
394
474
|
*/
|
|
395
475
|
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
476
|
/**
|
|
408
477
|
* Access the default variable collection.
|
|
409
478
|
* @returns A Promise that resolves into a Collection.
|
|
@@ -459,6 +528,160 @@ interface WebflowApi {
|
|
|
459
528
|
*/
|
|
460
529
|
removeVariableCollection(id: VariableCollectionId): Promise<boolean>;
|
|
461
530
|
|
|
531
|
+
getIdToken(): Promise<string>;
|
|
532
|
+
getAppSubscriptions(): Promise<Array<AppSubscription>>;
|
|
533
|
+
elementPresets: ElementPresets;
|
|
534
|
+
/**
|
|
535
|
+
* Removes the Style from the site.
|
|
536
|
+
* @example
|
|
537
|
+
* ```ts
|
|
538
|
+
* await webflow.removeStyle(style);
|
|
539
|
+
* ```
|
|
540
|
+
*/
|
|
541
|
+
removeStyle(style: Style): Promise<null>;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Create a new asset, associated with the site
|
|
545
|
+
* @example
|
|
546
|
+
* ```ts
|
|
547
|
+
* const fileBlob = new File([blob], 'cat.png', { type: 'image/png' });
|
|
548
|
+
* const asset = await webflow.createAsset(fileBlob);
|
|
549
|
+
* ```
|
|
550
|
+
*/
|
|
551
|
+
createAsset(fileBlob: File): Promise<Asset>;
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Gets an asset by its id
|
|
555
|
+
* @example
|
|
556
|
+
* ```ts
|
|
557
|
+
* const asset = await webflow.getAssetById('1234');
|
|
558
|
+
* ```
|
|
559
|
+
* @param id
|
|
560
|
+
*/
|
|
561
|
+
getAssetById(id: AssetId): Promise<null | Asset>;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Gets all assets for the site
|
|
565
|
+
* @example
|
|
566
|
+
* ```ts
|
|
567
|
+
* const assets = await webflow.getAllAssets();
|
|
568
|
+
* ```
|
|
569
|
+
*/
|
|
570
|
+
getAllAssets(): Promise<Array<Asset>>;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Gets all asset folders for the site
|
|
574
|
+
* @example
|
|
575
|
+
* ```ts
|
|
576
|
+
* const assetFolders = await webflow.getAssetFolders();
|
|
577
|
+
* console.log('Asset folders:', assetFolders);
|
|
578
|
+
* ```
|
|
579
|
+
* @returns A Promise that resolves to an array of AssetFolder objects
|
|
580
|
+
*/
|
|
581
|
+
getAllAssetFolders(): Promise<Array<AssetFolder>>;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Creates a new asset folder within a given site
|
|
585
|
+
* @param name - The name of the new asset folder.
|
|
586
|
+
* @param parentFolderId - Optional. The ID of the parent folder. If not provided, the folder will be created at the root level.
|
|
587
|
+
* @returns A Promise that resolves to the newly created AssetFolder object.
|
|
588
|
+
* @example
|
|
589
|
+
* ```ts
|
|
590
|
+
* const newFolder = await webflow.createAssetFolder('My New Folder');
|
|
591
|
+
* console.log('New folder created:', newFolder.id);
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
createAssetFolder(
|
|
595
|
+
name: string,
|
|
596
|
+
parentFolderId?: string
|
|
597
|
+
): Promise<AssetFolder>;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
interface DesignerOnlyApi {
|
|
601
|
+
/**
|
|
602
|
+
* Get the currently selected element in the Webflow Designer.
|
|
603
|
+
* @returns A promise that resolves to one of the following:
|
|
604
|
+
* - null: If no element is currently selected in the Designer
|
|
605
|
+
* - AnyElement: an object representing the selected element, which can be of any type.
|
|
606
|
+
* @example
|
|
607
|
+
* ```ts
|
|
608
|
+
* const selectedElement = await webflow.getSelectedElement();
|
|
609
|
+
* if (selectedElement) {
|
|
610
|
+
* // Handle the selected element
|
|
611
|
+
* } else {
|
|
612
|
+
* // No element is currently selected
|
|
613
|
+
* }
|
|
614
|
+
* ```
|
|
615
|
+
*/
|
|
616
|
+
getSelectedElement(): Promise<null | AnyElement>;
|
|
617
|
+
/**
|
|
618
|
+
* Sets the currently selected element in the Webflow Designer.
|
|
619
|
+
* @returns A promise that resolves to one of the following:
|
|
620
|
+
* - null: If no element is able to be currently selected in the Designer
|
|
621
|
+
* - AnyElement: an object representing the selected element, which can be of any type.
|
|
622
|
+
* @example
|
|
623
|
+
* ```ts
|
|
624
|
+
* await webflow.setSelectedElement(element);
|
|
625
|
+
* ```
|
|
626
|
+
*/
|
|
627
|
+
setSelectedElement(element: AnyElement): Promise<null | AnyElement>;
|
|
628
|
+
/**
|
|
629
|
+
* Captures a screenshot of the specified element.
|
|
630
|
+
* @returns A promise that resolves to a base64 string representing the screenshot of the element.
|
|
631
|
+
* @example
|
|
632
|
+
* ```ts
|
|
633
|
+
* const selectedElement = await webflow.getSelectedElement();
|
|
634
|
+
* if (selectedElement) {
|
|
635
|
+
* const screenshot = await webflow.getElementSnapshot(selectedElement);
|
|
636
|
+
* console.log('Screenshot:', screenshot);
|
|
637
|
+
* }else{
|
|
638
|
+
* console.log('No element selected');
|
|
639
|
+
* }
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
642
|
+
getElementSnapshot(element: AnyElement): Promise<null | string>;
|
|
643
|
+
/**
|
|
644
|
+
* Get the current media query breakpoint ID.
|
|
645
|
+
* @returns A Promise that resolves to a BreakpointId which is a string representing the current media query
|
|
646
|
+
* breakpoint. A BreakpointId is one of 'tiny', 'small', 'medium', 'main', 'large', 'xl', 'xxl'.
|
|
647
|
+
* @example
|
|
648
|
+
* ```ts
|
|
649
|
+
* const breakpoint = await webflow.getMediaQuery();
|
|
650
|
+
* console.log('Current Media Query:', breakpoint);
|
|
651
|
+
* ```
|
|
652
|
+
*/
|
|
653
|
+
getMediaQuery(): Promise<BreakpointId>;
|
|
654
|
+
/**
|
|
655
|
+
* Get the current pseudo mode.
|
|
656
|
+
* @returns A Promise that resolves to a PseudoStateKey which is a string representing the current pseudo mode.
|
|
657
|
+
* @example
|
|
658
|
+
* ```ts
|
|
659
|
+
* const pseudoMode = await webflow.getPseudoMode();
|
|
660
|
+
* console.log('Current Pseudo Mode:', pseudoMode);
|
|
661
|
+
* ```
|
|
662
|
+
*/
|
|
663
|
+
getPseudoMode(): Promise<null | PseudoStateKey>;
|
|
664
|
+
/**
|
|
665
|
+
* Fetch the currently active page in the Webflow designer.
|
|
666
|
+
* @returns A Promise that resolves to a Page object representing the current page open in the Designer.
|
|
667
|
+
* @example
|
|
668
|
+
* ```ts
|
|
669
|
+
* const currentPage = await webflow.getCurrentPage();
|
|
670
|
+
* console.log('Current Page:', currentPage);
|
|
671
|
+
* ```
|
|
672
|
+
*/
|
|
673
|
+
getCurrentPage(): Promise<Page>;
|
|
674
|
+
/**
|
|
675
|
+
* @param page - The Page object representing the target page to switch to.
|
|
676
|
+
* @returns A Promise that resolves when the page switch is successful.
|
|
677
|
+
* @example
|
|
678
|
+
* ```ts
|
|
679
|
+
* const targetPage = <Get the target page>;
|
|
680
|
+
* await webflow.switchPage(targetPage);
|
|
681
|
+
* // Page switched successfully
|
|
682
|
+
* ```
|
|
683
|
+
*/
|
|
684
|
+
switchPage(page: Page): Promise<null>;
|
|
462
685
|
/**
|
|
463
686
|
* Sets the extension size to one of predefined sizes or a custom size. If the specified custom size is larger than
|
|
464
687
|
* the user's viewport size, the extension will default to the width/height of the browser's viewport.
|
|
@@ -593,88 +816,25 @@ interface WebflowApi {
|
|
|
593
816
|
event: 'currentcmsitem',
|
|
594
817
|
callback: (cmsItemId: null | string) => void
|
|
595
818
|
): Unsubscribe;
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
819
|
+
/**
|
|
820
|
+
* Subscribe to app mode changes. The callback receives the current mode
|
|
821
|
+
* and the full appModes capability map.
|
|
822
|
+
* @param event - The name of the event to subscribe to, specifically 'currentappmode'.
|
|
823
|
+
* @param callback - A callback function receiving the current AppModeChangeEvent.
|
|
824
|
+
*/
|
|
825
|
+
subscribe(
|
|
826
|
+
event: 'currentappmode',
|
|
827
|
+
callback: (event: AppModeChangeEvent) => void
|
|
828
|
+
): Unsubscribe;
|
|
599
829
|
subscribe(
|
|
600
830
|
event: 'pseudomode',
|
|
601
831
|
callback: (pseudoMode: null | PseudoStateKey) => void
|
|
602
832
|
): 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
833
|
/**
|
|
673
834
|
* Checks if the user has the ability to perform the given App Mode
|
|
674
835
|
* @param appModes
|
|
675
836
|
*/
|
|
676
837
|
canForAppMode(appModes: Array<AppMode>): Promise<{[key in AppMode]: boolean}>;
|
|
677
|
-
|
|
678
838
|
/**
|
|
679
839
|
* The list of App Modes that are available to be queried
|
|
680
840
|
* ```ts
|
|
@@ -682,7 +842,17 @@ interface WebflowApi {
|
|
|
682
842
|
* ```
|
|
683
843
|
*/
|
|
684
844
|
appModes: {[key in AppMode]: AppMode};
|
|
685
|
-
|
|
845
|
+
/**
|
|
846
|
+
* Checks if the current Designer mode matches the given mode name.
|
|
847
|
+
* @param mode - The mode name to check against (e.g., 'design', 'build', 'preview')
|
|
848
|
+
* @returns True if the Designer is currently in the specified mode
|
|
849
|
+
*/
|
|
850
|
+
isMode(mode: AppModeName): Promise<boolean>;
|
|
851
|
+
/**
|
|
852
|
+
* Gets the current Designer mode name.
|
|
853
|
+
* @returns The current mode name, or null if the mode cannot be determined
|
|
854
|
+
*/
|
|
855
|
+
getCurrentMode(): Promise<AppModeName | null>;
|
|
686
856
|
/**
|
|
687
857
|
* Closes the extension
|
|
688
858
|
* ```ts
|
|
@@ -690,7 +860,6 @@ interface WebflowApi {
|
|
|
690
860
|
* ```
|
|
691
861
|
*/
|
|
692
862
|
closeExtension(): Promise<null>;
|
|
693
|
-
|
|
694
863
|
/**
|
|
695
864
|
* Gets the current App connection
|
|
696
865
|
* ```ts
|
|
@@ -698,7 +867,6 @@ interface WebflowApi {
|
|
|
698
867
|
* ```
|
|
699
868
|
*/
|
|
700
869
|
getCurrentAppConnection(): Promise<null | string>;
|
|
701
|
-
|
|
702
870
|
/**
|
|
703
871
|
* Gets the current App connection resource
|
|
704
872
|
* ```ts
|
|
@@ -706,7 +874,6 @@ interface WebflowApi {
|
|
|
706
874
|
* ```
|
|
707
875
|
*/
|
|
708
876
|
getCurrentAppConnectionResource(): Promise<null | AppConnectionResource>;
|
|
709
|
-
|
|
710
877
|
/**
|
|
711
878
|
* Gets the current App launch context (i.e how the app was launched)
|
|
712
879
|
* ```ts
|
|
@@ -716,4 +883,27 @@ interface WebflowApi {
|
|
|
716
883
|
getLaunchContext(): Promise<null | LaunchContext>;
|
|
717
884
|
}
|
|
718
885
|
|
|
886
|
+
interface WebflowApi extends SharedApi, DesignerOnlyApi {}
|
|
887
|
+
|
|
888
|
+
interface WebflowPageApi extends SharedApi {}
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Thrown when an API call fails because the Designer is in the wrong mode.
|
|
892
|
+
* Use `err.cause.tag` to identify the error programmatically.
|
|
893
|
+
* Use `err.message` for the human-readable description of what went wrong.
|
|
894
|
+
*/
|
|
895
|
+
interface AppModeForbiddenError extends Error {
|
|
896
|
+
cause: {
|
|
897
|
+
tag: 'ModeForbidden';
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
|
|
719
901
|
type Unsubscribe = () => void;
|
|
902
|
+
|
|
903
|
+
interface OpenCanvasByComponentId {
|
|
904
|
+
componentId: string;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
interface OpenCanvasByPageId {
|
|
908
|
+
pageId: string;
|
|
909
|
+
}
|