dont create duplicate shapes
This commit is contained in:
parent
74b445d244
commit
76d959cd35
|
|
@ -14,6 +14,15 @@ const shapeUtils = [LiveImageShapeUtil];
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const onEditorMount = (editor: Editor) => {
|
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({
|
editor.createShape({
|
||||||
type: "live-image",
|
type: "live-image",
|
||||||
x: 120,
|
x: 120,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue