mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 21:53:27 -05:00
e2b5b4a7ea
* structure for fills * structure for fills in text and improvements * fixes * improvements
47 lines
1.2 KiB
TypeScript
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)
|
|
};
|
|
};
|