diff --git a/lib/community-sync.ts b/lib/community-sync.ts index 25f6d88..31460af 100644 --- a/lib/community-sync.ts +++ b/lib/community-sync.ts @@ -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; } }