Skip to content

Editor

new Editor(container, options?): Editor

HTMLElement

EditorOptions

Editor

addPlugin(plugin): EditorDisposable

EditorPlugin

EditorDisposable


applyEdit(edit, tokens, textSnapshot): void

textSnapshot is the text after edit; a detached view renders it. On a buffer session the edit goes through the session, which supplies its own.

TextEdit

EditorTokenInput

TextSnapshot

void


attachSession(session, options?): void

DocumentSession

EditorSessionOptions

void


authorEdits(author): EditorDisposable

DocumentEditAuthor

EditorDisposable


captureSnapshot(options): DocumentPaintCapture

"document"

DocumentPaintCapture

captureSnapshot(options?): any

"viewport"

any


clear(): void

void


clearDocument(): void

void


closeFind(): boolean

boolean


cursorRedo(): boolean

boolean


cursorUndo(): boolean

Returns the carets, and the view, to where they were before the last caret move.

boolean


detachSession(): void

void


dispatchCommand(command, context?): boolean

EditorAnyCommandId

EditorCommandContext

boolean


dispose(): void

void


edit(editOrEdits, options?): void

EditorEditInput

DocumentSessionApplyEditsOptions

void


findNext(): boolean

boolean


findPrevious(): boolean

boolean


focus(): void

void


fold(offset?): boolean

number

boolean


foldAll(): boolean

boolean


getBufferSession(): EditorBufferSession | null

EditorBufferSession | null


getCommandIds(): readonly EditorAnyCommandId[]

The commands this editor knows: every built-in, then those its plugins contribute. The built-ins’ titles are in EDITOR_COMMANDS from @singapore-editor/core/keymap, which only a palette or shortcut UI needs to load.

readonly EditorAnyCommandId[]


getContentHeight(): number

number


getContributedCommandDeclarations(): readonly EditorContributedCommandDeclaration[]

The commands this editor’s plugins contribute, with their titles.

readonly EditorContributedCommandDeclaration[]


getFeature<T>(token): T | null

A capability a plugin registered on this editor, such as spellcheck; null while none has.

T

EditorCapabilityToken<T>

T | null


getHotkeysHost(): EditorHotkeysHost

The dispatcher and focus node that own this editor’s keyboard commands.

EditorHotkeysHost


getInputElement(): HTMLElement

HTMLElement


getKeymapContext(): EditorKeymapContext

EditorKeymapContext


getPresentationState(): "provisional" | "live" | "empty"

"provisional" | "live" | "empty"


getScrollPosition(): Required<EditorScrollPosition>

Required<EditorScrollPosition>


getSelections(): readonly EditorResolvedSelection[]

Every selection as document offsets, primary first.

readonly EditorResolvedSelection[]


getState(): EditorState

EditorState


getSyntaxRecords(): EditorSyntaxRecords | null

Parsed records for this exact text revision; absent while analysis catches up.

EditorSyntaxRecords | null


getTextSnapshot(): TextSnapshot

TextSnapshot


isTabMovesFocusEnabled(): boolean

boolean


isWordWrapEnabled(): boolean

boolean


jumpBack(): boolean

boolean


jumpForward(): boolean

boolean


jumpTo(anchor, head?, cause?): void

number

number

JumpCause

void


markerAtPoint(clientX, clientY): EditorMarkerHit | null

number

number

EditorMarkerHit | null


materializeFullText(): string

O(document length) on every call, never cached; save and export are what it is for.

string


onDidChangeContentHeight(listener): EditorDisposable

Called with the rows’ total height in pixels whenever it changes: lines added or removed, wrap reflowing, the font changing. A host that grows with its text sizes itself from this.

(height) => void

EditorDisposable


onDidScroll(listener): EditorDisposable

Called when the editor’s own scroll position changes, including after a programmatic move or clamp. View contributions receive the visible viewport when an outside ancestor scrolls.

(position) => void

EditorDisposable


onDidTransaction(listener): EditorDisposable

Each logical edit, before view updates can coalesce it. The registration survives document swaps.

(event) => void

EditorDisposable


openDocument(document): void

EditorOpenDocumentOptions

void


openFind(): boolean

boolean


openFindReplace(): boolean

boolean


reconcile(base, batches, options): void

PieceTableTreeSnapshot

readonly readonly TextEdit[][]

DocumentSessionReconcileOptions

void


registerKeymapNode(options): object

