1 | import * as React from 'react';
|
2 | import * as codemirror from 'codemirror';
|
3 | export interface IDefineModeOptions {
|
4 | fn: () => codemirror.Mode<any>;
|
5 | name: string;
|
6 | }
|
7 | export interface ISetScrollOptions {
|
8 | x?: number | null;
|
9 | y?: number | null;
|
10 | }
|
11 | export interface ISetSelectionOptions {
|
12 | anchor: codemirror.Position;
|
13 | head: codemirror.Position;
|
14 | }
|
15 | export interface DomEvent {
|
16 | (editor: codemirror.Editor, event?: any): void;
|
17 | }
|
18 | export interface KeyHandledEvent {
|
19 | (editor: codemirror.Editor, name: string, event: any): void;
|
20 | }
|
21 | export interface EditorChangeEvent {
|
22 | (editor: codemirror.Editor, changeObj: codemirror.EditorChange): void;
|
23 | }
|
24 | export interface ICodeMirror {
|
25 | autoCursor?: boolean;
|
26 | autoScroll?: boolean;
|
27 | className?: string;
|
28 | cursor?: codemirror.Position;
|
29 | defineMode?: IDefineModeOptions;
|
30 | editorDidConfigure?: (editor: codemirror.Editor) => void;
|
31 | editorDidMount?: (editor: codemirror.Editor, value: string, cb: () => void) => void;
|
32 | editorWillUnmount?: (lib: any) => void;
|
33 | onBlur?: DomEvent;
|
34 | onChange?: (editor: codemirror.Editor, data: codemirror.EditorChange, value: string) => void;
|
35 | onContextMenu?: DomEvent;
|
36 | onCopy?: DomEvent;
|
37 | onCursor?: (editor: codemirror.Editor, data: codemirror.Position) => void;
|
38 | onCut?: DomEvent;
|
39 | onCursorActivity?: (editor: codemirror.Editor) => void;
|
40 | onDblClick?: DomEvent;
|
41 | onDragEnter?: DomEvent;
|
42 | onDragLeave?: DomEvent;
|
43 | onDragOver?: DomEvent;
|
44 | onDragStart?: DomEvent;
|
45 | onDrop?: DomEvent;
|
46 | onFocus?: DomEvent;
|
47 | onGutterClick?: (editor: codemirror.Editor, lineNumber: number, gutter: string, event: Event) => void;
|
48 | onInputRead?: EditorChangeEvent;
|
49 | onKeyDown?: DomEvent;
|
50 | onKeyHandled?: KeyHandledEvent;
|
51 | onKeyPress?: DomEvent;
|
52 | onKeyUp?: DomEvent;
|
53 | onMouseDown?: DomEvent;
|
54 | onPaste?: DomEvent;
|
55 | onRenderLine?: (editor: codemirror.Editor, line: codemirror.LineHandle, element: HTMLElement) => void;
|
56 | onScroll?: (editor: codemirror.Editor, data: codemirror.ScrollInfo) => void;
|
57 | onSelection?: (editor: codemirror.Editor, data: any) => void;
|
58 | onTouchStart?: DomEvent;
|
59 | onUpdate?: (editor: codemirror.Editor) => void;
|
60 | onViewportChange?: (editor: codemirror.Editor, start: number, end: number) => void;
|
61 | options?: codemirror.EditorConfiguration;
|
62 | selection?: {
|
63 | ranges: Array<ISetSelectionOptions>;
|
64 | focus?: boolean;
|
65 | };
|
66 | scroll?: ISetScrollOptions;
|
67 | }
|
68 | export interface IControlledCodeMirror extends ICodeMirror {
|
69 | onBeforeChange: (editor: codemirror.Editor, data: codemirror.EditorChange, value: string) => void;
|
70 | value: string;
|
71 | }
|
72 | export interface IUnControlledCodeMirror extends ICodeMirror {
|
73 | detach?: boolean;
|
74 | editorDidAttach?: (editor: codemirror.Editor) => void;
|
75 | editorDidDetach?: (editor: codemirror.Editor) => void;
|
76 | onBeforeChange?: (editor: codemirror.Editor, data: codemirror.EditorChange, value: string, next: () => void) => void;
|
77 | value?: string;
|
78 | }
|
79 | export declare class Controlled extends React.Component<IControlledCodeMirror, any> {
|
80 | }
|
81 | export declare class UnControlled extends React.Component<IUnControlledCodeMirror, any> {
|
82 | }
|