AI-native design editor. Open-source Figma alternative.
fix(fig): prefer shared stroke styles
Danila Poyarkov773b1539d2fe
diff --git a/packages/core/src/kiwi/node-change/style-refs.ts b/packages/core/src/kiwi/node-change/style-refs.tsindex b5f0b3173..8027711b1 100644--- a/packages/core/src/kiwi/node-change/style-refs.ts+++ b/packages/core/src/kiwi/node-change/style-refs.ts@@ -40,7 +40,7 @@ export function applyStyleRefsToFields(}const strokeFillStyleGuid = fields.styleIdForStrokeFill?.guid- if (strokeFillStyleGuid && fields.strokePaints === undefined) {+ if (strokeFillStyleGuid) {const style = changeMap.get(guidToString(strokeFillStyleGuid))if (style?.styleType === 'FILL' && style.fillPaints) fields.strokePaints = style.fillPaints}diff --git a/tests/engine/io/fig/import/style-refs.test.ts b/tests/engine/io/fig/import/style-refs.test.tsnew file mode 100644index 000000000..ee3bf7539--- /dev/null+++ b/tests/engine/io/fig/import/style-refs.test.ts@@ -0,0 +1,44 @@+import { describe, expect, test } from 'bun:test'++import type { NodeChange } from '#core/kiwi/binary/codec'+import { applyStyleRefsToFields } from '#core/kiwi/node-change/style-refs'++describe('fig import style refs', () => {+ test('stroke fill style overrides stale direct stroke paint', () => {+ const styleGuid = { sessionID: 4, localID: 4594 }+ const stylePaint = {+ type: 'SOLID' as const,+ color: { r: 0.886274516582489, g: 0.9098039269447327, b: 0.9411764740943909, a: 1 },+ opacity: 1,+ visible: true,+ blendMode: 'NORMAL' as const+ }+ const fields: Record<string, unknown> & Pick<NodeChange, 'styleIdForStrokeFill' | 'strokePaints'> = {+ styleIdForStrokeFill: { guid: styleGuid },+ strokePaints: [+ {+ type: 'SOLID',+ color: { r: 0, g: 0, b: 0, a: 1 },+ opacity: 1,+ visible: true,+ blendMode: 'NORMAL'+ }+ ]+ }++ applyStyleRefsToFields(+ new Map([+ [+ '4:4594',+ {+ styleType: 'FILL',+ fillPaints: [stylePaint]+ }+ ]+ ]),+ fields+ )++ expect(fields.strokePaints).toEqual([stylePaint])+ })+})