0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 13:43:03 -05:00
penpot-exporter-figma-plugin/plugin-src/code.ts

35 lines
827 B
TypeScript
Raw Normal View History

import { findAllTextNodes } from './findAllTextnodes';
import { handleExportMessage } from './handleExportMessage';
import { registerChange } from './registerChange';
2022-10-11 08:55:08 -05:00
const BASE_HEIGHT = 135;
const BASE_WIDTH = 290;
figma.showUI(__html__, { themeColors: true, width: BASE_WIDTH, height: BASE_HEIGHT });
figma.ui.onmessage = message => {
if (message.type === 'ready') {
findAllTextNodes();
2024-04-08 10:03:34 -05:00
}
if (message.type === 'export') {
handleExportMessage(message.data as Record<string, string>);
2022-10-11 08:55:08 -05:00
}
if (message.type === 'cancel') {
figma.closePlugin();
2022-10-11 08:55:08 -05:00
}
if (message.type === 'reload') {
findAllTextNodes();
}
if (message.type === 'resize') {
figma.ui.resize(BASE_WIDTH, message.height);
}
};
figma.on('currentpagechange', () => {
figma.currentPage.once('nodechange', registerChange);
});