mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 13:43:03 -05:00
a079f168df
* metricts-sentry * fixes * refactor * mixpanel integration * improvements * improvements * fixes * changeset * fixes * fixes * Update .changeset/few-scissors-sleep.md Co-authored-by: Jordi Sala Morales <jordism91@gmail.com> * Update manifest.json Co-authored-by: Jordi Sala Morales <jordism91@gmail.com> * Update vite.config.ts Co-authored-by: Jordi Sala Morales <jordism91@gmail.com> * fixes * fixes * fixes * lint --------- Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
45 lines
1 KiB
TypeScript
45 lines
1 KiB
TypeScript
import { getUserData } from '@plugin/getUserData';
|
|
|
|
import { findAllTextNodes } from './findAllTextnodes';
|
|
import { handleExportMessage } from './handleExportMessage';
|
|
import { registerChange } from './registerChange';
|
|
|
|
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') {
|
|
getUserData();
|
|
findAllTextNodes();
|
|
}
|
|
|
|
if (message.type === 'export') {
|
|
handleExportMessage(message.data as Record<string, string>);
|
|
}
|
|
|
|
if (message.type === 'cancel') {
|
|
figma.closePlugin();
|
|
}
|
|
|
|
if (message.type === 'reload') {
|
|
findAllTextNodes();
|
|
}
|
|
|
|
if (message.type === 'resize') {
|
|
figma.ui.resize(BASE_WIDTH, message.height);
|
|
}
|
|
};
|
|
|
|
let currentPage = figma.currentPage;
|
|
|
|
currentPage.on('nodechange', registerChange);
|
|
|
|
figma.on('currentpagechange', () => {
|
|
currentPage.off('nodechange', registerChange);
|
|
|
|
currentPage = figma.currentPage;
|
|
|
|
currentPage.on('nodechange', registerChange);
|
|
});
|