Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/PermissionsMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const permissionsMap: PermissionsMap = {
getAllComponents: { permissions: ['canAccessCanvas'] },
getComponentByName: { permissions: ['canAccessCanvas'] },
getComponentByNameAndGroup: { permissions: ['canAccessCanvas'] },
searchComponents: { permissions: ['canAccessCanvas'] },
getInstanceCount: { permissions: ['canAccessCanvas'] },
getVariants: { permissions: ['canAccessCanvas'] },
getSelectedVariant: { permissions: ['canAccessCanvas'] },
Expand Down
10 changes: 10 additions & 0 deletions src/designer-extension-typings/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ interface WebflowApi {
* ```
*/
getComponentByName(a: string, b?: string): Promise<Component>;
/**
* Searches for Components by name
* @returns A Promise that resolves to an array or objects with information about matching Components, not the `Component` objects themselves.
* @example
* ```ts
* const heroes = await webflow.searchComponents({ q: 'Hero' });
* console.log(heroes);
* ```
*/
searchComponents(options: SearchComponentsOptions?): Promise<Array<ComponentSearchResult>>
/**
* Gets the number of instances of a component.
* @returns A Promise that resolves to the number of instances of the component across the entire site.
Expand Down
18 changes: 18 additions & 0 deletions src/designer-extension-typings/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,21 @@ interface Variant {
name: string;
isSelected: boolean;
}

interface SearchComponentsOptions {
/** Fuzzy search query matching Component panel search behavior */
q?: string;
}
interface ComponentLibrary {
name: string;
id: string;
}
interface ComponentSearchResult {
id: string;
name: string;
group: string;
description: string;
instances: number;
canEdit: boolean;
library: ComponentLibrary | null;
}
5 changes: 5 additions & 0 deletions src/examples/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export const Components = {
console.log(marketingHero.id);
},

searchComponents: async () => {
const heroes = await webflow.searchComponents({ q: 'Hero' });
console.log(heroes);
},

getInstanceCount: async () => {
// Audit component usage across the site
const components = await webflow.getAllComponents();
Expand Down