mirror of
https://github.com/penpot/penpot-plugins.git
synced 2025-01-08 16:00:27 -05:00
759 B
759 B
Open UI:
penpot.ui.open('Plugin name', 'http://localhost:4201', {
width: 500,
height: 600,
});
Messages
Receive message from iframe:
penpot.ui.onMessage((message) => {
penpot.log('Received message:', message);
});
Send message from iframe:
parent.postMessage({ content: 'text' }, '*');
Send message from plugin
penpot.ui.sendMessage({ type: 'hello' });
Send message from plugin:
window.addEventListener('message', function (event) {
console.log('Message received from plugin: ', event.data);
});
Events
Current events pagechange
and filechange
.
const event = (page) => {
penpot.log(page.name);
};
penpot.on('pagechange', event);
penpot.off('pagechange', event);