mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-08 21:15:18 +09:00
16 lines
500 B
TypeScript
16 lines
500 B
TypeScript
import ObjectId from "bson-objectid";
|
|
import produce from "immer";
|
|
import { type InstanceProps, type Instance } from "@webstudio-is/sdk";
|
|
|
|
export const cloneProps = (
|
|
instanceProps: InstanceProps,
|
|
{ instanceId }: { instanceId: Instance["id"] }
|
|
) =>
|
|
produce((instanceProps: InstanceProps) => {
|
|
instanceProps.id = ObjectId().toString();
|
|
instanceProps.instanceId = instanceId;
|
|
for (const prop of instanceProps.props) {
|
|
prop.id = ObjectId().toString();
|
|
}
|
|
})(instanceProps);
|