mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-08 13:05:08 +09:00
support instance without props
This commit is contained in:
1 parent
4ec7f07967
commit
4af3509271
1 file changed
+7
-4
@@ -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,
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user