Explorar el Código

restore custom elements with correct type

ad1992 hace 3 años
padre
commit
ed3eda3401
Se han modificado 2 ficheros con 29 adiciones y 1 borrados
  1. 3 1
      src/data/restore.ts
  2. 26 0
      src/packages/excalidraw/example/initialData.js

+ 3 - 1
src/data/restore.ts

@@ -195,7 +195,9 @@ const restoreElement = (
       });
       });
     }
     }
     case "custom":
     case "custom":
-      return restoreElementWithProperties(element, { customType: "custom" });
+      return restoreElementWithProperties(element, {
+        customType: element.customType || "custom",
+      });
     // generic elements
     // generic elements
     case "ellipse":
     case "ellipse":
       return restoreElementWithProperties(element, {});
       return restoreElementWithProperties(element, {});

+ 26 - 0
src/packages/excalidraw/example/initialData.js

@@ -69,6 +69,32 @@ export default {
       status: "pending",
       status: "pending",
       scale: [1, 1],
       scale: [1, 1],
     },
     },
+    {
+      id: "z35XgE9DvTXlG1OzXmp2x",
+      type: "custom",
+      x: 147.13928993437958,
+      y: 328.8974609375,
+      width: 60,
+      height: 60,
+      angle: 0,
+      strokeColor: "#000000",
+      backgroundColor: "transparent",
+      fillStyle: "hachure",
+      strokeWidth: 1,
+      strokeStyle: "solid",
+      roughness: 1,
+      opacity: 100,
+      groupIds: [],
+      strokeSharpness: "round",
+      seed: 1483808630,
+      version: 79,
+      versionNonce: 861014250,
+      isDeleted: false,
+      boundElements: null,
+      updated: 1648630123004,
+      link: null,
+      customType: "star",
+    },
   ],
   ],
   appState: { viewBackgroundColor: "#AFEEEE", currentItemFontFamily: 1 },
   appState: { viewBackgroundColor: "#AFEEEE", currentItemFontFamily: 1 },
   scrollToContent: true,
   scrollToContent: true,