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
UX Tools
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.
WeaveEraserToolAction
Allows users to erase (delete) elements of the canvas. When enabled the user can click on an element and it will be erased.
Nodes Tools
WeaveRectangleToolAction
Enables users to create new rectangle nodes on the canvas.
WeaveEllipseToolAction
Enables users to create new ellipses nodes on the canvas.
WeaveRegularPolygonToolAction
Enables users to create new regular polygons nodes on the canvas.
WeavePenToolAction
Enables users to create continuos lines on the canvas with N segments on the canvas.
WeaveBrushToolAction
Enables users to paint freeform strokes on the canvas, similar to a digital brush.
WeaveImageToolAction
Enables users to add images to the canvas by selecting a file.
WeaveTextToolAction
Enables users to add new text nodes to the canvas by clicking or touching on it.
WeaveStarToolAction
Enables users to add new star nodes to the canvas by clicking or touching on it.
WeaveArrowToolAction
Enables users to add new arrow nodes to the canvas by clicking or touching on it.
Grouping Tools
Zooming Tools
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.
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.
Export Tools
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.
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.