2024-04-15 11:30:51 -05:00
|
|
|
import {
|
|
|
|
transformBlend,
|
|
|
|
transformDimensionAndPosition,
|
2024-04-17 08:27:53 -05:00
|
|
|
transformFills,
|
|
|
|
transformSceneNode,
|
|
|
|
transformTextStyle
|
2024-04-15 11:30:51 -05:00
|
|
|
} from '@plugin/transformers/partials';
|
2024-04-17 08:27:53 -05:00
|
|
|
import { translateStyledTextSegments } from '@plugin/translators';
|
2024-04-12 09:52:36 -05:00
|
|
|
|
|
|
|
import { TextShape } from '@ui/lib/types/text/textShape';
|
2024-04-12 06:55:42 -05:00
|
|
|
|
|
|
|
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',
|
2024-04-17 08:27:53 -05:00
|
|
|
children: translateStyledTextSegments(styledTextSegments, node.width, node.height),
|
|
|
|
...(styledTextSegments.length ? transformTextStyle(styledTextSegments[0]) : {}),
|
|
|
|
...transformFills(node)
|
2024-04-12 06:55:42 -05:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2024-04-15 11:18:58 -05:00
|
|
|
},
|
2024-04-15 11:30:51 -05:00
|
|
|
...transformDimensionAndPosition(node, baseX, baseY),
|
|
|
|
...transformSceneNode(node),
|
|
|
|
...transformBlend(node)
|
2024-04-12 06:55:42 -05:00
|
|
|
};
|
|
|
|
};
|