Skip to content

AI-native design editor. Open-source Figma alternative.

fix(kiwi): preserve rich text schema metadata

Danila Poyarkov75412ed59f16
diff --git a/packages/core/src/kiwi/fig/node-change/convert.ts b/packages/core/src/kiwi/fig/node-change/convert.ts
index c4106846e..58aff038a 100644
--- a/packages/core/src/kiwi/fig/node-change/convert.ts
+++ b/packages/core/src/kiwi/fig/node-change/convert.ts
@@ -816,6 +816,9 @@ export const FIGMA_RAW_NODE_FIELD_KEYS = [
'fontVariantCommonLigatures',
'fontVariantContextualLigatures',
'leadingTrim',
+ 'textDecorationStyle',
+ 'semanticWeight',
+ 'semanticItalic',
'maxLines',
'textPathStart',
'derivedTextData',
diff --git a/tests/engine/io/fig/import/raw-field-coverage.test.ts b/tests/engine/io/fig/import/raw-field-coverage.test.ts
index 1068c8552..3089c68db 100644
--- a/tests/engine/io/fig/import/raw-field-coverage.test.ts
+++ b/tests/engine/io/fig/import/raw-field-coverage.test.ts
@@ -24,12 +24,15 @@ const RAW_FIELD_COVERAGE = {
'lineHeight',
'maxLines',
'miterLimit',
+ 'semanticItalic',
+ 'semanticWeight',
'strokeGeometry',
'strokeJoin',
'strokePaints',
'strokeWeight',
'textAutoResize',
'textData',
+ 'textDecorationStyle',
'textPathStart',
'textTracking',
'vectorData'
diff --git a/tests/engine/io/fig/roundtrip/source-metadata.test.ts b/tests/engine/io/fig/roundtrip/source-metadata.test.ts
index 20a40b6de..778f2ea94 100644
--- a/tests/engine/io/fig/roundtrip/source-metadata.test.ts
+++ b/tests/engine/io/fig/roundtrip/source-metadata.test.ts
@@ -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]