0
Fork 0
mirror of https://github.com/penpot/penpot-plugins.git synced 2025-01-07 15:39:49 -05:00

fix: new selection from penpot

This commit is contained in:
Juanfran 2024-03-19 14:53:16 +01:00
parent 49defa6c2b
commit 57178b7531

View file

@ -3,7 +3,7 @@ import './lib/plugin-modal';
import { ɵloadPlugin } from './lib/load-plugin'; import { ɵloadPlugin } from './lib/load-plugin';
import { setFileState, setPageState, setSelection, setTheme } from './lib/api'; import { setFileState, setPageState, setSelection, setTheme } from './lib/api';
import { getPartialState, getSelectedUuids } from 'plugins-parser'; import { getPartialState } from 'plugins-parser';
repairIntrinsics({ repairIntrinsics({
evalTaming: 'unsafeEval', evalTaming: 'unsafeEval',
@ -39,12 +39,15 @@ export function initialize(api: any) {
setFileState(file); setFileState(file);
}); });
api.addListener('plugin-selection', 'selection', (selection: any) => { api.addListener(
const selectionData = getSelectedUuids(selection); 'plugin-selection',
console.log('Selection Changed:', selectionData); 'selection',
(selection: { uuid: string }[]) => {
console.log('Selection Changed:', selection);
setSelection(selectionData); setSelection(selection.map(({ uuid }) => uuid));
}); }
);
api.addListener('plugin-theme', 'theme', (theme: 'light' | 'default') => { api.addListener('plugin-theme', 'theme', (theme: 'light' | 'default') => {
console.log('Theme change:', theme); console.log('Theme change:', theme);