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