History – inksane
inksane
ExtensionsEditor features

History

The history extension: undo and redo for typing and commands.

The history extension adds undo and redo. Register it individually or through BaseKit.

Setup

Import HistoryExtension and register it with the editor:

import { Editor } from "@inksane/core";
import { HistoryExtension } from "@inksane/core/extensions/history";

const editor = new Editor({
  element: document.getElementById("editor")!,
  extensions: [HistoryExtension],
});

Create the mount element before this code runs. BaseKit includes history, so no separate registration is needed with the kit. Disable it with BaseKit({ history: false }).

For Yjs collaboration, keep this extension disabled. The collaboration extension owns its own undo history.

What it adds

  • The CodeMirror history() extension, which records document changes.
  • The redo and undo keybindings listed below.

Commands dispatch their changes through the editor update, so both typing and command-based edits are undoable.

Keyboard

KeysAction
Mod-zUndo.
Mod-yRedo.
Mod-Shift-zRedo.

Mod-Shift-z is bound explicitly in addition to the CodeMirror keymap, which would only bind it on macOS and Linux, so redo works on the same keys on every platform.