import { EditorSelection, SelectionRange } from '@codemirror/state'; import { EditorView } from 'codemirror'; type Extension = unknown; declare class EditorDocument { #private; /** * @hidden */ constructor(unkInner: unknown); /** * */ /** * * @returns the document as a string, using newline characters to separate lines. */ toString(): string; } declare class EditSession { #private; /** * @hidden */ constructor(unkInner: unknown); get document(): EditorDocument; get selection(): Selection; wordAt(pos: number): Range; } interface EditSessionConfig { value?: string | null; selection?: Selection | { anchor: number; head?: number; }; extensions?: Extension[]; } interface EditorConfig extends EditSessionConfig { parent?: Element | DocumentFragment | null; } declare function create_editor(config: EditorConfig): Editor; declare class Editor { #private; /** * @hidden */ constructor(unkInner: EditorView); get session(): EditSession; addRef(): void; dispatch(arg: { changes: { from: number; to?: number; insert?: string; }[]; }): void; focus(): void; insert(from: number, text: string): void; get hasFocus(): boolean; release(): void; select(ranges: readonly Range[], mainIndex?: number): void; /** * Sets the start and end positions of a selection in the editor. * @param start The offset into the editor for the start of the selection. * @param end The offset into the editor for the end of the selection. * @param direction The direction in which the selection is performed. */ setSelectionRange(start: number | null, end: number | null, direction?: "forward" | "backward" | "none"): void; get value(): string; set value(text: string); } interface StyleSpec { } declare function create_theme(spec: { [selector: string]: StyleSpec; }, options?: { dark?: boolean; }): Extension; declare function basic_extension(): Extension; declare function fixed_height_extension(height: string, dark?: boolean): Extension; /** * A reference-counted wrapper over the CodeMirror EditorSelection. */ declare class Selection { #private; /** * @hidden */ constructor(unkInner: EditorSelection); get ranges(): Range[]; addRef(): void; release(): void; } /** * A reference-counted wrapper over the CodeMirror SelectionRange. */ declare class Range { #private; /** * @hidden */ constructor(unkInner: SelectionRange); /** * The lower boundary of the range. */ get from(): number; /** * The upper boundary of the range. */ get to(): number; addRef(): void; release(): void; } declare function create_anchor_range(anchor: number, head: number, goalColumn?: number, bidiLevel?: number): Range; declare function create_cursor_range(pos: number, assoc?: number, bidiLevel?: number, goalColumn?: number): Range; /** * * @param ranges * @param mainIndex * @returns */ declare function create_selection(ranges: readonly Range[], mainIndex?: number): Selection; export { EditSession, type EditSessionConfig, Editor, type EditorConfig, EditorDocument, type Extension, Range, Selection, type StyleSpec, basic_extension, create_anchor_range, create_cursor_range, create_editor, create_selection, create_theme, fixed_height_extension };