API / @aionbuilders/nabu

CommandContext

Type Stability: stable

What the engine builds at each key press (and for nabu.exec of a command, with event: null). Extensions add FACTS (any other property) through Extension#commandContext; facts never replace the fields below.

Related guide: Commands and keymap →

Definition

TypeScript
import type { CommandContext } from '@aionbuilders/nabu';
TypeScript
interface CommandContext {
  ancestors: string[];
  block: Block | null;
  event: KeyboardEvent | null;
  inRoot: boolean;
  isCollapsed: boolean;
  nabu: Nabu;
  selection: NabuSelection;
}

Properties

Properties of CommandContext
PropertyTypeDescription
ancestorsstring[]

types of the ancestors of block, nearest first ([] for a root block)

blockBlock | null

the block holding the selection anchor

eventKeyboardEvent | null

the key press; null when the command runs from exec / commands.run

inRootboolean

block is a direct child of the document (not nested in a container)

isCollapsedbooleann/a
nabuNabun/a
selectionNabuSelectionn/a

Source: src/lib/utils/commands.js:17