EditorKeymapNodeOptions

object

dispose: () => void

void


removePlugin(plugin): boolean

EditorPlugin

boolean


replaceAll(): boolean

boolean


replaceOne(): boolean

boolean


rowAtPoint(clientX, clientY): EditorPointHit | null

number

number

EditorPointHit | null


runInOperation<T>(run): T

Runs run as a single mutating pass. Whatever it changes, the caret is revealed once, the DOM selection is written back once and listeners hear once, at the end — so a sequence of edits costs one visual update instead of one each. Calls made from inside a pass join it rather than opening another.

T

() => T

T


selectAllMatches(): boolean

boolean


setContent(text): void

On a buffer session this replaces the buffer’s text as one undoable edit every view sees.

string

void


setDetectIndentation(enabled): void

boolean

void


setDocument(document): void

EditorDocument

void


setEditability(editability): void

EditorEditability

void


setFolding(enabled): void

boolean

void


setFoldMap(foldMap): void

FoldMap | null

void


setFontFamily(fontFamily): void

A CSS font-family list; undefined hands the face back to the stylesheet.

string | undefined

void


setFontSize(fontSize): void

Undefined hands the size back to the stylesheet.

number | undefined

void


setGutterLeadingInset(inset): void

Empty pixels before the first gutter lane; row decorations tint them. 0 removes the inset.

number

void


setGutterScroll(mode): void

Switch all gutter lanes between the viewport edge and the horizontally scrolling text.

NonNullable<EditorGutterScroll | undefined>

void


setHeight(height, maxHeight?): void

EditorHeight

number

void


setHiddenCharacters(mode): void

HiddenCharactersMode

void


setInlineMap(inlineMap): void

Installs the inline replacements this document renders instead of parts of its own text — the entry point a markdown live-preview view drives. Passing null restores raw buffer text.

InlineMap | null

void


setInlineReplacementProvider(provider, options?): void

Registers a provider that turns the document’s syntax captures into inline replacements. The map is rebuilt whenever fresh captures land, so a markdown view stays in step with the parse without the host scheduling anything itself. Passing null removes the transform.

EditorInlineReplacementProvider | null

EditorInlineReplacementProviderOptions

void


setInlineSuggestion(edit): boolean

Offers an inline suggestion, drawn in front of the reader as the part of it the document does not already hold. Passing null takes back whatever is showing.

TextEdit | null

boolean


setKeymap(keymap): void

EditorKeymapOptions | undefined

void


setLineHeight(lineHeight): void

number

void


setPlugins(plugins): void

readonly EditorPlugin[]

void


setPresentationReady(ready): void

boolean

void


setRangeDecorations(decorations): void

readonly EditorRangeDecoration[]

void


setRowDecorations(decorations): void

ReadonlyMap<number, VirtualizedTextRowDecoration>

void


setRowGap(rowGap): void

number

void


setScrollMode(scrollMode): void

VirtualizedTextViewScrollMode | undefined

void


setScrollPosition(scrollPosition): void

EditorScrollPosition

void


setSelection(anchor, head?, options?): void

number

number

EditorSetSelectionOptions

void


setSnapshot(snapshot, documentKey): void

string | null

string | null

void


setSuspiciousCharacters(options): void

EditorSuspiciousCharactersOptions | undefined

void


setSyntaxFolds(folds): void

readonly FoldRange[]

void


setTabMovesFocus(enabled): boolean

Gives Tab back to the page, or takes it for indentation again. Returns the state in effect afterwards. Nothing is announced from here: a host writing its own controls says what it did in its own words, and the key that toggles this from inside the editor speaks for itself.

boolean

boolean


setTabSize(tabSize): void

Columns a tab spans, and the fallback the open document’s indentation is guessed against, so a document that gave no sign of its own follows the new width. Undefined is the default, 4.

number | undefined

void


setText(text, options?): void

string

EditorSetTextOptions

void


setTheme(theme): void

EditorTheme | null | undefined

void


setTokens(tokens): void

EditorTokenInput

void


setWordWrap(enabled): boolean

Turns soft wrap on or off. Returns the state actually in effect afterwards.

boolean

boolean


syncText(text, options?): void

string

EditorSetTextOptions

void


textOffsetFromPoint(clientX, clientY): number | null

number

number

number | null


toggleFold(offset?): boolean

number

boolean


unfold(offset?): boolean

number

boolean


unfoldAll(): boolean

boolean