Skip to content

Cm5Editor

Unofficial

A CodeMirror 5 editor instance.

Import:

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

Signature:

export interface Cm5Editor extends Doc

Extends: Doc

Properties

Property Type Description
display Cm5EditorDisplay The display object containing the wrapper element.
modeOption Cm5ModeSpec<unknown> | string The mode specification for this document.
(Inherited from Doc)
state Cm5EditorState The editor state object.

Methods

Method Returns Description
addKeyMap(map, bottom?) void Adds a key map to the editor.
addLineClass(line, where, className) Cm5LineHandle Set a CSS class name for the given line.
addLineWidget(line, node, options?) Cm5LineWidget Adds a line widget below the given line.
addOverlay(mode, options?) void Adds a mode overlay to the editor.
addSelection(anchor, head?) void Adds a new selection to the existing set of selections.
addWidget(pos, node, scrollIntoView) void Puts an absolutely positioned DOM node into the editor.
changeGeneration(closeEvent?) number Returns a number that can later be passed to isClean to test whether any edits were made.
(Inherited from Doc)
charCoords(pos, mode?) Cm5EditorCharCoords Returns the coordinates for a character position.
clearGutter(gutterID) void Remove all gutter markers in the gutter with the given ID.
clearHistory() void Clears the editor's undo history.
(Inherited from Doc)
coordsChar(coords, mode?) Position Returns the position corresponding to the given coordinates.
copy(copyHistory) Doc Create an identical copy of this document.
(Inherited from Doc)
cursorCoords(where?, mode?) Cm5EditorCursorCoords Returns the coordinates of the cursor.
defaultCharWidth() number Returns the default character width.
defaultTextHeight() number Returns the default text height.
eachLine(f) void Iterate over the whole document, calling f for each line.
(Inherited from Doc)
eachLine(start, end, f) void Iterate over a range of lines.
(Inherited from Doc)
endOperation() void Ends a buffered operation started with startOperation.
execCommand(name) void Executes a named command.
extendSelection(from, to?, options?) void Moves the head of the selection while leaving the anchor in place.
extendSelections(heads, options?) void Like extendSelection, but acts on all selections at once.
extendSelectionsBy(f) void Applies a function to all selections and calls extendSelections on the result.
findMarks(from, to) TextMarker[] Returns an array of all the bookmarks and marked ranges found between the given positions.
(Inherited from Doc)
findMarksAt(pos) TextMarker[] Returns an array of all the bookmarks and marked ranges at the given position.
(Inherited from Doc)
findPosH(start, amount, unit, visually) Cm5FindPosResult Finds the target position for horizontal cursor motion.
findPosV(start, amount, unit) Cm5FindPosResult Finds the target position for vertical cursor motion.
findWordAt(pos) Cm5Range Returns the start and end of the word at the given position.
firstLine() number Get the first line of the editor.
(Inherited from Doc)
focus() void Gives focus to the editor.
getAllMarks() TextMarker[] Returns an array containing all marked ranges in the document.
(Inherited from Doc)
getCursor(start?) Position Gets the cursor position.
(Inherited from Doc)
getDoc() Doc Gets the associated document.
getEditor() Cm5Editor | null Retrieve the editor associated with this document.
(Inherited from Doc)
getExtending() boolean Get the value of the 'extending' flag.
getGutterElement() HTMLElement Returns the gutter element.
getHistory() unknown Get a JSON-serializable representation of the undo history.
(Inherited from Doc)
getInputField() HTMLDivElement | HTMLTextAreaElement Returns the input field element.
getLine(n) string Gets the content of the given line.
(Inherited from Doc)
getLineHandle(num) Cm5LineHandle Fetches the line handle for the given line number.
(Inherited from Doc)
getLineNumber(handle) null | number Given a line handle, returns the current position of that line.
(Inherited from Doc)
getLineTokens(line, precise?) Cm5Token[] Retrieves a list of all tokens on the given line.
getMode() Cm5Mode<unknown> Gets the mode object for this document.
(Inherited from Doc)
getModeAt(pos) Cm5Mode<unknown> Gets the inner mode at a given position.
getOption(option) unknown Gets the value of an option.
getRange(from, to, separator?) string Gets the text between the given points.
(Inherited from Doc)
getScrollerElement() HTMLElement Returns the scroller element.
getScrollInfo() Cm5ScrollInfo Returns scroll position and dimensions.
getSelection(lineSep?) string Gets the currently selected text.
(Inherited from Doc)
getSelections(lineSep?) string[] Returns an array containing a string for each selection.
(Inherited from Doc)
getStateAfter(line?) unknown Returns the mode's parser state at the end of the given line number.
getTokenAt(pos, precise?) Cm5Token Retrieves information about the token at the given position.
getTokenTypeAt(pos) string Returns the token type at the given position.
getValue(separator?) string Gets the editor content.
(Inherited from Doc)
getViewport() Cm5Viewport Returns the start and end of the currently rendered part of the document.
getWrapperElement() HTMLElement Returns the wrapper element.
hasFocus() boolean Tells whether the editor currently has focus.
heightAtLine(line, mode?, includeWidgets?) number Computes the height of the top of a line.
historySize() DocHistorySize Gets the number of undo/redo operations available.
(Inherited from Doc)
indentLine(line, dir?, aggressive?) void Adjusts the indentation of the given line.
indentSelection(how) void Indents the current selection.
indexFromPos(object) number The reverse of posFromIndex.
(Inherited from Doc)
isClean(generation?) boolean Returns whether the document is currently clean.
(Inherited from Doc)
isReadOnly() boolean Tells you whether the editor's content can be edited by the user.
iterLinkedDocs(fn) void Will call the given function for all documents linked to this document.
(Inherited from Doc)
lastLine() number Get the last line of the editor.
(Inherited from Doc)
lineAtHeight(height, mode?) number Computes the line at the given pixel height.
lineCount() number Gets the number of lines in the document.
(Inherited from Doc)
lineInfo(line) Cm5LineInfo Returns information about the given line.
lineSeparator() string Returns the preferred line separator string for this document.
(Inherited from Doc)
linkedDoc(options) Doc Create a new document linked to this one.
(Inherited from Doc)
listSelections() Cm5Range[] Retrieves a list of all current selections.
markClean() void Set the editor content as 'clean'.
(Inherited from Doc)
markText(from, to, options?) TextMarker Marks a range of text with a specific CSS class.
(Inherited from Doc)
off(eventName, handler) void Removes an event listener.
on(eventName, handler) void Registers an event listener.
operation(fn) T Buffers all changes inside the function and only updates after it returns.
phrase(text) unknown Translates a string through the phrases option for i18n.
posFromIndex(index) Position Calculates a position for a zero-based index.
(Inherited from Doc)
redo() void Redoes the last undone edit.
(Inherited from Doc)
redoSelection() void Redo one undone selection change.
(Inherited from Doc)
refresh() void Refreshes the editor display.
removeKeyMap(map) void Removes a key map from the editor.
removeLine(n) void Remove the given line from the document.
(Inherited from Doc)
removeLineClass(line, where, className?) Cm5LineHandle Remove a CSS class from a line.
removeLineWidget(widget) void Removes a line widget.
removeOverlay(mode) void Removes a mode overlay from the editor.
replaceRange(replacement, from, to?, origin?) void Replaces the range between the given points with the given string.
(Inherited from Doc)
replaceSelection(replacement, select?) void Replaces the current selection with the given string.
(Inherited from Doc)
replaceSelections(replacements, collapse?, origin?) void Replaces the content of the selections with the given strings.
scrollIntoView(pos, margin?) void Scrolls the editor to the given position.
scrollTo(x?, y?) void Scrolls the editor to the given coordinates.
setBookmark(pos, options?) TextMarker Inserts a bookmark at the given position.
(Inherited from Doc)
setCursor(pos, ch?, options?) void Sets the cursor position.
(Inherited from Doc)
setExtending(value) void Sets or clears the 'extending' flag.
setGutterMarker(line, gutterID, value) Cm5LineHandle Sets the gutter marker for the given gutter.
setHistory(history) void Replace the editor's undo history.
(Inherited from Doc)
setLine(n, text) void Set the content of a given line.
(Inherited from Doc)
setOption(option, value) void Sets the value of an option.
setSelection(anchor, head?, options?) void Sets the selection range.
(Inherited from Doc)
setSelections(ranges, primary?, options?) void Sets a new set of selections.
setSize(width, height) void Sets the editor size.
setValue(content) void Sets the editor content.
(Inherited from Doc)
somethingSelected() boolean Tells whether the editor currently has a selection.
(Inherited from Doc)
startOperation() void Starts a buffered operation.
swapDoc(doc) Doc Attaches a new document to the editor.
toggleOverwrite(value?) void Switches between overwrite and normal insert mode.
undo() void Undoes the last edit.
(Inherited from Doc)
undoSelection() void Undo one selection change.
(Inherited from Doc)
unlinkDoc(doc) void Break the link between two documents.
(Inherited from Doc)

Links to this page: