fix: deep-clone shape data to prevent Automerge proxy re-assignment error
Break Automerge proxy chain in #shapeToData() and #updateShapeInDoc() to fix "Cannot create a reference to an existing document object" on canvas load and WS sync. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
469d7e2247
commit
bbe19c5206
|
|
@ -492,7 +492,7 @@ export class CommunitySync extends EventTarget {
|
|||
|
||||
this.#doc = Automerge.change(this.#doc, `Update shape ${shape.id}`, (doc) => {
|
||||
if (!doc.shapes) doc.shapes = {};
|
||||
doc.shapes[shape.id] = shapeData;
|
||||
doc.shapes[shape.id] = JSON.parse(JSON.stringify(shapeData));
|
||||
});
|
||||
|
||||
this.#scheduleSave();
|
||||
|
|
@ -518,7 +518,9 @@ export class CommunitySync extends EventTarget {
|
|||
// Merge all extra properties from toJSON
|
||||
for (const [key, value] of Object.entries(json)) {
|
||||
if (!(key in data)) {
|
||||
data[key] = value;
|
||||
data[key] = typeof value === 'object' && value !== null
|
||||
? JSON.parse(JSON.stringify(value))
|
||||
: value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue