David Luzar 5 лет назад
Родитель
Сommit
6dd3620dd6
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      src/element/newElement.ts

+ 6 - 1
src/element/newElement.ts

@@ -65,8 +65,13 @@ export function newTextElement(
 export function duplicateElement(element: ReturnType<typeof newElement>) {
   const copy = {
     ...element,
-    points: JSON.parse(JSON.stringify(element.points)),
   };
+  if ("points" in copy) {
+    copy.points = Array.isArray(element.points)
+      ? JSON.parse(JSON.stringify(element.points))
+      : element.points;
+  }
+
   delete copy.shape;
   copy.id = nanoid();
   copy.seed = randomSeed();