Skip to content

@jupyter-kit/editor-codemirror

CodeMirror 6 editor plugin. Replaces static <pre> code displays with a live editor per code cell. Adds a cell toolbar (run / add / delete).

createEditorPlugin() is installed transitively by both @jupyter-kit/executor-pyodide and @jupyter-kit/executor-webr — you only install it directly if you want editable cells without an executor.

EditorCodemirrorOptions

OptionTypeDefaultNotes
languagesRecord<string, Extension>{}Per-language CodeMirror extensions. Keys match cell language strings; '*' is fallback. Example: { python: python() }.
extensionsExtension[][]Extra extensions applied to every editor (theme, keymap, linting …).
readOnlybooleanfalseRender editors as read-only. Hides the Run / Add / Delete toolbar.
lineNumbersbooleanfalseShow gutter line numbers.
fontFamilystringui-monospace stackEditor font.
fontSizestring'inherit'CSS font-size value.
backgroundColorstring'transparent'Editor background.
focusBorderColorstringsemi-transparent blueLeft border when focused.
inactiveBorderColorstring'transparent'Left border when blurred.
runButtonbooleantrueShow the ▶ run button (only when executor is set).
runLabelstring'Run (Shift+Enter)'Tooltip for the run button.

Usage

import { createEditorPlugin } from '@jupyter-kit/editor-codemirror';
import { python } from '@codemirror/lang-python';
import { StreamLanguage } from '@codemirror/language';
import { r } from '@codemirror/legacy-modes/mode/r';
import { EditorView } from '@codemirror/view';
const plugin = createEditorPlugin({
languages: {
python: python(),
r: StreamLanguage.define(r),
},
extensions: [EditorView.lineWrapping],
lineNumbers: true,
});

Keybindings

KeysEffect
Shift+EnterRun the current cell and focus the next code cell.
Cmd/Ctrl+Z / Shift+Cmd/Ctrl+ZUndo / redo (within a cell).
Cmd/Ctrl+SDownload the notebook (see onSave).

Toolbar buttons

Visible on hover / focus of a code cell:

  • ▶ Run — runs the cell via ctx.executor?.rerun. Only rendered when an executor is present and runButton: true.
  • + Add cell below — inserts an empty cell of the same type.
  • 🗑 Delete cell — removes the cell.