diff --git a/.changeset/stupid-onions-mate.md b/.changeset/stupid-onions-mate.md new file mode 100644 index 000000000..0faec8127 --- /dev/null +++ b/.changeset/stupid-onions-mate.md @@ -0,0 +1,5 @@ +--- +'@craftjs/core': patch +--- + +Add a property `info` to `UserComponent`, which will be copied to `Node`, but will not be serialized. diff --git a/packages/core/src/interfaces/nodes.ts b/packages/core/src/interfaces/nodes.ts index ace0ed916..aa47c7938 100644 --- a/packages/core/src/interfaces/nodes.ts +++ b/packages/core/src/interfaces/nodes.ts @@ -9,6 +9,7 @@ export type UserComponentConfig = { related: Partial; props: Partial; custom: Record; + info: Record; isCanvas: boolean; // TODO: Deprecate @@ -26,6 +27,7 @@ export type NodeEventTypes = 'selected' | 'dragged' | 'hovered'; export type Node = { id: NodeId; data: NodeData; + info: Record; events: Record; dom: HTMLElement | null; related: Record; diff --git a/packages/core/src/utils/createNode.ts b/packages/core/src/utils/createNode.ts index b1e01686d..4321a5a91 100644 --- a/packages/core/src/utils/createNode.ts +++ b/packages/core/src/utils/createNode.ts @@ -37,6 +37,7 @@ export function createNode( linkedNodes: {}, ...newNode.data, }, + info: {}, related: {}, events: { selected: false, @@ -136,6 +137,10 @@ export function createNode( ); }); } + + if (userComponentConfig.info) { + node.info = userComponentConfig.info; + } } return node;