Actions
Actions API Reference
Introduction
Actions are the core mechanism for handling user-driven changes in Weave.js. Whether you're adding a node, moving elements, updating properties, or triggering a custom behavior, Actions provide a structured, trackable way to apply changes to the shared state.
Actions help keep your application logic clean and consistent, and collaborative. In Weave.js, if something meaningful happens—it’s probably through an Action.
Weave.js includes a set of built-in Actions, but you can also create your own to tailor functionality to your specific application needs.
Available actions
Weave.js team maintain a set of actions, think of them as how the users interact with the canvas to build visual collaborative applications. This are the actions:
Base
Collaboration
UX Tools
WeaveEraserToolAction
Allows users to erase (delete) elements of the canvas. When enabled the user can click on an element and it will be erased.
WeaveMoveToolAction
Allows users to enable/disable the panning of canvas. When enabled the user can pan the canvas at its will.
WeaveSelectionToolAction
Allows users to enable/disable the selection mode of the canvas. When enabled the users can select nodes, move then, resize them, etc.
Layout Tools
Nodes Tools
WeaveBrushToolAction
Enables users to paint freeform strokes on the canvas, similar to a digital brush.
WeaveConnectorToolAction
Enables users to add new connector nodes to the canvas by clicking or touching on nodes pre-defined anchors.
WeaveEllipseToolAction
Enables users to create new ellipses nodes on the canvas.
WeaveImageToolAction
Enables users to add images to the canvas by selecting a file.
WeaveRectangleToolAction
Enables users to create new rectangle nodes on the canvas.
WeaveRegularPolygonToolAction
Enables users to create new regular polygons nodes on the canvas.
WeaveStarToolAction
Enables users to add new star nodes to the canvas by clicking or touching on it.
WeaveStrokeToolAction
Enables users to create a single-stroke line on the canvas.
WeaveTextToolAction
Enables users to add new text nodes to the canvas by clicking or touching on it.
WeaveVideoToolAction
Enables users to add videos to the canvas by selecting a file.
Deprecated
WeaveArrowToolAction (deprecated)
Enables users to add new arrow nodes to the canvas by clicking or touching on it.
WeaveLineToolAction (deprecated)
Enables users to create a single-stroke line on the canvas.
WeavePenToolAction (deprecated)
Enables users to create continuos lines on the canvas with N segments on the canvas.
Support Tools
Grouping Tools
Zooming Tools
WeaveFitToScreenToolAction
Automatically adjusts the zoom and position of the canvas to ensure all visible nodes fit neatly within the viewport.
WeaveFitToSelectionToolAction
Automatically adjusts the zoom and position of the canvas to ensure all selected nodes fit neatly within the viewport.
WeaveZoomInToolAction
Enables users to incrementally zoom into the canvas, providing a more detailed view of content.
WeaveZoomOutToolAction
Enables users to incrementally zoom out the canvas, providing a more general view of content.
Export Tools
WeaveExportNodeToolAction
Automatically adjusts the zoom and position of the canvas to ensure all selected nodes fit neatly within the viewport, and then proceeds to export the viewport as an image.
WeaveExportStageToolAction
Automatically adjusts the zoom and position of the canvas to ensure all visible nodes fit neatly within the viewport, and then proceeds to export the viewport as an image.
