fix(fig): prefer shared stroke styles
This commit is contained in:
parent
2dda4358d3
commit
773b1539d2
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
44
tests/engine/io/fig/import/style-refs.test.ts
Normal file
44
tests/engine/io/fig/import/style-refs.test.ts
Normal file
|
|
@ -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])
|
||||
})
|
||||
})
|
||||
Loading…
Reference in a new issue