Vizel API / core/src / VizelCommand
Interface: VizelCommand
Defined in: packages/core/src/commands/types.ts:80
Unified runtime-bearing command shared across editor surfaces.
A single VizelCommand defines one user action for the slash item, toolbar action, bubble menu action, block menu action, and shortcut binding at once. Surface-specific builders (buildVizelSlashMenuSpecFromCommands, buildVizelToolbarSpec, buildVizelBubbleMenuSpec, buildVizelBlockMenuSpecFromCommands) consume VizelCommand[] and derive the matching spec shapes; registerVizelShortcuts consumes the same list to wire keyboard bindings.
Example
const boldCommand: VizelCommand = {
id: "format/bold",
label: (locale) => locale.toolbar.bold,
icon: "bold",
shortcut: { mac: "Mod-B", other: "Mod-B" },
canRun: (editor) => editor.can().toggleBold(),
isActive: (editor) => editor.isActive("bold"),
run: (editor) => editor.chain().focus().toggleBold().run(),
surfaces: {
toolbar: { priority: 10 },
bubbleMenu: { priority: 10 },
shortcut: true,
},
};Properties
canRun
readonly canRun: (editor) => boolean;Defined in: packages/core/src/commands/types.ts:96
Whether the command can currently run against the editor.
Parameters
| Parameter | Type |
|---|---|
editor | Editor |
Returns
boolean
description?
readonly optional description?: (locale) => string;Defined in: packages/core/src/commands/types.ts:86
Optional secondary line (slash menu description, tooltip hint).
Parameters
| Parameter | Type |
|---|---|
locale | VizelLocale |
Returns
string
group?
readonly optional group?: string;Defined in: packages/core/src/commands/types.ts:90
Group key for slash menu sections and other categorized surfaces.
icon?
readonly optional icon?: VizelIconName;Defined in: packages/core/src/commands/types.ts:88
Optional icon identifier resolved by the icon catalog.
id
readonly id: string;Defined in: packages/core/src/commands/types.ts:82
Stable identifier shared across surfaces (e.g. "format/bold").
isActive?
readonly optional isActive?: (editor) => boolean;Defined in: packages/core/src/commands/types.ts:98
Whether the command's mark / node is currently active at the selection.
Parameters
| Parameter | Type |
|---|---|
editor | Editor |
Returns
boolean
keywords?
readonly optional keywords?: readonly string[];Defined in: packages/core/src/commands/types.ts:92
Fuzzy-match keywords used by slash menu filtering.
label
readonly label: (locale) => string;Defined in: packages/core/src/commands/types.ts:84
Localized display label.
Parameters
| Parameter | Type |
|---|---|
locale | VizelLocale |
Returns
string
run
readonly run: (editor) => boolean;Defined in: packages/core/src/commands/types.ts:100
Execute the command. Returns whether the command applied.
Parameters
| Parameter | Type |
|---|---|
editor | Editor |
Returns
boolean
shortcut?
readonly optional shortcut?: VizelShortcut;Defined in: packages/core/src/commands/types.ts:94
Optional keyboard shortcut. Bound only when surfaces.shortcut === true.
surfaces
readonly surfaces: VizelCommandSurfaceSet;Defined in: packages/core/src/commands/types.ts:102
Surfaces the command appears on.