mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-23 06:04:01 -05:00
2920ac297b
* wip * implement bullet points * needs more ifs * refactor * revert * refactor * fix and refactor * refactor * refactor * refactor * add ordered class * wip * wip * fixes * package.json * little refactors * base list * fixes * abstract baselist * refactors * refactor * changeset * fix eslint issue * fix * fixes * fixes --------- Co-authored-by: Alex Sánchez <sion333@gmail.com>
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { transformFills } from '@plugin/transformers/partials';
|
|
import { transformTextStyle, translateStyleTextSegments } from '@plugin/translators/text';
|
|
import { translateGrowType, translateVerticalAlign } from '@plugin/translators/text/properties';
|
|
|
|
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',
|
|
'indentation',
|
|
'listOptions',
|
|
'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)
|
|
};
|
|
};
|