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

PropertyTypeDescription
displayCm5EditorDisplayThe display object containing the wrapper element.
modeOptionCm5ModeSpec<unknown> | stringThe mode specification for this document.
(Inherited from Doc)
stateCm5EditorStateThe editor state object.

Methods

MethodReturnsDescription
addKeyMap(map, bottom?)voidAdds a key map to the editor.
addLineClass(line, where, className)Cm5LineHandleSet a CSS class name for the given line.
addLineWidget(line, node, options?)Cm5LineWidgetAdds a line widget below the given line.
addOverlay(mode, options?)voidAdds a mode overlay to the editor.
addSelection(anchor, head?)voidAdds a new selection to the existing set of selections.
addWidget(pos, node, scrollIntoView)voidPuts an absolutely positioned DOM node into the editor.
changeGeneration(closeEvent?)numberReturns a number that can later be passed to isClean to test whether any edits were made.
(Inherited from Doc)
charCoords(pos, mode?)Cm5EditorCharCoordsReturns the coordinates for a character position.
clearGutter(gutterID)voidRemove all gutter markers in the gutter with the given ID.
clearHistory()voidClears the editor's undo history.
(Inherited from Doc)
coordsChar(coords, mode?)PositionReturns the position corresponding to the given coordinates.
copy(copyHistory)DocCreate an identical copy of this document.
(Inherited from Doc)
cursorCoords(where?, mode?)Cm5EditorCursorCoordsReturns the coordinates of the cursor.
defaultCharWidth()numberReturns the default character width.
defaultTextHeight()numberReturns the default text height.
eachLine(f)voidIterate over the whole document, calling f for each line.
(Inherited from Doc)
eachLine(start, end, f)voidIterate over a range of lines.
(Inherited from Doc)
endOperation()voidEnds a buffered operation started with startOperation.
execCommand(name)voidExecutes a named command.
extendSelection(from, to?, options?)voidMoves the head of the selection while leaving the anchor in place.
extendSelections(heads, options?)voidLike extendSelection, but acts on all selections at once.
extendSelectionsBy(f)voidApplies 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)Cm5FindPosResultFinds the target position for horizontal cursor motion.
findPosV(start, amount, unit)Cm5FindPosResultFinds the target position for vertical cursor motion.
findWordAt(pos)Cm5RangeReturns the start and end of the word at the given position.
firstLine()numberGet the first line of the editor.
(Inherited from Doc)
focus()voidGives focus to the editor.
getAllMarks()TextMarker[]Returns an array containing all marked ranges in the document.
(Inherited from Doc)
getCursor(start?)PositionGets the cursor position.
(Inherited from Doc)
getDoc()DocGets the associated document.
getEditor()Cm5Editor | nullRetrieve the editor associated with this document.
(Inherited from Doc)
getExtending()booleanGet the value of the 'extending' flag.
getGutterElement()HTMLElementReturns the gutter element.
getHistory()unknownGet a JSON-serializable representation of the undo history.
(Inherited from Doc)
getInputField()HTMLDivElement | HTMLTextAreaElementReturns the input field element.
getLine(n)stringGets the content of the given line.
(Inherited from Doc)
getLineHandle(num)Cm5LineHandleFetches the line handle for the given line number.
(Inherited from Doc)
getLineNumber(handle)null | numberGiven 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)unknownGets the value of an option.
getRange(from, to, separator?)stringGets the text between the given points.
(Inherited from Doc)
getScrollerElement()HTMLElementReturns the scroller element.
getScrollInfo()Cm5ScrollInfoReturns scroll position and dimensions.
getSelection(lineSep?)stringGets the currently selected text.
(Inherited from Doc)
getSelections(lineSep?)string[]Returns an array containing a string for each selection.
(Inherited from Doc)
getStateAfter(line?)unknownReturns the mode's parser state at the end of the given line number.
getTokenAt(pos, precise?)Cm5TokenRetrieves information about the token at the given position.
getTokenTypeAt(pos)stringReturns the token type at the given position.
getValue(separator?)stringGets the editor content.
(Inherited from Doc)
getViewport()Cm5ViewportReturns the start and end of the currently rendered part of the document.
getWrapperElement()HTMLElementReturns the wrapper element.
hasFocus()booleanTells whether the editor currently has focus.
heightAtLine(line, mode?, includeWidgets?)numberComputes the height of the top of a line.
historySize()DocHistorySizeGets the number of undo/redo operations available.
(Inherited from Doc)
indentLine(line, dir?, aggressive?)voidAdjusts the indentation of the given line.
indentSelection(how)voidIndents the current selection.
indexFromPos(object)numberThe reverse of posFromIndex.
(Inherited from Doc)
isClean(generation?)booleanReturns whether the document is currently clean.
(Inherited from Doc)
isReadOnly()booleanTells you whether the editor's content can be edited by the user.
iterLinkedDocs(fn)voidWill call the given function for all documents linked to this document.
(Inherited from Doc)
lastLine()numberGet the last line of the editor.
(Inherited from Doc)
lineAtHeight(height, mode?)numberComputes the line at the given pixel height.
lineCount()numberGets the number of lines in the document.
(Inherited from Doc)
lineInfo(line)Cm5LineInfoReturns information about the given line.
lineSeparator()stringReturns the preferred line separator string for this document.
(Inherited from Doc)
linkedDoc(options)DocCreate a new document linked to this one.
(Inherited from Doc)
listSelections()Cm5Range[]Retrieves a list of all current selections.
markClean()voidSet the editor content as 'clean'.
(Inherited from Doc)
markText(from, to, options?)TextMarkerMarks a range of text with a specific CSS class.
(Inherited from Doc)
off(eventName, handler)voidRemoves an event listener.
on(eventName, handler)voidRegisters an event listener.
operation(fn)TBuffers all changes inside the function and only updates after it returns.
phrase(text)unknownTranslates a string through the phrases option for i18n.
posFromIndex(index)PositionCalculates a position for a zero-based index.
(Inherited from Doc)
redo()voidRedoes the last undone edit.
(Inherited from Doc)
redoSelection()voidRedo one undone selection change.
(Inherited from Doc)
refresh()voidRefreshes the editor display.
removeKeyMap(map)voidRemoves a key map from the editor.
removeLine(n)voidRemove the given line from the document.
(Inherited from Doc)
removeLineClass(line, where, className?)Cm5LineHandleRemove a CSS class from a line.
removeLineWidget(widget)voidRemoves a line widget.
removeOverlay(mode)voidRemoves a mode overlay from the editor.
replaceRange(replacement, from, to?, origin?)voidReplaces the range between the given points with the given string.
(Inherited from Doc)
replaceSelection(replacement, select?)voidReplaces the current selection with the given string.
(Inherited from Doc)
replaceSelections(replacements, collapse?, origin?)voidReplaces the content of the selections with the given strings.
scrollIntoView(pos, margin?)voidScrolls the editor to the given position.
scrollTo(x?, y?)voidScrolls the editor to the given coordinates.
setBookmark(pos, options?)TextMarkerInserts a bookmark at the given position.
(Inherited from Doc)
setCursor(pos, ch?, options?)voidSets the cursor position.
(Inherited from Doc)
setExtending(value)voidSets or clears the 'extending' flag.
setGutterMarker(line, gutterID, value)Cm5LineHandleSets the gutter marker for the given gutter.
setHistory(history)voidReplace the editor's undo history.
(Inherited from Doc)
setLine(n, text)voidSet the content of a given line.
(Inherited from Doc)
setOption(option, value)voidSets the value of an option.
setSelection(anchor, head?, options?)voidSets the selection range.
(Inherited from Doc)
setSelections(ranges, primary?, options?)voidSets a new set of selections.
setSize(width, height)voidSets the editor size.
setValue(content)voidSets the editor content.
(Inherited from Doc)
somethingSelected()booleanTells whether the editor currently has a selection.
(Inherited from Doc)
startOperation()voidStarts a buffered operation.
swapDoc(doc)DocAttaches a new document to the editor.
toggleOverwrite(value?)voidSwitches between overwrite and normal insert mode.
undo()voidUndoes the last edit.
(Inherited from Doc)
undoSelection()voidUndo one selection change.
(Inherited from Doc)
unlinkDoc(doc)voidBreak the link between two documents.
(Inherited from Doc)

Links to this page: