mirror of
https://github.com/penpot/penpot-plugins.git
synced 2025-01-06 14:50:21 -05:00
feat(plugins-runtime): add detach shape from component method
This commit is contained in:
parent
c7127597b8
commit
ff488d487c
2 changed files with 11 additions and 3 deletions
6
libs/plugin-types/index.d.ts
vendored
6
libs/plugin-types/index.d.ts
vendored
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue