CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-codemirror--view

DOM view component for the CodeMirror code editor

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

keybindings.mddocs/

Key Bindings

CodeMirror's key binding system provides flexible keyboard interaction support with platform-specific modifiers, multi-stroke keys, and contextual commands.

KeyBinding Interface

interface KeyBinding {
  key: string;
  run: Command;
  shift?: Command;
  scope?: string;
  preventDefault?: boolean;
}

Keymap Facet

const keymap: Facet<readonly KeyBinding[]>;

function runScopeHandlers(view: EditorView, event: KeyboardEvent, scope: string): boolean;

Usage Examples

Basic Key Bindings

import { keymap } from "@codemirror/view";

const basicKeys = keymap.of([
  { key: "Ctrl-s", run: saveCommand },
  { key: "Ctrl-z", run: undoCommand },
  { key: "Ctrl-y", run: redoCommand },
  { key: "Mod-a", run: selectAllCommand } // Ctrl on PC, Cmd on Mac
]);

Multi-stroke Key Bindings

const multiStrokeKeys = keymap.of([
  { key: "Ctrl-k Ctrl-c", run: commentCommand },
  { key: "Ctrl-k Ctrl-u", run: uncommentCommand }
]);

Conditional Commands

const conditionalKeys = keymap.of([
  {
    key: "Tab",
    run: (view) => {
      if (view.state.selection.ranges.some(r => !r.empty)) {
        return indentSelection(view);
      }
      return insertTab(view);
    }
  }
]);

docs

bidi.md

builtin-extensions.md

decorations.md

editor-view.md

extensions.md

gutters.md

index.md

keybindings.md

layout.md

panels.md

tooltips.md

tile.json