Skip to content

Cm5EditorConfiguration

Unofficial

Configuration options for a CodeMirror 5 editor instance.

Import:

import type { Cm5EditorConfiguration } from '@obsidian-typings/obsidian-public-latest';

Signature:

export interface Cm5EditorConfiguration

Properties

Property Type Description
addModeClass? boolean Whether to add an extra CSS class indicating the inner mode to each token.
allowDropFileTypes? null | string[] When set, only files whose MIME type is in this array can be dropped.
autocapitalize? boolean Whether to enable autocapitalize on the input.
autocorrect? boolean Whether to enable autocorrect on the input.
autofocus? boolean Whether to auto-focus on initialization.
coverGutterNextToScrollbar? boolean Whether the gutter will be covered when next to a scrollbar.
cursorBlinkRate? number Half-period in milliseconds used for cursor blinking.
cursorHeight? number Determines the height of the cursor (0 to 1).
cursorScrollMargin? number Extra space above and below the cursor when approaching the visible edge.
direction? 'ltr' | 'rtl' Flips overall layout direction ("ltr" or "rtl").
dragDrop? boolean Controls whether drag-and-drop is enabled.
electricChars? boolean Whether to re-indent when a character is typed that might change indentation.
extraKeys? Cm5KeyMap | null | string Can be used to specify extra keybindings for the editor.
firstLineNumber? number At which number to start counting lines.
fixedGutter? boolean Whether the gutter stays fixed during horizontal scrolling.
flattenSpans? boolean Whether to combine adjacent tokens with the same class into a single span.
gutters? Array<Cm5GutterConfig | string> An array of CSS class names for gutters.
historyEventDelay? number The period of inactivity (ms) before a new history event is started.
indentUnit? number The number of spaces a block should be indented.
indentWithTabs? boolean Whether to indent with tabs.
inputStyle? Cm5InputStyle Selects the input model ("textarea" or "contenteditable").
keyMap? string Configures the keymap to use.
lineNumbers? boolean Whether to show line numbers.
lineSeparator? null | string Explicitly set the line separator for the editor.
lineWiseCopyCut? boolean Whether to enable line-wise copy/cut when there is no selection.
lineWrapping? boolean Whether to enable line wrapping.
maxHighlightLength? number Position beyond which highlighting gives up.
mode? Cm5ModeSpec<unknown> | null | string The mode specification.
pasteLinesPerSelection? boolean Whether to paste one line per selection when counts match.
phrases? Record<string, unknown> An object mapping strings to translations for i18n.
pollInterval? number How quickly (ms) CodeMirror should poll its input for changes.
readOnly? 'nocursor' | boolean Whether the editor is read-only.
resetSelectionOnContextMenu? boolean Controls whether the context menu resets the selection.
rtlMoveVisually? boolean Whether horizontal cursor movement through RTL text is visual.
screenReaderLabel? string A label read by screen readers when the editor is focused.
scrollbarStyle? string Chooses a scrollbar implementation ("native" or "null").
selectionsMayTouch? boolean Whether multiple selections are joined when they touch.
showCursorWhenSelecting? boolean Whether the cursor should be drawn when a selection is active.
smartIndent? boolean Whether to use context-sensitive indentation.
specialChars? RegExp A regular expression for characters that should be replaced by a placeholder.
spellcheck? boolean Whether to enable spellcheck on the input.
tabindex? number The tab index to assign to the editor.
tabSize? number The tab size in spaces.
theme? string The theme to style the editor with.
undoDepth? number The maximum number of undo levels stored.
value? Doc | string The starting value of the editor.
viewportMargin? number Specifies the amount of lines rendered above and below the visible area.
workDelay? number How long (ms) the highlighting thread works before sleeping.
workTime? number How long (ms) the highlighting thread sleeps between work periods.

Methods

Method Returns Description
configureMouse(cm, repeat, event) Cm5MouseSelectionConfiguration Allows you to configure the behavior of mouse selection and dragging.
lineNumberFormatter(line) string A function to format line numbers.
onDragEvent(instance, event) boolean Deprecated drag event handler.
onKeyEvent(instance, event) boolean Deprecated key event handler.
specialCharPlaceholder(char) HTMLElement A function that produces a DOM node for special characters.

Links to this page: