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:

Property Type Required Description

config

WeaveStageContextMenuPluginConfig

Required

Config parameters for the plugin.

For WeaveStageContextMenuPluginConfig:

Property Type Required Default Description

xOffset

number

4

X-axis offset of the click point in pixels.

yOffset

number

4

Y-axis offset of the click point in pixes

Events

onNodeContextMenu

onNodeContextMenu: WeaveStageContextMenuPluginOnNodeContextMenuEvent;

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