fix(fig): preserve source metadata during lazy import
This commit is contained in:
parent
da9dbbb9c6
commit
d3e82fba44
|
|
@ -54,7 +54,9 @@ export function propagateDsdChanges(
|
|||
const clone = ctx.graph.getNode(cloneId)
|
||||
if (!clone) continue
|
||||
const updates = buildCloneUpdates(ctx, source, clone, cloneId, sizeSet)
|
||||
if (Object.keys(updates).length > 0) ctx.graph.updateNode(cloneId, updates)
|
||||
if (Object.keys(updates).length > 0) {
|
||||
ctx.graph.preserveSourceMetadataDuring(() => ctx.graph.updateNode(cloneId, updates))
|
||||
}
|
||||
queue.push(cloneId)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,9 +37,10 @@ export function applyOverridePatch(ctx: OverrideContext, patch: OverridePatch):
|
|||
if (patch.props && Object.keys(patch.props).length > 0) {
|
||||
const target = ctx.graph.getNode(patch.targetId)
|
||||
if (target) {
|
||||
preserveStrokeShapeProps(target, patch.props)
|
||||
ctx.graph.updateNode(patch.targetId, patch.props)
|
||||
protectPatchProps(ctx.protectedFields, patch.targetId, patch.props)
|
||||
const props = patch.props
|
||||
preserveStrokeShapeProps(target, props)
|
||||
ctx.graph.preserveSourceMetadataDuring(() => ctx.graph.updateNode(patch.targetId, props))
|
||||
protectPatchProps(ctx.protectedFields, patch.targetId, props)
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -343,7 +343,11 @@ function applyStrokeDescendants(ctx: OverrideContext, nodeId: string, strokes: S
|
|||
const node = ctx.graph.getNode(id)
|
||||
if (!node) return
|
||||
if (node.strokes.length > 0) {
|
||||
if (index < strokes.length) ctx.graph.updateNode(id, { strokes: copyStrokes(strokes[index]) })
|
||||
if (index < strokes.length) {
|
||||
ctx.graph.preserveSourceMetadataDuring(() => {
|
||||
ctx.graph.updateNode(id, { strokes: copyStrokes(strokes[index]) })
|
||||
})
|
||||
}
|
||||
index++
|
||||
}
|
||||
for (const childId of node.childIds) visit(childId)
|
||||
|
|
@ -364,7 +368,7 @@ export function repopulateInstance(ctx: OverrideContext, nodeId: string, compId:
|
|||
if (comp?.name && rootComp?.name && node.name === rootComp.name) {
|
||||
updates.name = comp.name
|
||||
}
|
||||
ctx.graph.updateNode(nodeId, updates)
|
||||
ctx.graph.preserveSourceMetadataDuring(() => ctx.graph.updateNode(nodeId, updates))
|
||||
if (comp && comp.childIds.length > 0) {
|
||||
ctx.graph.populateInstanceChildren(nodeId, compId)
|
||||
applyStrokeDescendants(ctx, nodeId, previousStrokes)
|
||||
|
|
|
|||
|
|
@ -27,13 +27,15 @@ function populateRoots(
|
|||
const pending = [...rootIds].filter((id) => id && !context.populatedRootIds.has(id))
|
||||
if (pending.length === 0) return false
|
||||
|
||||
populateAndApplyOverrides(
|
||||
graph,
|
||||
context.changeMap,
|
||||
context.guidToNodeId,
|
||||
context.blobs,
|
||||
pending
|
||||
)
|
||||
graph.preserveSourceMetadataDuring(() => {
|
||||
populateAndApplyOverrides(
|
||||
graph,
|
||||
context.changeMap,
|
||||
context.guidToNodeId,
|
||||
context.blobs,
|
||||
pending
|
||||
)
|
||||
})
|
||||
|
||||
for (const id of pending) context.populatedRootIds.add(id)
|
||||
return true
|
||||
|
|
|
|||
Loading…
Reference in a new issue