Weave.js

WeavePlugin

Blueprint for the Plugin API

Overview

The abstract WeavePlugin class represents the base structure for all plugins in the Weave.js ecosystem. Plugins are modular components that extend the functionality of the canvas environment without modifying the core Weave.js system itself.

The WeavePlugin class provides the foundational API that all specific plugins—such as selection tools, grid rendering, snapping systems, or user pointers—inherit and build upon. It defines the lifecycle hooks and integration points necessary to inject custom behavior into a Weave.js app.

Plugins are ideal for:

  • Building reusable visual or behavioral extensions for the canvas.
  • Enabling domain-specific tools (e.g., diagramming tools, design tool overlays).
  • Keeping the core system clean and lightweight, while scaling with feature complexity.
  • Supporting collaborative behaviors (e.g., multi-user cursors, collaborative selection).

All plugins must extend this class.

Don't directly use

Don't instantiate this WeavePlugin class directly.

Lifecycle

A Weave.js plugin lifecycle is pretty simple:

Decoupled from the lifecycle

The following methods are called outside the lifecycle:

  • When an user wants to disable the plugin, the disable method is called.
  • When an user wants to enable the plugin, the enable method is called.

Import

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

Name

All plugins must define a property:

name: string;

Which defines the plugin identity, for example the plugin that handles the stage grid it's name is stageGrid. The name must be unique among other plugins.

Methods

getName

getName(): string

This method returns the name property of the node.

isEnabled

isEnabled(): boolean

This method returns true if the plugin is enabled, false otherwise.

Abstract Methods

init

init?(): void

This method initializes the plugin, ideal to initialize all necessary Konva elements needed and their events.

render

render?(): void

This method is called then the canvas re-renders, useful to update the plugin nodes updated according to the changes made by the user.

enable

enable(): void

This method makes enabled the plugin.

disable

disable(): void

This method disables the plugin.