Weave.js

WeaveRectangleToolAction

Add a rectangle to the canvas

Overview

The WeaveRectangleToolAction class that allows users to create rectangle shapes on the canvas by clicking and dragging. It provides a smooth, intuitive way to add structured, resizable rectangular elements that can serve as building blocks for diagrams, layouts, mockups, and more.

Each interaction results in the creation of a WeaveRectangleNode, added to the shared state and synchronized across all users.

While dragging, hold Shift to draw a square, Alt/Option to draw from the initial point as the center, or both to combine the behaviors.

The class extends the WeaveAction class.

Name

This action name property value is rectangleTool.

Import

import { WeaveRectangleToolAction } from "@inditextech/weave-sdk";

Instantiation

new WeaveRectangleToolAction();