forked from ajaxorg/ace
-
Notifications
You must be signed in to change notification settings - Fork 4
/
ace-internal.d.ts
1536 lines (1271 loc) · 47.5 KB
/
ace-internal.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
export namespace Ace {
type Anchor = import("./src/anchor").Anchor;
type Editor = import("./src/editor").Editor;
type EditSession = import("./src/edit_session").EditSession;
type Document = import("./src/document").Document;
type Fold = import("./src/edit_session/fold").Fold;
type FoldLine = import("./src/edit_session/fold_line").FoldLine;
type Range = import("./src/range").Range;
type VirtualRenderer = import("./src/virtual_renderer").VirtualRenderer;
type UndoManager = import("./src/undomanager").UndoManager;
type Tokenizer = import("./src/tokenizer").Tokenizer;
type TokenIterator = import("./src/token_iterator").TokenIterator;
type Selection = import("./src/selection").Selection;
type Autocomplete = import("./src/autocomplete").Autocomplete;
type InlineAutocomplete = import("./src/ext/inline_autocomplete").InlineAutocomplete;
type CompletionProvider = import("./src/autocomplete").CompletionProvider;
type AcePopup = import("./src/autocomplete/popup").AcePopup;
type AceInline = import("./src/autocomplete/inline").AceInline;
type MouseEvent = import("./src/mouse/mouse_event").MouseEvent;
type RangeList = import("./src/range_list").RangeList;
type FilteredList = import("./src/autocomplete").FilteredList;
type LineWidgets = import("./src/line_widgets").LineWidgets;
type SearchBox = import("./src/ext/searchbox").SearchBox;
type Occur = import("./src/occur").Occur;
type DefaultHandlers = import("./src/mouse/default_handlers").DefaultHandlers;
type GutterHandler = import("./src/mouse/default_gutter_handler").GutterHandler;
type DragdropHandler = import("./src/mouse/dragdrop_handler").DragdropHandler;
type AppConfig = import("./src/lib/app_config").AppConfig;
type AfterLoadCallback = (err: Error | null, module: unknown) => void;
type LoaderFunction = (moduleName: string, afterLoad: AfterLoadCallback) => void;
export interface Config {
get(key: string): any;
set(key: string, value: any): void;
all(): { [key: string]: any };
moduleUrl(name: string, component?: string): string;
setModuleUrl(name: string, subst: string): string;
setLoader(cb: LoaderFunction): void;
setModuleLoader(name: string, onLoad: Function): void;
loadModule(moduleName: string | [string, string],
onLoad?: (module: any) => void): void;
init(packaged: any): any;
defineOptions(obj: any, path: string, options: { [key: string]: any }): Config;
resetOptions(obj: any): void;
setDefaultValue(path: string, name: string, value: any): void;
setDefaultValues(path: string, optionHash: { [key: string]: any }): void;
}
interface Theme {
cssClass?: string;
cssText?: string;
$id?: string;
padding?: number | string;
isDark?: boolean;
}
interface ScrollBar {
setVisible(visible: boolean): void;
[key: string]: any;
}
interface HScrollbar extends ScrollBar {
setWidth(width: number): void;
}
interface VScrollbar extends ScrollBar {
setHeight(width: number): void;
}
interface LayerConfig {
width: number,
padding: number,
firstRow: number,
firstRowScreen: number,
lastRow: number,
lineHeight: number,
characterWidth: number,
minHeight: number,
maxHeight: number,
offset: number,
height: number,
gutterOffset: number
}
interface HardWrapOptions {
startRow: number;
endRow: number;
allowMerge?: boolean;
column?: number;
}
interface CommandBarOptions {
maxElementsOnTooltip: number;
alwaysShow: boolean;
showDelay: number;
hideDelay: number;
}
interface ScreenCoordinates {
row: number,
column: number,
side?: 1 | -1,
offsetX?: number
}
interface Folding {
$foldData: FoldLine[];
/**
* Looks up a fold at a given row/column. Possible values for side:
* -1: ignore a fold if fold.start = row/column
* +1: ignore a fold if fold.end = row/column
**/
getFoldAt(row: number, column: number, side?: number): Ace.Fold;
/**
* Returns all folds in the given range. Note, that this will return folds
**/
getFoldsInRange(range: Ace.Range | Ace.Delta): Ace.Fold[];
getFoldsInRangeList(ranges: Ace.Range[] | Ace.Range): Ace.Fold[];
/**
* Returns all folds in the document
*/
getAllFolds(): Ace.Fold[];
/**
* Returns the string between folds at the given position.
* E.g.
* foo<fold>b|ar<fold>wolrd -> "bar"
* foo<fold>bar<fold>wol|rd -> "world"
* foo<fold>bar<fo|ld>wolrd -> <null>
*
* where | means the position of row/column
*
* The trim option determs if the return string should be trimed according
* to the "side" passed with the trim value:
*
* E.g.
* foo<fold>b|ar<fold>wolrd -trim=-1> "b"
* foo<fold>bar<fold>wol|rd -trim=+1> "rld"
* fo|o<fold>bar<fold>wolrd -trim=00> "foo"
*/
getFoldStringAt(row: number, column: number, trim?: number, foldLine?: Ace.FoldLine): string | null;
getFoldLine(docRow: number, startFoldLine?: Ace.FoldLine): null | Ace.FoldLine;
/**
* Returns the fold which starts after or contains docRow
*/
getNextFoldLine(docRow: number, startFoldLine?: Ace.FoldLine): null | Ace.FoldLine;
getFoldedRowCount(first: number, last: number): number;
$addFoldLine(foldLine: FoldLine): Ace.FoldLine;
/**
* Adds a new fold.
* @returns {Ace.Fold}
* The new created Fold object or an existing fold object in case the
* passed in range fits an existing fold exactly.
*/
addFold(placeholder: Ace.Fold | string, range?: Ace.Range): Ace.Fold;
$modified: boolean;
addFolds(folds: Ace.Fold[]): void;
removeFold(fold: Ace.Fold): void;
removeFolds(folds: Ace.Fold[]): void;
expandFold(fold: Ace.Fold): void;
expandFolds(folds: Ace.Fold[]): void;
unfold(location?: number | null | Ace.Point | Ace.Range | Ace.Range[], expandInner?: boolean): Ace.Fold[] | undefined;
/**
* Checks if a given documentRow is folded. This is true if there are some
* folded parts such that some parts of the line is still visible.
**/
isRowFolded(docRow: number, startFoldRow?: Ace.FoldLine): boolean;
getRowFoldEnd(docRow: number, startFoldRow?: Ace.FoldLine): number;
getRowFoldStart(docRow: number, startFoldRow?: Ace.FoldLine): number;
getFoldDisplayLine(foldLine: Ace.FoldLine, endRow?: number | null, endColumn?: number | null, startRow?: number | null, startColumn?: number | null): string;
getDisplayLine(row: number, endColumn: number | null, startRow: number | null, startColumn: number | null): string;
$cloneFoldData(): Ace.FoldLine[];
toggleFold(tryToUnfold?: boolean): void;
getCommentFoldRange(row: number, column: number, dir?: number): Ace.Range | undefined;
foldAll(startRow?: number | null, endRow?: number | null, depth?: number | null, test?: Function): void;
foldToLevel(level: number): void;
foldAllComments(): void;
$foldStyles: {
manual: number;
markbegin: number;
markbeginend: number;
};
$foldStyle: string;
setFoldStyle(style: string): void;
$setFolding(foldMode: Ace.FoldMode): void;
$foldMode: any;
foldWidgets: any[];
getFoldWidget: any;
getFoldWidgetRange: any;
$updateFoldWidgets: any;
$tokenizerUpdateFoldWidgets: any;
getParentFoldRangeData(row: number, ignoreCurrent?: boolean): {
range?: Ace.Range;
firstRange?: Ace.Range;
};
onFoldWidgetClick(row: number, e: any): void;
$toggleFoldWidget(row: number, options: any): Fold | any;
/**
*
* @param {boolean} [toggleParent]
*/
toggleFoldWidget(toggleParent?: boolean): void;
updateFoldWidgets(delta: Ace.Delta): void;
tokenizerUpdateFoldWidgets(e: any): void;
}
interface BracketMatch {
findMatchingBracket: (position: Point, chr?: string) => Point;
getBracketRange: (pos: Point) => null | Range;
/**
* Returns:
* * null if there is no any bracket at `pos`;
* * two Ranges if there is opening and closing brackets;
* * one Range if there is only one bracket
*/
getMatchingBracketRanges: (pos: Point, isBackwards?: boolean) => null | Range[];
$brackets: {
")": string;
"(": string;
"]": string;
"[": string;
"{": string;
"}": string;
"<": string;
">": string;
};
$findOpeningBracket: (bracket: string, position: Point, typeRe?: RegExp) => Point | null;
$findClosingBracket: (bracket: string, position: Point, typeRe?: RegExp) => Point | null;
/**
* Returns [[Range]]'s for matching tags and tag names, if there are any
*/
getMatchingTags: (pos: Point) => {
closeTag: Range;
closeTagName: Range;
openTag: Range;
openTagName: Range;
};
$findTagName: (iterator: any) => any;
$findClosingTag: (iterator: any, token: any) => {
openTag: Range;
closeTag: Range;
openTagName: Range;
closeTagName: Range;
};
$findOpeningTag: (iterator: any, token: any) => {
openTag: Range;
closeTag: Range;
openTagName: Range;
closeTagName: Range;
};
}
interface IRange {
start: Point;
end: Point;
}
interface LineWidget {
el: HTMLElement;
rowCount: number;
hidden: boolean;
_inDocument: boolean;
column?: number;
row?: number;
$oldWidget?: LineWidget,
session: EditSession,
html?: string,
text?: string,
className?: string,
coverGutter?: boolean,
pixelHeight?: number,
$fold?: Fold,
editor: Editor,
coverLine?: boolean,
fixedWidth?: boolean,
fullWidth?: boolean,
screenWidth?: number,
rowsAbove?: number,
lenses?: any[],
}
type NewLineMode = 'auto' | 'unix' | 'windows';
interface EditSessionOptions {
wrap: "off" | "free" | "printmargin" | boolean | number;
wrapMethod: 'code' | 'text' | 'auto';
indentedSoftWrap: boolean;
firstLineNumber: number;
useWorker: boolean;
useSoftTabs: boolean;
tabSize: number;
navigateWithinSoftTabs: boolean;
foldStyle: 'markbegin' | 'markbeginend' | 'manual';
overwrite: boolean;
newLineMode: NewLineMode;
mode: string;
}
interface VirtualRendererOptions {
animatedScroll: boolean;
showInvisibles: boolean;
showPrintMargin: boolean;
printMarginColumn: number;
printMargin: boolean | number;
showGutter: boolean;
fadeFoldWidgets: boolean;
showFoldWidgets: boolean;
showLineNumbers: boolean;
displayIndentGuides: boolean;
highlightIndentGuides: boolean;
highlightGutterLine: boolean;
hScrollBarAlwaysVisible: boolean;
vScrollBarAlwaysVisible: boolean;
fontSize: string;
fontFamily: string;
maxLines: number;
minLines: number;
scrollPastEnd: number;
fixedWidthGutter: boolean;
customScrollbar: boolean;
theme: string;
hasCssTransforms: boolean;
maxPixelHeight: number;
useSvgGutterIcons: boolean;
showFoldedAnnotations: boolean;
useResizeObserver: boolean;
}
interface MouseHandlerOptions {
scrollSpeed: number;
dragDelay: number;
dragEnabled: boolean;
focusTimeout: number;
tooltipFollowsMouse: boolean;
}
interface EditorOptions extends EditSessionOptions,
MouseHandlerOptions,
VirtualRendererOptions {
selectionStyle: "fullLine" | "screenLine" | "text" | "line";
highlightActiveLine: boolean;
highlightSelectedWord: boolean;
readOnly: boolean;
copyWithEmptySelection: boolean;
cursorStyle: 'ace' | 'slim' | 'smooth' | 'wide';
mergeUndoDeltas: true | false | 'always';
behavioursEnabled: boolean;
wrapBehavioursEnabled: boolean;
enableAutoIndent: boolean;
enableBasicAutocompletion: boolean | Completer[];
enableLiveAutocompletion: boolean | Completer[];
liveAutocompletionDelay: number;
liveAutocompletionThreshold: number;
enableSnippets: boolean;
autoScrollEditorIntoView: boolean;
keyboardHandler: string | null;
placeholder: string;
value: string;
session: EditSession;
relativeLineNumbers: boolean;
enableMultiselect: boolean;
enableKeyboardAccessibility: boolean;
enableCodeLens: boolean;
enableMobileMenu: boolean;
}
interface EventsBase {
[key: string]: any;
}
interface EditSessionEvents {
/**
* Emitted when the document changes.
* @param delta
*/
"change": (delta: Delta) => void;
/**
* Emitted when the tab size changes, via [[EditSession.setTabSize]].
* @param tabSize
*/
"changeTabSize": (tabSize: number) => void;
/**
* Emitted when the ability to overwrite text changes, via [[EditSession.setOverwrite]].
* @param overwrite
*/
"changeOverwrite": (overwrite: boolean) => void;
/**
* Emitted when the gutter changes, either by setting or removing breakpoints, or when the gutter decorations change.
* @param e
*/
"changeBreakpoint": (e: { row: number, breakpoint: boolean }) => void;
/**
* Emitted when a front marker changes.
* @param e
*/
"changeFrontMarker": (e: { row: number, marker: boolean }) => void;
/**
* Emitted when a back marker changes.
* @param e
*/
"changeBackMarker": (e: { row: number, marker: boolean }) => void;
/**
* Emitted when an annotation changes, like through [[EditSession.setAnnotations]].
* @param e
*/
"changeAnnotation": (e: { row: number, lines: string[] }) => void;
/**
* Emitted when a background tokenizer asynchronously processes new rows.
*/
"tokenizerUpdate": (e: { data: { first: string, last: string } }) => void;
/**
* Emitted when the current mode changes.
* @param e
*/
"changeMode": (e) => void;
/**
* Emitted when the wrap mode changes.
* @param e
*/
"changeWrapMode": (e) => void;
/**
* Emitted when the wrapping limit changes.
* @param e
*/
"changeWrapLimit": (e) => void;
/**
* Emitted when a code fold is added or removed.
* @param e
*/
"changeFold": (e, session: EditSession) => void;
/**
* Emitted when the scroll top changes.
* @param scrollTop The new scroll top value
**/
"changeScrollTop": (scrollTop: number) => void;
/**
* Emitted when the scroll left changes.
* @param scrollLeft The new scroll left value
**/
"changeScrollLeft": (scrollLeft: number) => void;
"changeEditor": (e: { editor: Editor }) => void;
}
interface EditorEvents {
"change": (delta: Delta) => void;
"changeSelection": () => void;
"input": () => void;
/**
* Emitted whenever the [[EditSession]] changes.
* @param e An object with two properties, `oldSession` and `session`, that represent the old and new [[EditSession]]s.
**/
"changeSession": (e: { oldSession: EditSession, session: EditSession }) => void;
"blur": (e) => void;
"mousedown": (e: MouseEvent) => void;
"mousemove": (e: MouseEvent & { scrollTop? }, editor?: Editor) => void;
"changeStatus": () => void;
"keyboardActivity": () => void;
"mousewheel": (e: MouseEvent) => void;
"mouseup": (e: MouseEvent) => void;
"beforeEndOperation": (e) => void;
"nativecontextmenu": (e) => void;
"destroy": () => void;
"focus": () => void;
/**
* Emitted when text is copied.
* @param text The copied text
**/
"copy": (text: string) => void;
/**
* Emitted when text is pasted.
**/
"paste": (text: string, event) => void;
/**
* Emitted when the selection style changes, via [[Editor.setSelectionStyle]].
* @param data Contains one property, `data`, which indicates the new selection style
**/
"changeSelectionStyle": (data: "fullLine" | "screenLine" | "text" | "line") => void;
}
interface AcePopupEvents {
"click": (e: MouseEvent) => void;
"dblclick": (e: MouseEvent) => void;
"tripleclick": (e: MouseEvent) => void;
"quadclick": (e: MouseEvent) => void;
"show": () => void;
"hide": () => void;
"select": (hide: boolean) => void;
"changeHoverMarker": (e) => void;
}
interface DocumentEvents {
/**
* Fires whenever the document changes.
* Several methods trigger different `"change"` events. Below is a list of each action type, followed by each property that's also available:
* * `"insert"`
* * `range`: the [[Range]] of the change within the document
* * `lines`: the lines being added
* * `"remove"`
* * `range`: the [[Range]] of the change within the document
* * `lines`: the lines being removed
*
**/
"change": (e: Delta) => void;
"changeNewLineMode": () => void;
}
interface AnchorEvents {
/**
* Fires whenever the anchor position changes.
* Both of these objects have a `row` and `column` property corresponding to the position.
* Events that can trigger this function include [[Anchor.setPosition `setPosition()`]].
* @param {Object} e An object containing information about the anchor position. It has two properties:
* - `old`: An object describing the old Anchor position
* - `value`: An object describing the new Anchor position
**/
"change": (e: { old: Point, value: Point }) => void;
}
interface BackgroundTokenizerEvents {
/**
* Fires whenever the background tokeniziers between a range of rows are going to be updated.
* @param {Object} e An object containing two properties, `first` and `last`, which indicate the rows of the region being updated.
**/
"update": (e: { first: number, last: number }) => void;
}
interface SelectionEvents {
/**
* Emitted when the cursor position changes.
**/
"changeCursor": () => void;
/**
* Emitted when the cursor selection changes.
**/
"changeSelection": () => void;
}
interface PlaceHolderEvents {
}
interface GutterEvents {
"changeGutterWidth": (width: number) => void;
}
interface TextEvents {
"changeCharacterSize": (e) => void;
}
interface VirtualRendererEvents {
"afterRender": (e, renderer: VirtualRenderer) => void;
"beforeRender": (e, renderer: VirtualRenderer) => void;
}
class EventEmitter<T> {
once<K extends keyof T>(name: K, callback: T[K]): void;
setDefaultHandler(name: string, callback: Function): void;
removeDefaultHandler(name: string, callback: Function): void;
on<K extends keyof T>(name: K, callback: T[K], capturing?: boolean): T[K];
addEventListener<K extends keyof T>(name: K, callback: T[K], capturing?: boolean): T[K];
off<K extends keyof T>(name: K, callback: T[K]): void;
removeListener<K extends keyof T>(name: K, callback: T[K]): void;
removeEventListener<K extends keyof T>(name: K, callback: T[K]): void;
removeAllListeners(name?: string): void;
_signal(eventName: string, e: any): void;
_emit(eventName: string, e: any): void;
_dispatchEvent(eventName: string, e: any): void;
}
interface SearchOptions {
needle: string | RegExp;
preventScroll: boolean;
backwards: boolean;
start: Range;
skipCurrent: boolean;
range: Range;
preserveCase: boolean;
regExp: boolean;
wholeWord: boolean;
caseSensitive: boolean;
wrap: boolean;
re: RegExp;
}
interface Point {
row: number;
column: number;
}
type Position = Point;
interface Delta {
action: 'insert' | 'remove';
start: Point;
end: Point;
lines: string[];
id?: number,
folds?: Fold[]
}
interface Annotation {
row: number;
column: number;
text: string;
type: string;
}
export interface MarkerGroupItem {
range: Range;
className: string;
}
type MarkerGroup = import("./src/marker_group").MarkerGroup;
export interface Command {
name?: string;
bindKey?: string | { mac?: string, win?: string };
readOnly?: boolean;
exec?: (editor?: Editor | any, args?: any) => void;
isAvailable?: (editor: Editor) => boolean;
description?: string,
multiSelectAction?: "forEach" | "forEachLine" | Function,
scrollIntoView?: true | "cursor" | "center" | "selectionPart" | "animate" | "selection" | "none",
aceCommandGroup?: string,
passEvent?: boolean,
level?: number,
action?: string,
}
type CommandLike = Command | ((editor: Editor) => void) | ((sb: SearchBox) => void);
type KeyboardHandler = Partial<import("./src/keyboard/hash_handler").HashHandler> & {
attach?: (editor: Editor) => void;
detach?: (editor: Editor) => void;
getStatusText?: (editor?: any, data?) => string;
}
export interface MarkerLike {
range?: Range;
type: string;
renderer?: MarkerRenderer;
clazz: string;
inFront?: boolean;
id?: number;
update?: (html: string[],
// TODO maybe define Marker class
marker: any,
session: EditSession,
config: any) => void;
[key: string]: any;
}
type MarkerRenderer = (html: string[],
range: Range,
left: number,
top: number,
config: any) => void;
interface Token {
type: string;
value: string;
index?: number;
start?: number;
}
type BaseCompletion = import("./src/autocomplete").BaseCompletion;
type SnippetCompletion = import("./src/autocomplete").SnippetCompletion;
type ValueCompletion = import("./src/autocomplete").ValueCompletion;
type Completion = import("./src/autocomplete").Completion;
type HighlightRule = ({ defaultToken: string } | { include: string } | { todo: string } | {
token: string | string[] | ((value: string) => string);
regex: string | RegExp;
next?: string | (() => void);
push?: string;
comment?: string;
caseInsensitive?: boolean;
nextState?: string;
}) & { [key: string]: any };
type HighlightRulesMap = Record<string, HighlightRule[]>;
type KeywordMapper = (keyword: string) => string;
interface HighlightRules {
$rules: HighlightRulesMap;
$embeds: string[];
$keywords: any[];
$keywordList: string[];
addRules(rules: HighlightRulesMap, prefix?: string): void;
getRules(): HighlightRulesMap;
embedRules(rules: (new () => HighlightRules) | HighlightRulesMap, prefix: string, escapeRules?: boolean, append?: boolean): void;
getEmbeds(): string[];
normalizeRules(): void;
createKeywordMapper(map: Record<string, string>, defaultToken?: string, ignoreCase?: boolean, splitChar?: string): KeywordMapper;
}
type FoldWidget = "start" | "end" | ""
interface FoldMode {
foldingStartMarker: RegExp;
foldingStopMarker?: RegExp;
getFoldWidget(session: EditSession, foldStyle: string, row: number): FoldWidget;
getFoldWidgetRange(session: EditSession, foldStyle: string, row: number): Range | undefined;
indentationBlock(session: EditSession, row: number, column?: number): Range | undefined;
openingBracketBlock(session: EditSession, bracket: string, row: number, column: number, typeRe?: RegExp): Range | undefined;
closingBracketBlock(session: EditSession, bracket: string, row: number, column: number, typeRe?: RegExp): Range | undefined;
}
type BehaviorAction = (state: string | string[], action: string, editor: Editor, session: EditSession, text: string | Range) => ({
text: string,
selection: number[]
} | Range) & { [key: string]: any } | undefined;
type BehaviorMap = Record<string, Record<string, BehaviorAction>>;
interface Behaviour {
add(name: string, action: string, callback: BehaviorAction): void;
addBehaviours(behaviours: BehaviorMap): void;
remove(name: string): void;
inherit(mode: SyntaxMode | (new () => SyntaxMode), filter: string[]): void;
getBehaviours(filter?: string[]): BehaviorMap;
}
interface Outdent {
checkOutdent(line: string, input: string): boolean;
autoOutdent(doc: Document, row: number): number | undefined;
}
interface SyntaxMode {
/**
* quotes used by language mode
*/
$quotes: { [quote: string]: string };
HighlightRules: {
new(config: any): HighlightRules
}; //TODO: fix this
foldingRules?: FoldMode;
$behaviour?: Behaviour;
$defaultBehaviour?: Behaviour;
/**
* characters that indicate the start of a line comment
*/
lineCommentStart?: string;
/**
* characters that indicate the start and end of a block comment
*/
blockComment?: { start: string, end: string }
tokenRe?: RegExp;
nonTokenRe?: RegExp;
/**
* An object containing conditions to determine whether to apply matching quote or not.
*/
$pairQuotesAfter: { [quote: string]: RegExp }
$tokenizer: Tokenizer;
$highlightRules: HighlightRules;
$embeds?: string[];
$modes?: SyntaxMode[];
$keywordList?: string[];
$highlightRuleConfig?: any;
completionKeywords: string[];
transformAction: BehaviorAction;
path?: string;
getTokenizer(): Tokenizer;
toggleCommentLines(state: string | string[],
session: EditSession,
startRow: number,
endRow: number): void;
toggleBlockComment(state: string | string[],
session: EditSession,
range: Range,
cursor: Point): void;
getNextLineIndent(state: string | string[], line: string, tab: string): string;
checkOutdent(state: string | string[], line: string, input: string): boolean;
autoOutdent(state: string | string[], doc: EditSession, row: number): void;
// TODO implement WorkerClient types
createWorker(session: EditSession): any;
createModeDelegates(mapping: { [key: string]: string }): void;
getKeywords(append?: boolean): Array<string | RegExp>;
getCompletions(state: string | string[],
session: EditSession,
pos: Point,
prefix: string): Completion[];
$getIndent(line: string): string;
$createKeywordList(): string[];
$delegator(method: string, args: IArguments, defaultHandler): any;
}
interface OptionsBase {
[key: string]: any;
}
class OptionsProvider<T> {
setOptions(optList: Partial<T>): void;
getOptions(optionNames?: Array<keyof T> | Partial<T>): Partial<T>;
setOption<K extends keyof T>(name: K, value: T[K]): void;
getOption<K extends keyof T>(name: K): T[K];
}
type KeyBinding = import("./src/keyboard/keybinding").KeyBinding;
interface CommandMap {
[name: string]: Command;
}
type execEventHandler = (obj: {
editor: Editor,
command: Command,
args: any[]
}) => void;
interface CommandManagerEvents {
on(name: 'exec', callback: execEventHandler): Function;
on(name: 'afterExec', callback: execEventHandler): Function;
}
type CommandManager = import("./src/commands/command_manager").CommandManager;
interface SavedSelection {
start: Point;
end: Point;
isBackwards: boolean;
}
var Selection: {
new(session: EditSession): Selection;
}
interface TextInput {
resetSelection(): void;
setAriaOption(options?: { activeDescendant: string, role: string, setLabel }): void;
}
type CompleterCallback = (error: any, completions: Completion[]) => void;
interface Completer {
identifierRegexps?: Array<RegExp>,
getCompletions(editor: Editor,
session: EditSession,
position: Point,
prefix: string,
callback: CompleterCallback): void;
getDocTooltip?(item: Completion): void | string | Completion;
onSeen?: (editor: Ace.Editor, completion: Completion) => void;
onInsert?: (editor: Ace.Editor, completion: Completion) => void;
cancel?(): void;
id?: string;
triggerCharacters?: string[];
hideInlinePreview?: boolean;
}
interface CompletionOptions {
matches?: Completion[];
}
type CompletionProviderOptions = {
exactMatch?: boolean;
ignoreCaption?: boolean;
}
type GatherCompletionRecord = {
prefix: string;
matches: Completion[];
finished: boolean;
}
type CompletionCallbackFunction = (err: Error | undefined, data: GatherCompletionRecord) => void;
type CompletionProviderCallback = (this: import("./src/autocomplete").Autocomplete, err: Error | undefined, completions: import("./src/autocomplete").FilteredList, finished: boolean) => void;
type AcePopupNavigation = "up" | "down" | "start" | "end";
interface EditorMultiSelectProperties {
inMultiSelectMode?: boolean,
/**
* Updates the cursor and marker layers.
**/
updateSelectionMarkers: () => void,
/**
* Adds the selection and cursor.
* @param orientedRange A range containing a cursor
**/
addSelectionMarker: (orientedRange: Ace.Range & { marker? }) => Ace.Range & { marker? },
/**
* Removes the selection marker.
* @param range The selection range added with [[Editor.addSelectionMarker `addSelectionMarker()`]].
**/
removeSelectionMarker: (range: Ace.Range & { marker? }) => void,
removeSelectionMarkers: (ranges: (Ace.Range & { marker? })[]) => void,
$onAddRange: (e) => void,
$onRemoveRange: (e) => void,
$onMultiSelect: (e) => void,
$onSingleSelect: (e) => void,
$onMultiSelectExec: (e) => void,
/**
* Executes a command for each selection range.
* @param cmd The command to execute