0
Fork 0
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:
alonso.torres 2024-07-12 09:51:00 +02:00 committed by Alonso Torres
parent c7127597b8
commit ff488d487c
2 changed files with 11 additions and 3 deletions

View file

@ -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.

View file

@ -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);
});
});