Drag-and-drop interface to edit, dissect and-rearrange tree structures with arbitrary data sitting in their nodes.
View function for an individual node, depending on its context, and its value. This value is expressed as a maybe because the node may contain an insert new node-type placeholder.
Subscriptions for interactive enhancements like keyboard events
A function that updates hidden state and tree. This function is passed in the toMsg field of the view function.
Passing functions is necessary here because in the update function using elm-arborist, modifications in state always need to operate on the latest value because events like mousemove are fired very frequently and therefore it is possible that the changes caused by one event in the runtime are undone by one that follows immediately after.
Type definition for the settings object
Determines whether there is an active node. This is a simple alternative to activeNode, which provides a lot more information and requires more inputs in scope.
Returns the current active node as a tuple of Maybe node (as the node maybe a placeholder for a new node), as well as some contextual information as a two-field record:
position : ( Float, Float ): the node's position on the canvas (useful for rendering an edit pop-up).context: view context, identical to the one provided in NodeView.In order for the position calculations to match the current active node, you must supply the same settings array that the view method gets.
Sets a new node at the active position. This may be adding a completely new node from scratch (in case the current node is a placeholder), or modifying an existing one. Typically, the modification is based off an original value provided by the activeNode method.
Sets the active node with the option to also set its children. The existing children will be discarded along with their children.
Delete the active node from a tree, including all of its children. If a placeholder is active, this method does nothing.
Similar to setActiveNode, but instead of updating just the node with its subtrees intact, it updates the entire branch based on a Tree -> Tree function.
Restores the original pan position of the tree.
Remove active node
The state of a node at a given time. May be normal one of the following:
Normal: node in rest stateHovered: a hovered over nodeActive: an activated node. Overrides hoverDropTarget: indicates that a swap or insert of the dragged subtree will take place at this node upon release
Opaque type for the editor's model, dependent on a node type variable. You can only use this for type annotation - to initialize a new model, see init.