1 | import '../../';
|
2 |
|
3 | declare module '../../' {
|
4 | |
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | function showHint(cm: Editor, hinter?: HintFunction, options?: ShowHintOptions): void;
|
13 |
|
14 | function on<T extends keyof CompletionEventMap>(hints: Hints, eventName: T, handler: CompletionEventMap[T]): void;
|
15 | function off<T extends keyof CompletionEventMap>(hints: Hints, eventName: T, handler: CompletionEventMap[T]): void;
|
16 | function signal<T extends keyof CompletionEventMap>(hints: Hints, eventName: T, ...args: Parameters<CompletionEventMap[T]>): void;
|
17 |
|
18 | interface CompletionEventMap {
|
19 | shown: () => void;
|
20 | select: (completion: Hint | string, element: Element) => void;
|
21 | pick: (completion: Hint | string) => void;
|
22 | close: () => void;
|
23 | }
|
24 |
|
25 | interface Hints {
|
26 | from: Position;
|
27 | to: Position;
|
28 | list: Array<Hint | string>;
|
29 | }
|
30 |
|
31 | |
32 |
|
33 |
|
34 |
|
35 | interface Hint {
|
36 | text: string;
|
37 | className?: string | undefined;
|
38 | displayText?: string | undefined;
|
39 | from?: Position | undefined;
|
40 |
|
41 | hint?: ((cm: Editor, data: Hints, cur: Hint) => void) | undefined;
|
42 | render?: ((element: HTMLLIElement, data: Hints, cur: Hint) => void) | undefined;
|
43 | to?: Position | undefined;
|
44 | }
|
45 |
|
46 | interface EditorEventMap {
|
47 | startCompletion: (instance: Editor) => void;
|
48 | endCompletion: (instance: Editor) => void;
|
49 | }
|
50 |
|
51 | interface Editor {
|
52 | showHint(options?: ShowHintOptions): void;
|
53 | closeHint(): void;
|
54 | }
|
55 |
|
56 | interface CommandActions {
|
57 |
|
58 | autocomplete: typeof showHint;
|
59 | }
|
60 |
|
61 | interface HintFunction {
|
62 | (cm: Editor, options: ShowHintOptions): Hints | null | undefined | PromiseLike<Hints | null | undefined>;
|
63 | }
|
64 |
|
65 | interface AsyncHintFunction {
|
66 | (cm: Editor, callback: (hints: Hints | null | undefined) => void, options: ShowHintOptions): void;
|
67 | async: true;
|
68 | }
|
69 |
|
70 | interface HintFunctionResolver {
|
71 | resolve(cm: Editor, post: Position): HintFunction | AsyncHintFunction;
|
72 | }
|
73 |
|
74 | interface ShowHintOptions {
|
75 | completeSingle?: boolean | undefined;
|
76 | hint?: HintFunction | AsyncHintFunction | HintFunctionResolver | undefined;
|
77 | alignWithWord?: boolean | undefined;
|
78 | closeCharacters?: RegExp | undefined;
|
79 | closeOnPick?: boolean | undefined;
|
80 | closeOnUnfocus?: boolean | undefined;
|
81 | updateOnCursorActivity?: boolean | undefined;
|
82 | completeOnSingleClick?: boolean | undefined;
|
83 | container?: HTMLElement | null | undefined;
|
84 | customKeys?: { [key: string]: ((editor: Editor, handle: CompletionHandle) => void) | string } | null | undefined;
|
85 | extraKeys?: { [key: string]: ((editor: Editor, handle: CompletionHandle) => void) | string } | null | undefined;
|
86 | scrollMargin?: number | undefined;
|
87 | paddingForScrollbar?: boolean | undefined;
|
88 | moveOnOverlap?: boolean | undefined;
|
89 | words?: ReadonlyArray<string> | undefined; // used by fromList
|
90 | }
|
91 |
|
92 | /** The Handle used to interact with the autocomplete dialog box. */
|
93 | interface CompletionHandle {
|
94 | moveFocus(n: number, avoidWrap: boolean): void;
|
95 | setFocus(n: number): void;
|
96 | menuSize(): number;
|
97 | length: number;
|
98 | close(): void;
|
99 | pick(): void;
|
100 | data: any;
|
101 | }
|
102 |
|
103 | interface EditorConfiguration {
|
104 | showHint?: boolean | undefined;
|
105 | hintOptions?: ShowHintOptions | undefined;
|
106 | }
|
107 |
|
108 | interface HintHelpers {
|
109 | auto: HintFunctionResolver;
|
110 | fromList: HintFunction;
|
111 | }
|
112 |
|
113 | const hint: HintHelpers;
|
114 | }
|
115 |
|
\ | No newline at end of file |