Skip to content

CodeMirrorModule

Unofficial

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

Import:

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

Signature:

export interface CodeMirrorModule

Properties

Property Type Description
addClass unknown Adds a CSS class to a node.
commands Record<string, (cm: Cm5Editor) => void> A map of built-in CodeMirror 5 commands.
contains unknown Checks whether one node contains another.
copyState unknown Copies a mode state object.
defaults Record<string, unknown> Default configuration options for CodeMirror 5 editors.
Doc unknown The CodeMirror 5 Doc constructor.
e_preventDefault unknown Prevents the default action of an event.
e_stop unknown Stops an event (prevents default and stops propagation).
e_stopPropagation unknown Stops propagation of an event.
findColumn unknown Finds the character offset for a given column.
findModeByExtension unknown Finds a mode spec by file extension.
findModeByFileName unknown Finds a mode spec by file name.
findModeByMIME unknown Finds a mode spec by MIME type.
findModeByName unknown Finds a mode spec by name.
fold unknown The code-folding helper namespace.
helpers unknown Registered helper namespaces.
Init unknown Sentinel value passed as the "old value" on the first option update.
inputStyles unknown Registered input-style implementations.
isModifierKey unknown Checks whether a keyboard event is a modifier keypress.
keyMap Record<string, Cm5KeyMap> A map of key map definitions for CodeMirror 5.
keyName unknown Gets the key name for a keyboard event.
keyNames unknown A map of key codes to key names.
Line unknown The CodeMirror 5 Line constructor.
LineWidget unknown The CodeMirror 5 LineWidget constructor.
lookupKey unknown Looks up a key binding in a keymap.
mimeModes Record<string, Cm5ModeSpec<unknown> | string> Maps MIME types to mode specifications.
modeExtensions unknown Registered mode extensions.
modeInfo unknown The list of known mode descriptors.
modes Record<string, Cm5ModeFactory<unknown>> The mode map, mapping mode names to their factory constructors.
newFoldFunction unknown Creates a fold function for a given fold helper.
optionHandlers unknown Registered option handlers.
Pass Cm5Pass A sentinel value that key handlers can return to indicate the binding should fall through.
resolveMode unknown Resolves a mode spec to a normalized form.
rmClass unknown Removes a CSS class from a node.
scrollbarModel unknown Registered scrollbar-model implementations.
SharedTextMarker unknown The CodeMirror 5 SharedTextMarker constructor.
StringStream unknown The CodeMirror 5 StringStream constructor.
TextMarker unknown The CodeMirror 5 TextMarker constructor.
version string The CodeMirror 5 version string.
Vim unknown The CodeMirror 5 Vim-mode API.
wheelEventPixels unknown Computes pixel deltas for a wheel event.

Methods

Method Returns Description
changeEnd(change) Position Computes the end position of a change.
cmpPos(a, b) number Compares two positions.
countColumn(line, index, tabSize) number Finds the column position at a given string index using a given tab size.
defineDocExtension(name, value) void Like defineExtension, but the method will be added to Doc objects instead.
defineExtension(name, value) void Registers a new editor extension method.
defineInitHook(f) void Registers a function to be called when an editor is initialized.
defineMIME(mime, modeSpec) void Registers a MIME type with its associated mode specification.
defineMode(name, modeFactory) void Registers a new editor mode.
defineOption(name, defaultValue, onUpdate) void Registers a new editor option.
extendMode(name, properties) void Adds or overrides properties on mode objects produced for a specific mode.
fromTextArea(host, options?) Cm5Editor Creates 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) Cm5InnerModeResult Returns the inner mode and its state for the current position.
isWordChar(ch) boolean Checks whether a character is a word character.
normalizeKeyMap(keymap) Cm5KeyMap Normalizes a key map, expanding multi-stroke key bindings.
off(target, type, f) void Removes an event handler from the given target.
on(target, type, f) void Registers 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?) Position A constructor function for creating Position objects.
registerGlobalHelper(type, name, predicate, value) void Registers a global helper with a predicate.
registerHelper(type, name, value) void Registers a helper value for a specific type.
signal(target, name, args?) void Fires a signal (event) on the given target.
splitLines(text) string[] Splits a string by newline characters.
startState(mode) boolean | T Calls startState of the mode if available, otherwise returns true.

Links to this page: