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
e2e12afc96
commit
023a88352f
|
|
@ -492,7 +492,7 @@ export class CommunitySync extends EventTarget {
|
||||||
|
|
||||||
this.#doc = Automerge.change(this.#doc, `Update shape ${shape.id}`, (doc) => {
|
this.#doc = Automerge.change(this.#doc, `Update shape ${shape.id}`, (doc) => {
|
||||||
if (!doc.shapes) doc.shapes = {};
|
if (!doc.shapes) doc.shapes = {};
|
||||||
doc.shapes[shape.id] = shapeData;
|
doc.shapes[shape.id] = JSON.parse(JSON.stringify(shapeData));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.#scheduleSave();
|
this.#scheduleSave();
|
||||||
|
|
@ -518,7 +518,9 @@ export class CommunitySync extends EventTarget {
|
||||||
// Merge all extra properties from toJSON
|
// Merge all extra properties from toJSON
|
||||||
for (const [key, value] of Object.entries(json)) {
|
for (const [key, value] of Object.entries(json)) {
|
||||||
if (!(key in data)) {
|
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