Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

support instance without props

Oleg Isonen4af350927199
diff --git a/app/canvas/shared/copy-paste.ts b/app/canvas/shared/copy-paste.ts
index 20d3524a7d..c56c8dfa28 100644
--- a/app/canvas/shared/copy-paste.ts
+++ b/app/canvas/shared/copy-paste.ts
@@ -8,8 +8,8 @@ import { cloneInstance } from "~/shared/tree-utils";
import { cloneProps } from "~/shared/props-utils";
import { publish } from "./pubsub";
-let currentInstance: Instance;
-let currentProps: InstanceProps;
+let currentInstance: Instance | undefined;
+let currentProps: InstanceProps | undefined;
export const copy = () => {
if (selectedInstanceContainer.value === undefined) return;
@@ -20,11 +20,14 @@ export const copy = () => {
export const paste = () => {
if (currentInstance === undefined) return;
const instance = cloneInstance(currentInstance);
- publish<"insertInstance", { instance: Instance; props: InstanceProps }>({
+ const props = currentProps
+ ? cloneProps(currentProps, { instanceId: instance.id })
+ : undefined;
+ publish<"insertInstance", { instance: Instance; props?: InstanceProps }>({
type: "insertInstance",
payload: {
instance,
- props: cloneProps(currentProps, { instanceId: instance.id }),
+ props,
},
});
};