Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CodeMirrorEditor

CodeMirror editor.

Hierarchy

  • CodeMirrorEditor

Implements

  • IEditor

Index

Constructors

constructor

  • Construct a CodeMirror editor.

    Parameters

    Returns CodeMirrorEditor

Properties

Private _beforeDocChanged

_beforeDocChanged: any

Handles document changes.

Private _caretHover

_caretHover: any

Private _changeGuard

_changeGuard: any

Private _checkSync

_checkSync: any

Check for an out of sync editor.

Private _cleanSelections

_cleanSelections: any

Clean selections for the given uuid.

Private _clearHover

_clearHover: any

Clear the hover for a caret, due to things like scrolling, resizing, deactivation, etc, where the position is no longer valid.

Private Readonly _config

_config: any

Private _editor

_editor: any

Private _evtBlur

_evtBlur: any

Handle blur events for the editor.

Private _evtFocus

_evtFocus: any

Handle focus events for the editor.

Private _evtScroll

_evtScroll: any

Handle scroll events for the editor.

Private _getCaret

_getCaret: any

Construct a caret element representing the position of a collaborator's cursor.

Private _hoverId

_hoverId: any

Private _hoverTimeout

_hoverTimeout: any

Private _initializeEditorBinding

_initializeEditorBinding: any

Initialize the editor binding.

Private _isDisposed

_isDisposed: any

Private _keydownHandlers

_keydownHandlers: any

Private _lastChange

_lastChange: any

Private _markSelections

_markSelections: any

Marks selections.

Private _model

_model: any

Private _needsRefresh

_needsRefresh: any

Private _onCursorActivity

_onCursorActivity: any

Handles a cursor activity event.

Private _onMimeTypeChanged

_onMimeTypeChanged: any

Handles a mime type change.

Private _onSelectionsChanged

_onSelectionsChanged: any

Handles a selections change.

Private _onValueChanged

_onValueChanged: any

Handle model value changes.

Private _poll

_poll: any

Private _selectionStyle

_selectionStyle: any

Private _toCodeMirrorPosition

_toCodeMirrorPosition: any

Convert an editor position to a code mirror position.

Private _toCodeMirrorSelection

_toCodeMirrorSelection: any

Converts an editor selection to a code mirror selection.

Private _toCodeMirrorSelections

_toCodeMirrorSelections: any

Converts selections to code mirror selections.

Private _toPosition

_toPosition: any

Convert a code mirror position to an editor position.

Private _toSelection

_toSelection: any

Converts a code mirror selection to an editor selection.

Private _toTextMarkerOptions

_toTextMarkerOptions: any

Converts the selection style to a text marker options.

Private _trans

_trans: any

Private _uuid

_uuid: any

Private _yeditorBinding

_yeditorBinding: any

Readonly edgeRequested

edgeRequested: Signal<CodeMirrorEditor, EdgeLocation>

A signal emitted when either the top or bottom edge is requested.

Readonly host

host: HTMLElement

The DOM node that hosts the editor.

Protected selectionMarkers

selectionMarkers: {}

Type declaration

  • [key: string]: CodeMirror.TextMarker[] | undefined

Protected translator

translator: ITranslator

Accessors

charWidth

  • get charWidth(): number
  • The widget of a character in the editor in pixels.

    Returns number

doc

  • get doc(): Doc
  • Get the codemirror doc wrapped by the widget.

    Returns Doc

editor

  • get editor(): Editor
  • Get the codemirror editor wrapped by the editor.

    Returns Editor

isDisposed

  • get isDisposed(): boolean
  • Tests whether the editor is disposed.

    Returns boolean

lineCount

  • get lineCount(): number
  • Get the number of lines in the editor.

    Returns number

lineHeight

  • get lineHeight(): number
  • The height of a line in the editor in pixels.

    Returns number

model

  • get model(): IModel
  • Returns a model for this editor.

    Returns IModel

selectionStyle

  • get selectionStyle(): ISelectionStyle
  • set selectionStyle(value: ISelectionStyle): void
  • The selection style of this editor.

    Returns ISelectionStyle

  • The selection style of this editor.

    Parameters

    • value: ISelectionStyle

    Returns void

state

  • get state(): any
  • Returns any

uuid

  • get uuid(): string
  • set uuid(value: string): void
  • The uuid of this editor;

    Returns string

  • The uuid of this editor;

    Parameters

    • value: string

    Returns void

Methods

addKeydownHandler

  • addKeydownHandler(handler: KeydownHandler): IDisposable
  • Add a keydown handler to the editor.

    Parameters

    • handler: KeydownHandler

      A keydown handler.

    Returns IDisposable

    A disposable that can be used to remove the handler.

