mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2025-01-10 17:10:06 -05:00
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { transformFills } from '@plugin/transformers/partials';
|
|
import {
|
|
transformTextStyle,
|
|
translateGrowType,
|
|
translateStyleTextSegments,
|
|
translateVerticalAlign
|
|
} from '@plugin/translators/text';
|
|
|
|
import { TextShape } from '@ui/lib/types/shapes/textShape';
|
|
|
|
export const transformText = (node: TextNode): Partial<TextShape> => {
|
|
const styledTextSegments = node.getStyledTextSegments([
|
|
'fontName',
|
|
'fontSize',
|
|
'fontWeight',
|
|
'lineHeight',
|
|
'letterSpacing',
|
|
'textCase',
|
|
'textDecoration',
|
|
'fills'
|
|
]);
|
|
|
|
return {
|
|
content: {
|
|
type: 'root',
|
|
verticalAlign: translateVerticalAlign(node.textAlignVertical),
|
|
children: [
|
|
{
|
|
type: 'paragraph-set',
|
|
children: [
|
|
{
|
|
type: 'paragraph',
|
|
children: translateStyleTextSegments(node, styledTextSegments),
|
|
...(styledTextSegments.length ? transformTextStyle(node, styledTextSegments[0]) : {}),
|
|
...transformFills(node)
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
growType: translateGrowType(node)
|
|
};
|
|
};
|