Skip to content

EditorView

Unofficial

Import:

import type { EditorView } from '@codemirror/view';

Signature:

export interface EditorView

Properties

PropertyTypeDescription
cm?CodeMirrorEditorThe CodeMirror 5 compatible adapter wrapping this view, through which the Vim layer drives it. Only present once Vim mode has been enabled.
viewStateEditorViewStateInternal view state tracking properties like printing mode.

Methods

MethodReturnsDescription
bidiSpans(line)readonly BidiSpan[]Returns the bidirectional text structure of the given line.
coordsAtPos(pos, side?)null | RectGet the screen coordinates at the given document position.
coordsForChar(pos)null | RectReturn the rectangle around a given character.
destroy()voidClean up this editor view.
dispatch(tr)voidAll regular editor state updates should go through this.
dispatch(trs)voidDispatch an array of transactions.
dispatch(specs?)voidDispatch one or more transaction specs.
domAtPos(pos)EditorViewDomPositionFind the DOM parent node and offset at the given document position.
elementAtHeight(height)BlockInfoFind the text line or block widget at the given vertical position.
focus()voidPut focus on the editor.
lineBlockAt(pos)BlockInfoFind the line block around the given document position.
lineBlockAtHeight(height)BlockInfoFind the line block at the given height.
measure()voidRequest a layout measurement pass on the editor.
moveByChar(start, forward, by?)SelectionRangeMove a cursor position by grapheme cluster.
moveByGroup(start, forward)SelectionRangeMove a cursor position across the next group of letters or non-letter non-whitespace characters.
moveToLineBoundary(start, forward, includeWrap?)SelectionRangeMove to the next line boundary in the given direction.
moveVertically(start, forward, distance?)SelectionRangeMove a cursor position vertically.
plugin(plugin)null | TGet the value of a specific plugin, if present.
posAtCoords(coords)null | numberGet the document position at the given screen coordinates. Returns null if not found.
posAtCoords(coords, precise)numberGet the document position at the given screen coordinates with imprecise mode.
posAtDOM(node, offset?)numberFind the document position at the given DOM node.
requestMeasure(request?)voidSchedule a layout measurement, optionally providing callbacks to do custom DOM measuring followed by a DOM write phase.
scrollSnapshot()StateEffect<unknown>Return an effect that resets the editor to its current scroll position.
setRoot(root)voidUpdate the root in which the editor lives.
setState(newState)voidReset the view to the given state.
setTabFocusMode(to?)voidEnable or disable tab-focus mode.
textDirectionAt(pos)DirectionFind the text direction of the block at the given position.
update(transactions)voidUpdate the view for the given array of transactions.
visualLineSide(line, end)SelectionRangeGet the cursor position visually at the start or end of a line.

Links to this page: