Drag-and-drop interface to edit, dissect and-rearrange tree structures with arbitrary data sitting in their nodes. Structured as a TEA component defining its own init, update and view, elm-arborist allows you to easily initialize a tree editor, keep its state in an opaque model, and access the edited result at any time.
Message type annotation for the program. When wiring up the editor within a larger program, you will define a ArboristMsg Arborist.Msg message type, one that will trigger this package's update function.
Update function handling changes in the model.
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 responsible for obtaining animation frames used to smoothly center an activated tree node. Using these subscriptions is completely optional - if they aren't wired up in your app, the editor will simply jump to the activated node without an animation. We recommend adding these subscriptions as you familiarize yourself with the package, as it is a significant user experience improvement.
Apply a new list of settings to the model.
Resize the canvas by passing a new width and a new height. Note that you can reproduce this using applySettings as follows:
resize 600 400 arborist == applySettings [ Settings.canvasWidth 600, Settings.canvasHeight 400 ] arboristAccess the current state of the tree through this getter (returns structure defined in the Arborist.Tree module). The result reflects all changes since it was initialized.
Returns the current active node as a tuple of Maybe node (as the node maybe a placeholder for a new node), as well as its coordinates in the editor's container. Use these coordinates to position an active node-related pop-up (see example).
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.
Delete the active node from a tree, including all of its children. If a placeholder is active, this method does nothing.
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.