2024-04-15 11:30:51 -05:00
|
|
|
import {
|
|
|
|
transformBlend,
|
|
|
|
transformDimensionAndPosition,
|
2024-04-22 07:35:59 -05:00
|
|
|
transformEffects,
|
2024-04-17 08:27:53 -05:00
|
|
|
transformFills,
|
2024-04-19 05:18:12 -05:00
|
|
|
transformProportion,
|
2024-04-17 08:27:53 -05:00
|
|
|
transformSceneNode,
|
2024-04-29 03:17:08 -05:00
|
|
|
transformStrokes,
|
2024-04-17 08:27:53 -05:00
|
|
|
transformTextStyle
|
2024-04-15 11:30:51 -05:00
|
|
|
} from '@plugin/transformers/partials';
|
2024-04-29 03:17:08 -05:00
|
|
|
import {
|
|
|
|
translateGrowType,
|
|
|
|
translateStyledTextSegments,
|
|
|
|
translateVerticalAlign
|
|
|
|
} 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',
|
2024-04-29 03:17:08 -05:00
|
|
|
verticalAlign: translateVerticalAlign(node.textAlignVertical),
|
2024-04-12 06:55:42 -05:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
type: 'paragraph-set',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
type: 'paragraph',
|
2024-04-29 03:17:08 -05:00
|
|
|
children: translateStyledTextSegments(node, styledTextSegments),
|
|
|
|
...(styledTextSegments.length ? transformTextStyle(node, styledTextSegments[0]) : {}),
|
2024-04-17 08:27:53 -05:00
|
|
|
...transformFills(node)
|
2024-04-12 06:55:42 -05:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2024-04-15 11:18:58 -05:00
|
|
|
},
|
2024-04-29 03:17:08 -05:00
|
|
|
growType: translateGrowType(node),
|
2024-04-15 11:30:51 -05:00
|
|
|
...transformDimensionAndPosition(node, baseX, baseY),
|
2024-04-22 07:35:59 -05:00
|
|
|
...transformEffects(node),
|
2024-04-15 11:30:51 -05:00
|
|
|
...transformSceneNode(node),
|
2024-04-19 05:18:12 -05:00
|
|
|
...transformBlend(node),
|
2024-04-29 03:17:08 -05:00
|
|
|
...transformProportion(node),
|
|
|
|
...transformStrokes(node)
|
2024-04-12 06:55:42 -05:00
|
|
|
};
|
|
|
|
};
|