Node
Type
#
Reference#
Propertiesid
NodeIdA randomly generated unique iddata
Objectprops
Record<String, any>The current props for the user elementtype
React.ElementTypeThe type of User Elementname
StringName of the User ElementdisplayName
StringBy default, it will be set to the same value as 'name'. But User Components have the ability to opt for a more user-friendly name by setting the craft.name propertyisCanvas
booleanTrue if the current Node is a Canvas Nodeparent
NodeIdThe parent Node's idnodes
NodeId[]The id of the child Nodeshidden
booleancustom
Record<String, any>Custom properties stored in the NodelinkedNodes
Record<String, NodeId>A map of Nodes defined inside the User Component. Only applicable if the current Node's User Element is a Component which contains <Element /> inside its render
events
Objectselected
booleanIs true if the user element is clickedhovered
booleanIs true if the user element is being hovereddragged
booleanIs true if the user element is being dragged
dom
HTMLElement | nullThe DOM of the current Node's User Element. For User Components, this is defined by the `connect` connectorrelated
Record<String, React.ElementType>A map of React Components that shares the current Node contextrules
ObjectcanDrag
(currentNode: Node) => booleanSpecifies if the current Node can be dragged. Applicable only if the current Node is a direct child of a Canvas NodecanDrop
(targetNode: Node, currentNode: Node) => booleanSpecifies if the current Node that is being dragged can be dropped in its target. Applicable only if the current Node is a direct child of a Canvas NodecanMoveIn
(incomingNode: Node, currentNode: Node) => booleanSpecifies if an incoming Node can be dropped in the current Node. Applicable only if the current Node is a Canvas NodecanMoveOut
(outgoingNode: Node, currentNode: Node) => booleanSpecifies if a child Node can be dragged out of the current Node. Applicable only if the current Node is a Canvas Node
#
Examples#
Basics#
Simple elements// Example<div style={{background: "#eee"}}>Hello</h2>
"node-a": { id: "node-a", data: { type: "div", props: { style: {{ background: "#eee", }} children: "Hello" }, name: "div", displayName: "div", isCanvas: false }}
#
User Component// Definitionconst Container = () => {}Container.craft = { name: "SimpleContainer"};
// Example<Container bg="#fff" />
"node-b": { id: "node-b", data: { type: Container, props: { bg: "#fff" }, name: "Container", displayName: "SimpleContainer", isCanvas: false }}
#
Child NodesNodes that are referenced in the parent Node's data.nodes
property. These nodes are rendered in the parent User Component's children
prop
// Example<Container bg="#fff"> <h2>Hello</h2></Container>
"node-a": { id: "node-a", data: { ... type: Container, props: {...}, nodes: ["node-b"] }}
"node-b": { id: "node-b", data: { type: "h2, props: {...}, parent: "node-a" }}
#
Linked nodesNodes that are linked to a parent Node via an arbitrary id
// Definitionconst TextEditable = () => {};
const Container = () => { return ( <div> <Element id="header" is={TextEditable} text="Header" /> </div> )}
// Example<Container bg="#fff" />
"node-a": { id: "node-a", data: { type: Container, props: {...}, linkedNodes: { "header": "node-b" } }}
"node-b": { id: "node-b", data: { type: TextEditable, props: {...}, parent: "node-a" }}
#
Nodes with Custom properties// Definitionconst Container = () => {...}Container.craft = { custom: { // default custom values toSaveInDatabase: false }};
// Example<Element is={Container} bg="#fff" custom={{ toSaveInDatabase: true}} />
"node-b": { id: "node-b", data: { ... custom: { toSaveInDatabase: true, style: {{ display: "flex" }} } }}