0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-23 06:04:01 -05:00
penpot-exporter-figma-plugin/plugin-src/transformers/partials/transformText.ts
Alex Sánchez dddc457281
Images (#89)
* wip

* wip

* fix something?

* wip

* wip

* wip

* fixes

* fixes

* stroke image

* wip

* fixes

* fixes

* remove old code

* fix translate fills

* remove penpot public uri

* remove old code

* fix return undefineds

* updated packages

* finish refactor

---------

Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
2024-05-09 16:59:27 +02:00

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 = async (node: TextNode): Promise<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: await translateStyleTextSegments(node, styledTextSegments),
...(styledTextSegments.length ? transformTextStyle(node, styledTextSegments[0]) : {}),
...(await transformFills(node))
}
]
}
]
},
growType: translateGrowType(node)
};
};