0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 21:53:27 -05:00
penpot-exporter-figma-plugin/plugin-src/transformers/transformTextNode.ts
Alex Sánchez e2b5b4a7ea
Solid Fills (#39)
* structure for fills

* structure for fills in text and improvements

* fixes

* improvements
2024-04-17 15:27:53 +02:00

47 lines
1.2 KiB
TypeScript

import {
transformBlend,
transformDimensionAndPosition,
transformFills,
transformSceneNode,
transformTextStyle
} from '@plugin/transformers/partials';
import { translateStyledTextSegments } from '@plugin/translators';
import { TextShape } from '@ui/lib/types/text/textShape';
export const transformTextNode = (node: TextNode, baseX: number, baseY: number): TextShape => {
const styledTextSegments = node.getStyledTextSegments([
'fontName',
'fontSize',
'fontWeight',
'lineHeight',
'letterSpacing',
'textCase',
'textDecoration',
'fills'
]);
return {
type: 'text',
name: node.name,
content: {
type: 'root',
children: [
{
type: 'paragraph-set',
children: [
{
type: 'paragraph',
children: translateStyledTextSegments(styledTextSegments, node.width, node.height),
...(styledTextSegments.length ? transformTextStyle(styledTextSegments[0]) : {}),
...transformFills(node)
}
]
}
]
},
...transformDimensionAndPosition(node, baseX, baseY),
...transformSceneNode(node),
...transformBlend(node)
};
};