Skip to content

CodeMirrorModule

Unofficial

The CodeMirror 5 library module type, representing the window.CodeMirror object.

Import:

import type { CodeMirrorModule } from '@obsidian-typings/obsidian-catalyst-latest';

Signature:

export interface CodeMirrorModule

Properties

PropertyTypeDescription
addClassunknownAdds a CSS class to a node.
commandsRecord<string, (cm: Cm5Editor) => void>A map of built-in CodeMirror 5 commands.
containsunknownChecks whether one node contains another.
copyStateunknownCopies a mode state object.
defaultsRecord<string, unknown>Default configuration options for CodeMirror 5 editors.
DocunknownThe CodeMirror 5 Doc constructor.
e_preventDefaultunknownPrevents the default action of an event.
e_stopunknownStops an event (prevents default and stops propagation).
e_stopPropagationunknownStops propagation of an event.
findColumnunknownFinds the character offset for a given column.
findModeByExtensionunknownFinds a mode spec by file extension.
findModeByFileNameunknownFinds a mode spec by file name.
findModeByMIMEunknownFinds a mode spec by MIME type.
findModeByNameunknownFinds a mode spec by name.
foldunknownThe code-folding helper namespace.
helpersunknownRegistered helper namespaces.
InitunknownSentinel value passed as the "old value" on the first option update.
inputStylesunknownRegistered input-style implementations.
isModifierKeyunknownChecks whether a keyboard event is a modifier keypress.
keyMapRecord<string, Cm5KeyMap>A map of key map definitions for CodeMirror 5.
keyNameunknownGets the key name for a keyboard event.
keyNamesunknownA map of key codes to key names.
LineunknownThe CodeMirror 5 Line constructor.
LineWidgetunknownThe CodeMirror 5 LineWidget constructor.
lookupKeyunknownLooks up a key binding in a keymap.
mimeModesRecord<string, Cm5ModeSpec<unknown> | string>Maps MIME types to mode specifications.
modeExtensionsunknownRegistered mode extensions.
modeInfounknownThe list of known mode descriptors.
modesRecord<string, Cm5ModeFactory<unknown>>The mode map, mapping mode names to their factory constructors.
newFoldFunctionunknownCreates a fold function for a given fold helper.
optionHandlersunknownRegistered option handlers.
PassCm5PassA sentinel value that key handlers can return to indicate the binding should fall through.
resolveModeunknownResolves a mode spec to a normalized form.
rmClassunknownRemoves a CSS class from a node.
scrollbarModelunknownRegistered scrollbar-model implementations.
SharedTextMarkerunknownThe CodeMirror 5 SharedTextMarker constructor.
StringStreamunknownThe CodeMirror 5 StringStream constructor.
TextMarkerunknownThe CodeMirror 5 TextMarker constructor.
versionstringThe CodeMirror 5 version string.
VimunknownThe CodeMirror 5 Vim-mode API.
wheelEventPixelsunknownComputes pixel deltas for a wheel event.

Methods

MethodReturnsDescription
changeEnd(change)PositionComputes the end position of a change.
cmpPos(a, b)numberCompares two positions.
countColumn(line, index, tabSize)numberFinds the column position at a given string index using a given tab size.
defineDocExtension(name, value)voidLike defineExtension, but the method will be added to Doc objects instead.
defineExtension(name, value)voidRegisters a new editor extension method.
defineInitHook(f)voidRegisters a function to be called when an editor is initialized.
defineMIME(mime, modeSpec)voidRegisters a MIME type with its associated mode specification.
defineMode(name, modeFactory, dependencies?)voidRegisters a new editor mode.
defineOption(name, defaultValue, onUpdate)voidRegisters a new editor option.
extendMode(name, properties)voidAdds or overrides properties on mode objects produced for a specific mode.
fromTextArea(host, options?)Cm5EditorCreates a CodeMirror 5 editor from a textarea element.
getMode(config, modeSpec)Cm5Mode<unknown>Creates a mode object for the given mode specification.
innerMode(mode, state)Cm5InnerModeResultReturns the inner mode and its state for the current position.
isWordChar(ch)booleanChecks whether a character is a word character.
normalizeKeyMap(keymap)Cm5KeyMapNormalizes a key map, expanding multi-stroke key bindings.
off(target, type, f)voidRemoves an event handler from the given target.
on(target, type, f)voidRegisters an event handler on the given target.
overlayMode(base, overlay, combine?)Cm5Mode<unknown>Utility function to create an overlay mode combining two modes.
Pos(line, ch?, sticky?)PositionA constructor function for creating Position objects.
registerGlobalHelper(type, name, predicate, value)voidRegisters a global helper with a predicate.
registerHelper(type, name, value)voidRegisters a helper value for a specific type.
signal(target, name, args?)voidFires a signal (event) on the given target.
splitLines(text)string[]Splits a string by newline characters.
startState(mode)boolean | TCalls startState of the mode if available, otherwise returns true.

Links to this page: