Weave.js

WeaveContextMenuPlugin

Trigger a contextual menu on the canvas

Overview

The WeaveContextMenuPlugin class that enables custom right-click (context) menus on the canvas. It provides a flexible and modular way to trigger context-aware actions based on where and what the user right-clicks—whether it's a node, empty space, or selection.

This plugin enhances usability by letting developers define dynamic, context-sensitive options, making the user experience faster, more intuitive, and better organized.

The class extends the WeavePlugin class

Name

This plugin name property value is contextMenu.

Import

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

Instantiation

new WeaveContextMenuPlugin(params?: WeaveStageContextMenuPluginParams);

TypeScript types

type WeaveStageContextMenuPluginParams = {
  config?: WeaveStageContextMenuPluginConfig;
};

type WeaveStageContextMenuPluginConfig = {
  xOffset?: number;
  yOffset?: number;
};

type WeaveStageContextMenuPluginOnNodeContextMenuEvent = {
  selection: WeaveSelection[];
  point: Vector2d;
  visible: boolean;
};

Parameters

For WeaveStageContextMenuPluginParams:

PropTypeDefault
config
WeaveStageContextMenuPluginConfig
-

For WeaveStageContextMenuPluginConfig:

PropTypeDefault
yOffset?
number
4
xOffset?
number
4

Events

onNodeContextMenu

onNodeContextMenu: WeaveStageContextMenuPluginOnNodeContextMenuEvent;

The onNodeContextMenu event is called when an user triggers the context menu on a node or the stage.