A widget that provides a code editor.

As of JupyterLab 4.0.0, it is not possible to provide an editor that is different of CodeMirror 6.

interface IEditor {
    charWidth: number;
    edgeRequested: ISignal<CodeEditor.IEditor, EdgeLocation>;
    host: HTMLElement;
    isDisposed: boolean;
    lineCount: number;
    lineHeight: number;
    model: CodeEditor.IModel;
    uuid: string;
    blur(): void;
    clearHistory(): void;
    dispose(): void;
    focus(): void;
    getCoordinateForPosition(position: IPosition): null | ICoordinate;
    getCursorPosition(): IPosition;
    getLine(line: number): undefined | string;
    getOffsetAt(position: IPosition): number;
    getOption(option: string): unknown;
    getPositionAt(offset: number): undefined | IPosition;
    getPositionForCoordinate(coordinate: ICoordinate): null | IPosition;
    getSelection(): IRange;
    getSelections(): IRange[];
    getTokenAt(offset: number): CodeEditor.IToken;
    getTokenAtCursor(): CodeEditor.IToken;
    getTokens(): CodeEditor.IToken[];
    hasFocus(): boolean;
    injectExtension(ext: Extension): void;
    newIndentedLine(): void;
    redo(): void;
    replaceSelection(text: string): void;
    revealPosition(position: IPosition): void;
    revealSelection(selection: IRange): void;
    setBaseOptions(options: Record<string, any>): void;
    setCursorPosition(
        position: IPosition,
        options?: { scroll?: boolean },
    ): void;
    setOption(option: string, value: unknown): void;
    setOptions(options: Record<string, any>): void;
    setSelection(selection: IRange): void;
    setSelections(selections: IRange[]): void;
    undo(): void;
}

Hierarchy (View Summary)

Implemented by

Properties

charWidth: number

The widget of a character in the editor in pixels.

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

The DOM node that hosts the editor.

isDisposed: boolean

Test whether the object has been disposed.

This property is always safe to access.

lineCount: number

Get the number of lines in the editor.

lineHeight: number

The height of a line in the editor in pixels.

The model used by the editor.

uuid: string

The uuid of this selection owner.

Methods

  • Dispose of the resources held by the object.

    If the object's dispose method is called more than once, all calls made after the first will be a no-op.

    It is undefined behavior to use any functionality of the object after it has been disposed unless otherwise explicitly noted.

    Returns void

  • Returns the content for the given line number.

    Parameters

    • line: number

      The line of interest.

    Returns undefined | string

    The value of the line.

    Lines are 0-based, and accessing a line out of range returns undefined.

  • Find a position for the given offset.

    Parameters

    • offset: number

      The offset of interest.

    Returns undefined | IPosition

    The position at the offset, clamped to the extent of the editor contents.