@samatawy/diagrams
    Preparing search index...

    Class DiagramContextMenu

    A context menu pre-populated with diagram editing actions.

    Wire it to a DiagramView by assigning to view.contextMenu. The view will call open when a right-click event fires.

    const menu = new DiagramContextMenu(editorView);
    editorView.contextMenu = menu;

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    host: HTMLElement
    menuElement: HTMLElement | null = null

    Accessors

    Methods

    • Appends a labelled menu item that calls the given handler and closes the menu on click.

      Parameters

      • label: string

        Display text for the item.

      • onClick: () => void

        Callback invoked when the item is clicked.

      • options: { icon?: Element | null; active?: boolean; disabled?: boolean } = {}

        Optional icon element, active toggle state, and disabled flag.

      Returns HTMLElement

      The created menu item element.

    • Positions and displays the menu at the given viewport coordinates. Any previously open menu is closed first. Call this from open after populating items.

      Parameters

      • x: number

        Horizontal position in viewport pixels.

      • y: number

        Vertical position in viewport pixels.

      Returns void

    • Populates and displays the context menu at the event coordinates. Called automatically by DiagramView.contextmenu().

      Parameters

      • event: MouseEvent

        The mouse event from the context-menu trigger.

      Returns void