Static rows or a context-aware factory evaluated each time the menu opens.
Declaration
export type ContextMenuItems =
Referenced by
Workspace packages depending on @sheetwrite/core
@sheetwrite/benchdependency
@sheetwrite/docs-startdependency
@sheetwrite/reactdependency
@sheetwrite/sveltedependency
@sheetwrite/vuedependency
@sheetwrite/xlsxdependency
Public exports naming ContextMenuItems
interface ContextMenuItem {
id?: string;
action?: ContextMenuActionName;
onClick?: (grid: Grid, cell: CellAddress | null) => void;
label?: string;
shortcut?: KeyboardAction | KeyShortcut;
visible?: boolean | ((context: ContextMenuContext) => boolean);
disabled?: boolean | ((context: ContextMenuContext) => boolean);
}interface ContextMenuItem {
id?: string;
action?: ContextMenuActionName;
onClick?: (grid: Grid, cell: CellAddress | null) => void;
label?: string;
shortcut?: KeyboardAction | KeyShortcut;
visible?: boolean | ((context: ContextMenuContext) => boolean);
disabled?: boolean | ((context: ContextMenuContext) => boolean);
}interface ContextMenuItem {
id?: string;
action?: ContextMenuActionName;
onClick?: (
grid: Grid,
cell: CellAddress | null,
) => void;
label?: string;
shortcut?:
KeyboardAction | KeyShortcut;
visible?:
| boolean
| ((
context: ContextMenuContext,
) => boolean);
disabled?:
| boolean
| ((
context: ContextMenuContext,
// … 2 more lines — see the API reference
}Built-in, separator, or custom callback row in the right-click menu. @example import type { ContextMenuItem, GridConfig } from "@sheetwrite/core"; const total: ContextMenuItem = { id: "total", label: "Show total", onClick(grid) { window.alert(String(grid.aggregate(0, "sum"))); }, }; const config: GridConfig = { contextMenu: [total, { action: "separator" }, { action: "copy" }] }; @see ContextMenuItems @see GridConfig.contextMenuAPI reference →interface ContextMenuContext {
readonly cell: CellAddress | null;
readonly clientX: number;
readonly clientY: number;
}interface ContextMenuContext {
readonly cell: CellAddress | null;
readonly clientX: number;
readonly clientY: number;
}interface ContextMenuContext {
readonly cell: CellAddress | null;
readonly clientX: number;
readonly clientY: number;
}Cell and viewport coordinates resolved for one bundled context-menu opening.API reference →