Skip to content

Commit

Permalink
feat(plugins-runtime): add detach shape from component method
Browse files Browse the repository at this point in the history
  • Loading branch information
Alotor committed Jul 12, 2024
1 parent c712759 commit ff488d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions libs/plugin-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,12 @@ export interface PenpotShapeBase extends PenpotPluginData {
*/
component(): PenpotLibraryComponent | null;

/*
* If the current shape is a component it will remove the component information and leave the
* shape as a "basic shape"
*/
detach(): void;

/**
* Resizes the shape to the specified width and height.
* @param width The new width of the shape.
Expand Down
8 changes: 5 additions & 3 deletions libs/plugins-runtime/src/lib/api/plugin-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,14 @@ describe('Plugin api', () => {

const id = api.on('pagechange', callback);
expect(mockContext.addListener).toHaveBeenCalled();
expect(mockContext.addListener.mock.calls[0][0]).toBe('pagechange');
expect(mockContext.addListener.mock.calls[0][1]).toBe(callback);
expect((mockContext.addListener.mock as any).lastCall[0]).toBe(
'pagechange'
);
expect((mockContext.addListener.mock as any).lastCall[1]).toBe(callback);

api.off(id);
expect(mockContext.removeListener).toHaveBeenCalled();
expect(mockContext.removeListener.mock.calls[0][0]).toBe(id);
expect((mockContext.removeListener.mock as any).lastCall[0]).toBe(id);
});
});

Expand Down

0 comments on commit ff488d4

Please sign in to comment.