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): null | ICoordinate;
    getCursorPosition(): IPosition;
    getLine(line): undefined | string;
    getOffsetAt(position): number;
    getOption(option): unknown;
    getPositionAt(offset): undefined | IPosition;
    getPositionForCoordinate(coordinate): null | IPosition;
    getSelection(): IRange;
    getSelections(): IRange[];
    getTokenAt(offset): CodeEditor.IToken;
    getTokenAtCursor(): CodeEditor.IToken;
    getTokens(): CodeEditor.IToken[];
    hasFocus(): boolean;
    injectExtension(ext): void;
    newIndentedLine(): void;
    redo(): void;
    replaceSelection?(text): void;
    revealPosition(position): void;
    revealSelection(selection): void;
    setCursorPosition(position, options?): void;
    setOption(option, value): void;
    setOptions(options): void;
    setSelection(selection): void;
    setSelections(selections): void;
    undo(): void;

Hierarchy (view full)

Implemented by


    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.


    • 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.

      Undefined Behavior

      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.


      • 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 an offset for the given position.


      • position: IPosition

        The position of interest.

      Returns number

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

    • Find a position for the given offset.


      • offset: number

        The offset of interest.

      Returns undefined | IPosition

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