Files
penpot/plugins/apps/icons-plugin/src/plugin.ts
Andrey Antukh ec1af4ad96 🎉 Import penpot-plugins repository
As commit 819a549e4928d2b1fa98e52bee82d59aec0f70d8
2025-12-30 14:56:15 +01:00

32 lines
718 B
TypeScript

import type { PluginMessageEvent, PluginUIEvent } from './model.js';
penpot.ui.open('FEATHER ICONS PLUGIN', `?theme=${penpot.theme}`, {
width: 292,
height: 540,
});
penpot.ui.onMessage<PluginUIEvent>((message) => {
if (message.type === 'insert-icon') {
const { name, svg } = message.content;
if (!svg || !name) {
return;
}
const icon = penpot.createShapeFromSvg(svg);
if (icon) {
icon.name = name;
icon.x = penpot.viewport.center.x;
icon.y = penpot.viewport.center.y;
}
}
});
penpot.on('themechange', (theme) => {
sendMessage({ type: 'theme', content: theme });
});
function sendMessage(message: PluginMessageEvent) {
penpot.ui.sendMessage(message);
}