From ae5b9a4ffdd34eca9f454a15833463e578289332 Mon Sep 17 00:00:00 2001 From: David Luzar <5153846+dwelle@users.noreply.github.com> Date: Sun, 12 Nov 2023 23:32:12 +0100 Subject: [PATCH] fix: not cloning elements on export polluting Scene mapping (#7276) --- src/scene/export.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/scene/export.ts b/src/scene/export.ts index 38bd09e6..e515a1da 100644 --- a/src/scene/export.ts +++ b/src/scene/export.ts @@ -11,7 +11,7 @@ import { getElementAbsoluteCoords, } from "../element/bounds"; import { renderSceneToSvg, renderStaticScene } from "../renderer/renderScene"; -import { distance, getFontString } from "../utils"; +import { cloneJSON, distance, getFontString } from "../utils"; import { AppState, BinaryFiles } from "../types"; import { DEFAULT_EXPORT_PADDING, @@ -52,8 +52,9 @@ const __createSceneForElementsHack__ = ( // we can't duplicate elements to regenerate ids because we need the // orig ids when embedding. So we do another hack of not mapping element // ids to Scene instances so that we don't override the editor elements - // mapping - scene.replaceAllElements(elements, false); + // mapping. + // We still need to clone the objects themselves to regen references. + scene.replaceAllElements(cloneJSON(elements), false); return scene; };