addOverlay

  • addOverlay(mode: string | object, options?: object): void
  • Parameters

    • mode: string | object
    • Optional options: object

    Returns void

blur

  • blur(): void
  • Explicitly blur the editor.

    Returns void

clearHistory

  • clearHistory(): void
  • Clear the undo history.

    Returns void

cursorCoords

  • cursorCoords(where: boolean, mode?: "window" | "page" | "local"): { bottom: number; left: number; top: number }
  • Parameters

    • where: boolean
    • Optional mode: "window" | "page" | "local"

    Returns { bottom: number; left: number; top: number }

    • bottom: number
    • left: number
    • top: number

dispose

  • dispose(): void
  • Dispose of the resources held by the widget.

    Returns void

execCommand

  • execCommand(command: string): void
  • Execute a codemirror command on the editor.

    Parameters

    • command: string

      The name of the command to execute.

    Returns void

firstLine

  • firstLine(): number
  • Returns number

focus

  • focus(): void
  • Brings browser focus to this editor text.

    Returns void

getCoordinateForPosition

  • getCoordinateForPosition(position: IPosition): ICoordinate
  • Get the window coordinates given a cursor position.

    Parameters

    • position: IPosition

    Returns ICoordinate

getCursor

  • getCursor(start?: string): Position
  • Parameters

    • Optional start: string

    Returns Position

getCursorPosition

  • getCursorPosition(): IPosition
  • Returns the primary position of the cursor, never null.

    Returns IPosition

getLine

  • getLine(line: number): string
  • Returns the content for the given line number.

    Parameters

    • line: number

    Returns string

getOffsetAt

  • getOffsetAt(position: IPosition): number
  • Find an offset for the given position.

    Parameters

    • position: IPosition

    Returns number

getOption

  • getOption<K>(option: K): IConfig[K]
  • Get a config option for the editor.

    Type parameters

    • K: "cursorBlinkRate" | "fontFamily" | "fontSize" | "lineHeight" | "lineNumbers" | "lineWrap" | "readOnly" | "tabSize" | "insertSpaces" | "matchBrackets" | "autoClosingBrackets" | "handlePaste" | "wordWrapColumn" | "rulers" | "codeFolding" | "mode" | "theme" | "smartIndent" | "electricChars" | "keyMap" | "extraKeys" | "gutters" | "fixedGutter" | "foldGutter" | "showCursorWhenSelecting" | "coverGutterNextToScrollbar" | "dragDrop" | "lineSeparator" | "scrollbarStyle" | "lineWiseCopyCut" | "scrollPastEnd" | "styleActiveLine" | "styleSelectedText" | "selectionPointer"

    Parameters

    • option: K

    Returns IConfig[K]

getPositionAt

  • getPositionAt(offset: number): IPosition
  • Find a position for the given offset.

    Parameters

    • offset: number

    Returns IPosition

getPositionForCoordinate

  • getPositionForCoordinate(coordinate: ICoordinate): IPosition
  • Get the cursor position given window coordinates.

    Parameters

    • coordinate: ICoordinate

      The desired coordinate.

    Returns IPosition

    The position of the coordinates, or null if not contained in the editor.

getRange

  • getRange(from: Position, to: Position, separator?: string): string
  • Parameters

    • from: Position
    • to: Position
    • Optional separator: string

    Returns string

getSearchCursor

  • getSearchCursor(query: string | RegExp, start?: Position, caseFold?: boolean): SearchCursor
  • Parameters

    • query: string | RegExp
    • Optional start: Position
    • Optional caseFold: boolean

    Returns SearchCursor

getSelection

  • getSelection(): ITextSelection
  • Returns the primary selection, never null.

    Returns ITextSelection

getSelections

  • getSelections(): ITextSelection[]
  • Gets the selections for all the cursors, never null or empty.

    Returns ITextSelection[]

getTokenForPosition

  • getTokenForPosition(position: IPosition): IToken
  • Get the token at a given editor position.

    Parameters

    • position: IPosition

    Returns IToken

getTokens

  • getTokens(): IToken[]
  • Get a list of tokens for the current editor text content.

    Returns IToken[]

handleEvent

  • handleEvent(event: Event): void
  • Handle the DOM events for the editor.

    Parameters

    • event: Event

      The DOM event sent to the editor.

      Notes

      This method implements the DOM EventListener interface and is called in response to events on the editor's DOM node. It should not be called directly by user code.

    Returns void

hasFocus

  • hasFocus(): boolean
  • Test whether the editor has keyboard focus.

    Returns boolean

lastLine

  • lastLine(): number
  • Returns number

newIndentedLine

  • newIndentedLine(): void
  • Insert a new indented line at the current cursor position.

    Returns void

