import { EditorSelection, ChangeDesc, Extension } from '@codemirror/state'; import { StringStream } from '@codemirror/language'; import { EditorView, ViewUpdate } from '@codemirror/view'; import { SearchQuery } from '@codemirror/search'; interface CM5Range { anchor: Pos; head: Pos; } interface Pos { line: number; ch: number; } declare class Pos { constructor(line: number, ch: number); } declare function on(emitter: any, type: string, f: Function): void; declare function off(emitter: any, type: string, f: Function): void; declare function signal(emitter: any, type: string, ...args: any[]): void; interface Operation { $d: number; isVimOp?: boolean; cursorActivityHandlers?: Function[]; cursorActivity?: boolean; lastChange?: any; change?: any; changeHandlers?: Function[]; $changeStart?: number; } declare class CodeMirror { static isMac: boolean; static Pos: typeof Pos; static StringStream: typeof StringStream; static commands: { cursorCharLeft: (cm: CodeMirror) => void; redo: (cm: CodeMirror) => void; undo: (cm: CodeMirror) => void; newlineAndIndent: (cm: CodeMirror) => void; indentAuto: (cm: CodeMirror) => void; }; static defineOption: (name: string, val: any, setter: Function) => void; static isWordChar: (ch: string) => boolean; static keys: any; static keyMap: {}; static addClass: () => void; static rmClass: () => void; static e_preventDefault: (e: Event) => void; static e_stop: (e: Event) => void; static keyName: (e: KeyboardEvent) => string | undefined; static vimKey: (e: KeyboardEvent) => string | undefined; static lookupKey: (key: string, map: string, handle: Function) => void; static on: typeof on; static off: typeof off; static signal: typeof signal; openDialog(template: Element, callback: Function, options: any): (newVal?: string | undefined) => void; openNotification(template: Node, options: NotificationOptions): () => void; static findMatchingTag: typeof findMatchingTag; static findEnclosingTag: typeof findEnclosingTag; cm6: EditorView; state: { statusbar?: Element | null; dialog?: Element | null; vimPlugin?: any; vim?: any; currentNotificationClose?: Function | null; keyMap?: string; overwrite?: boolean; }; marks: Record; $mid: number; curOp: Operation | null | undefined; options: any; _handlers: any; constructor(cm6: EditorView); on(type: string, f: Function): void; off(type: string, f: Function): void; signal(type: string, e: any, handlers?: any): void; indexFromPos(pos: Pos): number; posFromIndex(offset: number): Pos; foldCode(pos: Pos): void; firstLine(): number; lastLine(): number; lineCount(): number; setCursor(line: Pos | number, ch: number): void; getCursor(p?: "head" | "anchor" | "start" | "end"): Pos; listSelections(): { anchor: Pos; head: Pos; }[]; setSelections(p: CM5Range[], primIndex?: number): void; setSelection(anchor: Pos, head: Pos, options?: any): void; getLine(row: number): string; getLineHandle(row: number): { row: number; index: number; }; getLineNumber(handle: any): number | null; releaseLineHandles(): void; getRange(s: Pos, e: Pos): string; replaceRange(text: string, s: Pos, e: Pos): void; replaceSelection(text: string): void; replaceSelections(replacements: string[]): void; getSelection(): string; getSelections(): string[]; somethingSelected(): boolean; getInputField(): HTMLElement; clipPos(p: Pos): Pos; getValue(): string; setValue(text: string): void; focus(): void; blur(): void; defaultTextHeight(): number; findMatchingBracket(pos: Pos): { to: Pos; } | { to: undefined; }; scanForBracket(pos: Pos, dir: 1 | -1, style: any, config: any): false | { pos: Pos; ch: string; } | null; indentLine(line: number, more: boolean): void; indentMore(): void; indentLess(): void; execCommand(name: string): void; setBookmark(cursor: Pos, options?: { insertLeft: boolean; }): Marker; cm6Query?: SearchQuery; addOverlay({ query }: { query: RegExp; }): SearchQuery | undefined; removeOverlay(overlay?: any): void; getSearchCursor(query: RegExp, pos: Pos): { findNext: () => string[] | null | undefined; findPrevious: () => string[] | null | undefined; find: (back?: boolean) => string[] | null | undefined; from: () => Pos | undefined; to: () => Pos | undefined; replace: (text: string) => void; }; findPosV(start: Pos, amount: number, unit: "page" | "line", goalColumn?: number): Pos & { hitSide: boolean; }; charCoords(pos: Pos, mode: "div" | "local"): { left: number; top: number; bottom: number; }; coordsChar(coords: { left: number; top: number; }, mode: "div" | "local"): Pos; getScrollInfo(): { left: number; top: number; height: number; width: number; clientHeight: number; clientWidth: number; }; scrollTo(x?: number, y?: number): void; scrollIntoView(pos?: Pos, margin?: number): void; getWrapperElement(): HTMLElement; getMode(): { name: string | number | boolean | undefined; }; setSize(w: number, h: number): void; refresh(): void; destroy(): void; getLastEditEnd(): Pos; $lastChangeEndOffset: number; $lineHandleChanges: undefined | ViewUpdate[]; onChange(update: ViewUpdate): void; onSelectionChange(): void; operation(fn: Function): any; onBeforeEndOperation(): void; moveH(increment: number, unit: string): void; setOption(name: string, val: any): void; getOption(name: string): string | number | boolean | undefined; toggleOverwrite(on: boolean): void; getTokenTypeAt(pos: Pos): "" | "string" | "comment"; overWriteSelection(text: string): void; /*** multiselect ****/ isInMultiSelectMode(): boolean; virtualSelectionMode(): boolean; virtualSelection: EditorSelection | null; forEachSelection(command: Function): void; } interface NotificationOptions { bottom?: boolean; duration?: number; } declare function findMatchingTag(cm: CodeMirror, pos: Pos): void; declare function findEnclosingTag(cm: CodeMirror, pos: Pos): { open: { from: Pos; to: Pos; }; close: { from: Pos; to: Pos; }; } | undefined; declare class Marker { cm: CodeMirror; id: number; offset: number | null; assoc: number; constructor(cm: CodeMirror, offset: number, assoc: number); clear(): void; find(): Pos | null; update(change: ChangeDesc): void; } declare const Vim: any; declare function vim(options?: { status?: boolean; }): Extension; declare function getCM(view: EditorView): CodeMirror | null; export { CodeMirror, Vim, getCM, vim };