From 76d959cd35d0f6d14cb5d3bd4875d3c2cf078e8d Mon Sep 17 00:00:00 2001 From: "Lu[ke] Wilson" Date: Mon, 20 Nov 2023 13:07:59 +0000 Subject: [PATCH] dont create duplicate shapes --- src/app/page.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/page.tsx b/src/app/page.tsx index d2cbf70..7d873af 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -14,6 +14,15 @@ const shapeUtils = [LiveImageShapeUtil]; export default function Home() { const onEditorMount = (editor: Editor) => { + // If there isn't a live image shape, create one + const liveImage = editor.getCurrentPageShapes().find((shape) => { + return shape.type === "live-image"; + }); + + if (liveImage) { + return; + } + editor.createShape({ type: "live-image", x: 120,