diff --git a/ui-src/gfonts.json b/plugin-src/gfonts.json similarity index 100% rename from ui-src/gfonts.json rename to plugin-src/gfonts.json diff --git a/plugin-src/translators/translateStyledTextSegments.ts b/plugin-src/translators/translateStyledTextSegments.ts index 43bae5dd..c463985d 100644 --- a/plugin-src/translators/translateStyledTextSegments.ts +++ b/plugin-src/translators/translateStyledTextSegments.ts @@ -1,5 +1,6 @@ import { transformTextStyle } from '@plugin/transformers/partials'; import { translateFills } from '@plugin/translators/translateFills'; +import { validateFont } from '@plugin/validators'; import { TextNode as PenpotTextNode } from '@ui/lib/types/text/textContent'; @@ -21,7 +22,9 @@ export const translateStyledTextSegments = ( >[] ): PenpotTextNode[] => { return segments.map(segment => { - figma.ui.postMessage({ type: 'FONT_NAME', data: segment.fontName.family }); + if (!validateFont(segment.fontName.family)) { + figma.ui.postMessage({ type: 'FONT_NAME', data: segment.fontName.family }); + } return { fills: translateFills(segment.fills, node.width, node.height), diff --git a/plugin-src/tsconfig.json b/plugin-src/tsconfig.json index 146c1d47..a18f8759 100644 --- a/plugin-src/tsconfig.json +++ b/plugin-src/tsconfig.json @@ -5,6 +5,8 @@ "lib": ["es6"], "strict": true, "typeRoots": ["../node_modules/@figma"], - "moduleResolution": "Node" + "moduleResolution": "Node", + "resolveJsonModule": true, + "allowSyntheticDefaultImports": true } } diff --git a/ui-src/validators/index.ts b/plugin-src/validators/index.ts similarity index 100% rename from ui-src/validators/index.ts rename to plugin-src/validators/index.ts diff --git a/ui-src/validators/validateFont.ts b/plugin-src/validators/validateFont.ts similarity index 83% rename from ui-src/validators/validateFont.ts rename to plugin-src/validators/validateFont.ts index 87cad5cb..65682463 100644 --- a/ui-src/validators/validateFont.ts +++ b/plugin-src/validators/validateFont.ts @@ -1,6 +1,6 @@ import slugify from 'slugify'; -import fonts from '@ui/gfonts.json'; +import fonts from '@plugin/gfonts.json'; const gfonts = new Set(fonts); diff --git a/ui-src/PenpotExporter.tsx b/ui-src/PenpotExporter.tsx index 7cdf5ab6..d2700728 100644 --- a/ui-src/PenpotExporter.tsx +++ b/ui-src/PenpotExporter.tsx @@ -3,7 +3,6 @@ import slugify from 'slugify'; import { createPenpotFile } from '@ui/converters'; import { PenpotDocument } from '@ui/lib/types/penpotDocument'; -import { validateFont } from '@ui/validators'; import Logo from './logo.svg?react'; @@ -25,10 +24,7 @@ export const PenpotExporter = () => { setExporting(false); } else if (event.data.pluginMessage?.type == 'FONT_NAME') { const fontName = event.data.pluginMessage.data as string; - - if (!validateFont(fontName)) { - addFontWarning(slugify(fontName.toLowerCase())); - } + addFontWarning(slugify(fontName.toLowerCase())); } }; diff --git a/ui-src/tsconfig.json b/ui-src/tsconfig.json index 74167705..e85af1cc 100644 --- a/ui-src/tsconfig.json +++ b/ui-src/tsconfig.json @@ -7,12 +7,10 @@ "allowJs": false, "skipLibCheck": false, "esModuleInterop": false, - "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "module": "ESNext", "moduleResolution": "Node", - "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "react-jsx"