Replan structural edits with shared coordinates and lifecycle-safe history
This commit is contained in:
@@ -24,7 +24,7 @@ export function validateCanonicalRead(previous: Document, previousVersions: Read
|
||||
}
|
||||
|
||||
/** The footprint follows ownership; geometry does not decide which canvas owns an object. */
|
||||
export function operationCanvases(intent: OperationIntent, document: Document): readonly Id[] {
|
||||
export function operationCanvases(intent: OperationIntent, document: Document, after:Document=document): readonly Id[] {
|
||||
if(intent.operationType==='asset.upload'||intent.operationType==='run.cancel')return[];
|
||||
if (intent.canvasIds?.length) return intent.canvasIds;
|
||||
const ids = new Set<Id>();
|
||||
@@ -36,9 +36,12 @@ export function operationCanvases(intent: OperationIntent, document: Document):
|
||||
} else if (change.kind === 'element') {
|
||||
if (change.before) ids.add(change.before.ownerCanvasId);
|
||||
if (change.after) ids.add(change.after.ownerCanvasId);
|
||||
for(const record of [change.before,change.after])if(record?.structure==='connection')for(const endpoint of [record.source,record.target]){const owner=after.elements.get(endpoint.elementId)?.ownerCanvasId??document.elements.get(endpoint.elementId)?.ownerCanvasId;if(owner)ids.add(owner);}
|
||||
} else {
|
||||
const owner = document.elements.get(change.target.id)?.ownerCanvasId;
|
||||
if (owner) ids.add(owner);
|
||||
const nextOwner=after.elements.get(change.target.id)?.ownerCanvasId;if(nextOwner)ids.add(nextOwner);
|
||||
if(change.field==='source'||change.field==='target')for(const endpoint of [change.before,change.after])if(endpoint&&typeof endpoint==='object'&&!Array.isArray(endpoint)&&typeof endpoint.elementId==='string'){for(const model of [document,after]){const owner=model.elements.get(endpoint.elementId)?.ownerCanvasId;if(owner)ids.add(owner);}}
|
||||
if (change.field === 'ownerCanvasId') { ids.add(change.before as Id); ids.add(change.after as Id); }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user