Protected onKeydown

  • onKeydown(event: KeyboardEvent): boolean
  • Handle keydown events from the editor.

    Parameters

    • event: KeyboardEvent

    Returns boolean

operation

  • operation<T>(fn: () => T): T
  • Type parameters

    • T

    Parameters

    • fn: () => T
        • (): T
        • Returns T

    Returns T

redo

  • redo(): void
  • Redo one undone edit.

    Returns void

refresh

  • refresh(): void
  • Repaint editor.

    Returns void

removeOverlay

  • removeOverlay(mode: string | object): void
  • Parameters

    • mode: string | object

    Returns void

replaceSelection

  • replaceSelection(text: string): void
  • Replaces the current selection with the given text.

    Parameters

    • text: string

      The text to be inserted.

    Returns void

resizeToFit

  • resizeToFit(): void
  • Refresh the editor if it is focused; otherwise postpone refreshing till focusing.

    Returns void

revealPosition

  • revealPosition(position: IPosition): void
  • Reveal the given position in the editor.

    Parameters

    • position: IPosition

    Returns void

revealSelection

  • revealSelection(selection: IRange): void
  • Reveal the given selection in the editor.

    Parameters

    • selection: IRange

    Returns void

scrollIntoView

  • scrollIntoView(pos: { from: Position; to: Position }, margin: number): void
  • Parameters

    • pos: { from: Position; to: Position }
      • from: Position
      • to: Position
    • margin: number

    Returns void

scrollIntoViewCentered

  • scrollIntoViewCentered(pos: Position): void
  • Parameters

    • pos: Position

    Returns void

setCursorPosition

  • setCursorPosition(position: IPosition, options?: { bias?: number; origin?: string; scroll?: boolean }): void
  • Set the primary position of the cursor.

    Notes

    This will remove any secondary cursors.

    Parameters

    • position: IPosition
    • Optional options: { bias?: number; origin?: string; scroll?: boolean }
      • Optional bias?: number
      • Optional origin?: string
      • Optional scroll?: boolean

    Returns void

setOption

  • setOption<K>(option: K, value: IConfig[K]): void
  • Set a config option for the editor.

    Type parameters

    • K: "cursorBlinkRate" | "fontFamily" | "fontSize" | "lineHeight" | "lineNumbers" | "lineWrap" | "readOnly" | "tabSize" | "insertSpaces" | "matchBrackets" | "autoClosingBrackets" | "handlePaste" | "wordWrapColumn" | "rulers" | "codeFolding" | "mode" | "theme" | "smartIndent" | "electricChars" | "keyMap" | "extraKeys" | "gutters" | "fixedGutter" | "foldGutter" | "showCursorWhenSelecting" | "coverGutterNextToScrollbar" | "dragDrop" | "lineSeparator" | "scrollbarStyle" | "lineWiseCopyCut" | "scrollPastEnd" | "styleActiveLine" | "styleSelectedText" | "selectionPointer"

    Parameters

    Returns void

setOptions

  • Set config options for the editor.

    This method is preferred when setting several options. The options are set within an operation, which only performs the costly update at the end, and not after every option is set.

    Type parameters

    • K: "cursorBlinkRate" | "fontFamily" | "fontSize" | "lineHeight" | "lineNumbers" | "lineWrap" | "readOnly" | "tabSize" | "insertSpaces" | "matchBrackets" | "autoClosingBrackets" | "handlePaste" | "wordWrapColumn" | "rulers" | "codeFolding" | "mode" | "theme" | "smartIndent" | "electricChars" | "keyMap" | "extraKeys" | "gutters" | "fixedGutter" | "foldGutter" | "showCursorWhenSelecting" | "coverGutterNextToScrollbar" | "dragDrop" | "lineSeparator" | "scrollbarStyle" | "lineWiseCopyCut" | "scrollPastEnd" | "styleActiveLine" | "styleSelectedText" | "selectionPointer"

    Parameters

    Returns void

setSelection

  • setSelection(selection: IRange): void
  • Set the primary selection. This will remove any secondary cursors.

    Parameters

    • selection: IRange

    Returns void

setSelections

  • setSelections(selections: IRange[]): void
  • Sets the selections for all the cursors, should not be empty. Cursors will be removed or added, as necessary. Passing an empty array resets a cursor position to the start of a document.

    Parameters

    • selections: IRange[]

    Returns void

setSize

  • setSize(dimension: IDimension): void
  • Set the size of the editor in pixels.

    Parameters

    • dimension: IDimension

    Returns void

undo

  • undo(): void
  • Undo one edit (if any undo events are stored).

    Returns void

Generated using TypeDoc