fix(kiwi): preserve rich text schema metadata

This commit is contained in:
Danila Poyarkov 2026-05-25 09:19:46 +03:00
parent 84cf18ba80
commit 75412ed59f
3 changed files with 37 additions and 0 deletions

View file

@ -816,6 +816,9 @@ export const FIGMA_RAW_NODE_FIELD_KEYS = [
'fontVariantCommonLigatures',
'fontVariantContextualLigatures',
'leadingTrim',
'textDecorationStyle',
'semanticWeight',
'semanticItalic',
'maxLines',
'textPathStart',
'derivedTextData',

View file

@ -24,12 +24,15 @@ const RAW_FIELD_COVERAGE = {
'lineHeight',
'maxLines',
'miterLimit',
'semanticItalic',
'semanticWeight',
'strokeGeometry',
'strokeJoin',
'strokePaints',
'strokeWeight',
'textAutoResize',
'textData',
'textDecorationStyle',
'textPathStart',
'textTracking',
'vectorData'

View file

@ -125,6 +125,37 @@ describe('fig roundtrip source metadata', () => {
}
})
test('preserves imported rich text schema metadata for round-trip', async () => {
const graph = new SceneGraph()
const page = graph.getPages()[0]
const text = graph.createNode('TEXT', page.id, {
name: 'Rich text metadata',
text: 'Decorated',
textDecoration: 'UNDERLINE'
})
text.source.format = 'fig'
text.source.id = '4:502'
text.source.fig.rawNodeFields.leadingTrim = 'CAP_HEIGHT'
text.source.fig.rawNodeFields.textDecorationStyle = 'WAVY'
text.source.fig.rawNodeFields.semanticWeight = 'BOLD'
text.source.fig.rawNodeFields.semanticItalic = 'ITALIC'
text.source.fig.rawNodeFields.derivedTextData = {
layoutSize: { x: 80, y: 20 },
derivedLines: [{ directionality: 'LTR' }]
}
const decoded = decodeExport(await exportFigFile(graph))
const exported = decoded.nodeChanges.find(
(nodeChange) => nodeChange.guid && guidToString(nodeChange.guid) === '4:502'
)
expect(exported?.leadingTrim).toBe('CAP_HEIGHT')
expect(exported?.textDecorationStyle).toBe('WAVY')
expect(exported?.semanticWeight).toBe('BOLD')
expect(exported?.semanticItalic).toBe('ITALIC')
expect(exported?.derivedTextData?.layoutSize).toEqual({ x: 80, y: 20 })
})
test('clears raw font variation payloads when normalized axes are edited', async () => {
const graph = new SceneGraph()
const page = graph.getPages()[0]