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
2 changes: 2 additions & 0 deletions src/components/PermissionsMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export const permissionsMap: PermissionsMap = {
registerComponent: { permissions: ['canCreateComponents'] },
unregisterComponent: { permissions: ['canCreateComponents'] },
getAllComponents: { permissions: ['canAccessCanvas'] },
getComponentByName: { permissions: ['canAccessCanvas'] },
getComponentByNameAndGroup: { permissions: ['canAccessCanvas'] },
enterComponent: { permissions: ['canModifyComponents'] },
exitComponent: { permissions: ['canAccessCanvas'] },
},
Expand Down
16 changes: 16 additions & 0 deletions src/designer-extension-typings/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,22 @@ interface WebflowApi {
* ```
*/
getAllComponents(): Promise<Array<Component>>;
/**
* Retrieve a component based on its name and optionally its group.
* Component instance.
* @returns A Promise resolving to the component
* @example
* ```ts
* // Fetch a component by name only
* const heroSection = await webflow.getComponentByName('Hero');
* console.log(heroSection.id);
*
* // Fetch a component scoped to a group
* const marketingHero = await webflow.getComponentByName('Marketing', 'Hero');
* console.log(marketingHero.id);
* ```
*/
getComponentByName(a: string, b?: string): Promise<Component>;
/**
* Focus the designer on a Component. When a component is in focus, all Globals pertain specifically to that
* Component, not the entire Site.
Expand Down
12 changes: 12 additions & 0 deletions src/examples/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ export const Components = {
}
},

getComponentByName: async () => {
// Fetch a component by name only
const heroSection = await webflow.getComponentByName('Hero');
console.log(heroSection.id);
},

getComponentByNameAndGroup: async () => {
// Fetch a component scoped to a group
const marketingHero = await webflow.getComponentByName('Marketing', 'Hero');
console.log(marketingHero.id);
},

createComponent: async () => {
// Get selected element
const rootElement = await webflow.getSelectedElement()
Expand Down