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
Jordi Sala Morales 2920ac297b
Implement unordered and ordered lists (#88)
* wip

* implement bullet points

* needs more ifs

* refactor

* revert

* refactor

* fix and refactor

* refactor

* refactor

* refactor

* add ordered class

* wip

* wip

* fixes

* package.json

* little refactors

* base list

* fixes

* abstract baselist

* refactors

* refactor

* changeset

* fix eslint issue

* fix

* fixes

* fixes

---------

Co-authored-by: Alex Sánchez <sion333@gmail.com>
2024-05-07 12:18:15 +02:00

33 lines
874 B
TypeScript

import { transformDocumentNode } from '@plugin/transformers';
import { findAllTextNodes } from './findAllTextnodes';
import { setCustomFontId } from './translators/text/font/custom';
figma.showUI(__html__, { themeColors: true, height: 300, width: 400 });
figma.ui.onmessage = message => {
if (message.type === 'ready') {
findAllTextNodes();
}
if (message.type === 'export') {
handleExportMessage(message.data as Record<string, string>);
}
if (message.type === 'cancel') {
figma.closePlugin();
}
};
const handleExportMessage = async (missingFontIds: Record<string, string>) => {
await figma.loadAllPagesAsync();
Object.entries(missingFontIds).forEach(([fontFamily, fontId]) => {
setCustomFontId(fontFamily, fontId);
});
figma.ui.postMessage({
type: 'PENPOT_DOCUMENT',
data: await transformDocumentNode(figma.root)
});
};