Rich text / foldkit-richtext-dom/events

AttachOptions

interface · packages/richtext-dom/src/events.ts:221

interface AttachOptions {
  readonly onIntent: (command: RichText.Command) => void
  readonly onHistory?: (direction: 'undo' | 'redo') => void
  readonly onSelection?: (selection: RichText.Selection | null) => void
  readonly kit?: RichText.Kit | undefined
  readonly keymap?: ReadonlyArray<KeyBinding> | undefined
  readonly decorate?: Decorate | undefined
  readonly placeholder?: string | undefined
  readonly label?: string | undefined
  readonly labelledBy?: string | undefined
  readonly lineHint?: string | undefined
  readonly nodes?: RichText.NodeRegistry | undefined
  readonly onAction?:
    ((node: RichText.NodeId, action: string) => void) | undefined
}

Members

AttachOptions.onIntent

property · packages/richtext-dom/src/events.ts:223

readonly onIntent: (command: RichText.Command) => void

Called with each semantic command the browser produced.

AttachOptions.onHistory

property · packages/richtext-dom/src/events.ts:225

readonly onHistory?: (direction: 'undo' | 'redo') => void

Called for undo and redo, which are editor intents rather than commands.

AttachOptions.onSelection

property · packages/richtext-dom/src/events.ts:231

readonly onSelection?: (selection: RichText.Selection | null) => void

Called when the caret or range moves to a position the application did not just commit. Without it the editor never learns where the caret is; the adapter cannot follow a selection it is not told about.

AttachOptions.kit

property · packages/richtext-dom/src/events.ts:236

readonly kit?: RichText.Kit | undefined

When given, imported HTML is constrained to this vocabulary: a node kind the Kit does not declare is degraded to a paragraph, never kept.

AttachOptions.keymap

property · packages/richtext-dom/src/events.ts:238

readonly keymap?: ReadonlyArray<KeyBinding> | undefined

Chords the application adds or overrides, checked before the built-ins.

AttachOptions.decorate

property · packages/richtext-dom/src/events.ts:243

readonly decorate?: Decorate | undefined

What is drawn over the document (§129), derived from it each time it is synced — code highlighting, say. A pure read: it sees the document and nothing else.

AttachOptions.placeholder

property · packages/richtext-dom/src/events.ts:245

readonly placeholder?: string | undefined

What a blank document shows (RichText.isBlank): "Write something…".

AttachOptions.label

property · packages/richtext-dom/src/events.ts:247

readonly label?: string | undefined

The editor's accessible name, as aria-label on the editable root.

AttachOptions.labelledBy

property · packages/richtext-dom/src/events.ts:252

readonly labelledBy?: string | undefined

The id of the element that names the editor, as aria-labelledby. Without a label or this, the editor takes the name of the group it is drawn in (the label a form gives its control).

AttachOptions.lineHint

property · packages/richtext-dom/src/events.ts:258

readonly lineHint?: string | undefined

What the empty paragraph a collapsed caret is in shows, as data-hint on it, which a stylesheet draws as it draws the placeholder (usually only while the editor has the focus). A blank document's block shows the placeholder instead.

AttachOptions.nodes

property · packages/richtext-dom/src/events.ts:263

readonly nodes?: RichText.NodeRegistry | undefined

The node vocabulary, which says where Tab means something (RichText.takesTab): code and table cells take it as Indent and Outdent; anywhere else it moves focus as it always does.

AttachOptions.onAction

property · packages/richtext-dom/src/events.ts:265

readonly onAction?:
  ((node: RichText.NodeId, action: string) => void) | undefined

Called with a block and an adornment's action when that adornment is clicked.