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

PropertyTypeDescription
addModeClass?booleanWhether 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?booleanWhether to enable autocapitalize on the input.
autocorrect?booleanWhether to enable autocorrect on the input.
autofocus?booleanWhether to auto-focus on initialization.
coverGutterNextToScrollbar?booleanWhether the gutter will be covered when next to a scrollbar.
cursorBlinkRate?numberHalf-period in milliseconds used for cursor blinking.
cursorHeight?numberDetermines the height of the cursor (0 to 1).
cursorScrollMargin?numberExtra space above and below the cursor when approaching the visible edge.
direction?'ltr' | 'rtl'Flips overall layout direction ("ltr" or "rtl").
dragDrop?booleanControls whether drag-and-drop is enabled.
electricChars?booleanWhether to re-indent when a character is typed that might change indentation.
extraKeys?Cm5KeyMap | null | stringCan be used to specify extra keybindings for the editor.
firstLineNumber?numberAt which number to start counting lines.
fixedGutter?booleanWhether the gutter stays fixed during horizontal scrolling.
flattenSpans?booleanWhether 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?numberThe period of inactivity (ms) before a new history event is started.
indentUnit?numberThe number of spaces a block should be indented.
indentWithTabs?booleanWhether to indent with tabs.
inputStyle?Cm5InputStyleSelects the input model ("textarea" or "contenteditable").
keyMap?stringConfigures the keymap to use.
lineNumbers?booleanWhether to show line numbers.
lineSeparator?null | stringExplicitly set the line separator for the editor.
lineWiseCopyCut?booleanWhether to enable line-wise copy/cut when there is no selection.
lineWrapping?booleanWhether to enable line wrapping.
maxHighlightLength?numberPosition beyond which highlighting gives up.
mode?Cm5ModeSpec<unknown> | null | stringThe mode specification.
pasteLinesPerSelection?booleanWhether to paste one line per selection when counts match.
phrases?Record<string, unknown>An object mapping strings to translations for i18n.
pollInterval?numberHow quickly (ms) CodeMirror should poll its input for changes.
readOnly?'nocursor' | booleanWhether the editor is read-only.
resetSelectionOnContextMenu?booleanControls whether the context menu resets the selection.
rtlMoveVisually?booleanWhether horizontal cursor movement through RTL text is visual.
screenReaderLabel?stringA label read by screen readers when the editor is focused.
scrollbarStyle?stringChooses a scrollbar implementation ("native" or "null").
selectionsMayTouch?booleanWhether multiple selections are joined when they touch.
showCursorWhenSelecting?booleanWhether the cursor should be drawn when a selection is active.
smartIndent?booleanWhether to use context-sensitive indentation.
specialChars?RegExpA regular expression for characters that should be replaced by a placeholder.
spellcheck?booleanWhether to enable spellcheck on the input.
tabindex?numberThe tab index to assign to the editor.
tabSize?numberThe tab size in spaces.
theme?stringThe theme to style the editor with.
undoDepth?numberThe maximum number of undo levels stored.
value?Doc | stringThe starting value of the editor.
viewportMargin?numberSpecifies the amount of lines rendered above and below the visible area.
workDelay?numberHow long (ms) the highlighting thread works before sleeping.
workTime?numberHow long (ms) the highlighting thread sleeps between work periods.

Methods

MethodReturnsDescription
configureMouse(cm, repeat, event)Cm5MouseSelectionConfigurationAllows you to configure the behavior of mouse selection and dragging.
lineNumberFormatter(line)stringA function to format line numbers.
onDragEvent(instance, event)booleanDeprecated drag event handler.
onKeyEvent(instance, event)booleanDeprecated key event handler.
specialCharPlaceholder(char)HTMLElementA function that produces a DOM node for special characters.

Links to this page: