api.contextMenu
ContextMenuApi
Items in the right-click menus of the map and the terrain palette.
Members
add
add(surface: ContextSurface, item: ContextItemSpec): Disposable;
// Right-click the map: copy the tile's position.
api.contextMenu.add("viewport", {
label: (ctx) => (ctx.tile ? `Copy position (${ctx.tile.x}, ${ctx.tile.y})` : "Copy position"),
enabled: (ctx) => ctx.tile !== null,
run: (ctx) => { if (ctx.tile) void navigator.clipboard.writeText(`${ctx.tile.x}, ${ctx.tile.y}`); },
});Try itTypes
Declarations only this group names.
ContextSurfacetype
type ContextSurface = "viewport" | "terrainPalette";
ContextItemSpecinterface
interface ContextItemSpec
label: string | ((ctx: ContextMenuContext) => string) | A fixed label is given in English and shown through the plugin's registered catalogues;
a function is called when the menu opens, so it translates with |
|---|---|
enabled?: (ctx: ContextMenuContext) => boolean | |
visible?: (ctx: ContextMenuContext) => boolean | |
run?: (ctx: ContextMenuContext) => void | Give this or |
command?: string |