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.

Required Methods

enable

enable(): void

This method makes enabled the plugin.

disable

disable(): void

This method disables the plugin.

Optional Hooks

initialize

initialize?(): void

This method resets the internal state of the plugin. It’s called each time the Weave instance is reset, for example when switching rooms. Built-in plugins also call it from their constructor.

onInit

onInit?(): void

This method is called once after the Weave instance is set up, and is the ideal place to initialize all necessary Konva elements needed and their events.

initialize vs onInit

Use initialize to (re)set state that must start clean every time the Weave instance is reset, and onInit to create elements and register events once the instance is ready.

onRender

onRender?(): void

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