WeavePolygonToolAction
Add a polygon to the canvas using a preset shape
Overview
The WeavePolygonToolAction class allows users to place a polygon node on the canvas by clicking or touching it.
The shape is selected via a preset — one of the six built-in polygon definitions shipped
with the SDK. The preset can be set at construction time, changed programmatically, or
overridden per-trigger via the presetId trigger parameter.
Each interaction results in the creation of a WeavePolygonNode, added to the shared state and synchronized across all users.
The class extends the WeaveAction class.
Name
This action name property value is polygonTool.
Import
import { WeavePolygonToolAction } from "@inditextech/weave-sdk";Instantiation
new WeavePolygonToolAction(preset?: string);Parameters
| Prop | Type | Default |
|---|---|---|
preset? | string | 'pentagon' |
Trigger parameters
type WeavePolygonToolActionTriggerParams = {
presetId?: string;
};| Prop | Type | Default |
|---|---|---|
presetId? | string | - |
Events
| Event | Payload | Description |
|---|---|---|
onAddingPolygon | undefined | Fired when the action enters the adding state (user is about to place the polygon). |
onAddedPolygon | undefined | Fired after the polygon node has been placed on the canvas. |
Methods
getPolygonsPresets
getPolygonsPresets(): Record<string, WeavePolygonPresetDef>Returns all available polygon presets. The built-in presets are:
triangle, diamond, pentagon, hexagon, octagon, decagon.
getPolygonPreset
getPolygonPreset(): stringReturns the currently active preset ID.
setPolygonPreset
setPolygonPreset(preset: string): voidSets the active preset ID. Takes effect on the next trigger call (unless presetId is
supplied via trigger params, which takes precedence).
