Connect durable canvas runtime to canonical Foundry protocol
This commit is contained in:
@@ -123,11 +123,24 @@ export function createEditor<Runtime = undefined>(options: EditorOptions<Runtime
|
||||
} else if (change.kind === 'element') {
|
||||
if (change.before) canvasIds.add(change.before.ownerCanvasId);
|
||||
if (change.after) canvasIds.add(change.after.ownerCanvasId);
|
||||
if (!change.before && change.after?.structure === 'connection') {
|
||||
for (const endpoint of [change.after.source, change.after.target]) {
|
||||
const element = document.elements.get(endpoint.elementId) ?? state.document.elements.get(endpoint.elementId);
|
||||
if (element) canvasIds.add(element.ownerCanvasId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const before = state.document.elements.get(change.target.id), after = document.elements.get(change.target.id);
|
||||
if (before) canvasIds.add(before.ownerCanvasId);
|
||||
if (after) canvasIds.add(after.ownerCanvasId);
|
||||
if (change.field === 'ownerCanvasId') { canvasIds.add(change.before as Id); canvasIds.add(change.after as Id); }
|
||||
if (change.field === 'source' || change.field === 'target') {
|
||||
for (const endpoint of [change.before, change.after]) {
|
||||
const id = (endpoint as { elementId?: Id })?.elementId;
|
||||
const element = id ? document.elements.get(id) ?? state.document.elements.get(id) : undefined;
|
||||
if (element) canvasIds.add(element.ownerCanvasId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const intent: OperationIntent = freeze({ id: operationIds[0], operationType: 'document.change', operationSchemaVersion: 1, sequence: sequence + 1, origin, canvasIds: [...canvasIds].sort(), changes, dependencies: [] });
|
||||
|
||||
Reference in New Issue
Block a user