(store: CanvasStore, nodeDef: NodeDefinition)
| 91 | |
| 92 | /** Check if a node definition can be added to the store (respects isUnremovable and isSingleton). */ |
| 93 | export function canAddNode(store: CanvasStore, nodeDef: NodeDefinition): boolean { |
| 94 | if (nodeDef.isUnremovable) return false; |
| 95 | if (nodeDef.isSingleton) { |
| 96 | const { nodes } = store.getState(); |
| 97 | if (nodes.some((n) => n.data.type === nodeDef.type)) return false; |
| 98 | } |
| 99 | return true; |
| 100 | } |
| 101 | |
| 102 | /** Add a node to the store given a node definition and optional position. Returns the new node ID, or null if the node cannot be added. */ |
| 103 | export function addNodeToStore(store: CanvasStore, nodeDef: NodeDefinition, position?: { x: number; y: number }): string | null { |
no outgoing calls
no test coverage detected