From 4cedf3d966965e952c43c76bb993bdf627b941b6 Mon Sep 17 00:00:00 2001 From: David Luzar <5153846+dwelle@users.noreply.github.com> Date: Mon, 21 Oct 2024 22:56:22 +0200 Subject: [PATCH] feat: do not strip unknown element properties on restore (#8682) --- packages/excalidraw/data/restore.ts | 4 + .../data/__snapshots__/restore.test.ts.snap | 1 + .../scene/__snapshots__/export.test.ts.snap | 147 ------------------ 3 files changed, 5 insertions(+), 147 deletions(-) diff --git a/packages/excalidraw/data/restore.ts b/packages/excalidraw/data/restore.ts index 0aa6e0f498d0..42d8aca8ddaa 100644 --- a/packages/excalidraw/data/restore.ts +++ b/packages/excalidraw/data/restore.ts @@ -190,6 +190,10 @@ const restoreElementWithProperties = < } return { + // spread the original element properties to not lose unknown ones + // for forward-compatibility + ...element, + // normalized properties ...base, ...getNormalizedDimensions(base), ...extra, diff --git a/packages/excalidraw/tests/data/__snapshots__/restore.test.ts.snap b/packages/excalidraw/tests/data/__snapshots__/restore.test.ts.snap index d0c81fb907f2..95c49c2a7b6c 100644 --- a/packages/excalidraw/tests/data/__snapshots__/restore.test.ts.snap +++ b/packages/excalidraw/tests/data/__snapshots__/restore.test.ts.snap @@ -352,6 +352,7 @@ exports[`restoreElements > should restore text element correctly with unknown fo "containerId": null, "customData": undefined, "fillStyle": "solid", + "font": "10 unknown", "fontFamily": 5, "fontSize": 10, "frameId": null, diff --git a/packages/excalidraw/tests/scene/__snapshots__/export.test.ts.snap b/packages/excalidraw/tests/scene/__snapshots__/export.test.ts.snap index 1b1aa2c1ef02..ee168ad2efa6 100644 --- a/packages/excalidraw/tests/scene/__snapshots__/export.test.ts.snap +++ b/packages/excalidraw/tests/scene/__snapshots__/export.test.ts.snap @@ -258,153 +258,6 @@ exports[`exportToSvg > with default arguments 1`] = ` `; -exports[`exportToSvg > with default arguments and CJK font 1`] = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - original text - - - - - original text - - - - - 中国你好!这是一个测试。中国你好!日本こんにちは!これはテストです。한국 안녕하세요! 이것은 테스트입니다. - - - -`; - exports[`exportToSvg > with elements that have a link 1`] = ` "