1
+ /// <reference path="./ace-modes.d.ts" />
2
+
1
3
export namespace Ace {
2
4
export type NewLineMode = 'auto' | 'unix' | 'windows' ;
3
5
@@ -364,7 +366,66 @@ export namespace Ace {
364
366
stepForward ( ) : Token ;
365
367
}
366
368
369
+ export type HighlightRule = { defaultToken : string } | { include : string } | { todo : string } | {
370
+ token : string | string [ ] | ( ( value : string ) => string ) ;
371
+ regex : string | RegExp ;
372
+ next ?: string ;
373
+ push ?: string ;
374
+ comment ?: string ;
375
+ caseInsensitive ?: boolean ;
376
+ }
377
+
378
+ export type HighlightRulesMap = Record < string , HighlightRule [ ] > ;
379
+
380
+ export type KeywordMapper = ( keyword : string ) => string ;
381
+
382
+ export interface HighlightRules {
383
+ $rules : HighlightRulesMap ;
384
+ $embeds ?: string [ ] ;
385
+ $keywordList ?: string [ ] ;
386
+ $keywords ?: KeywordMapper ;
387
+ addRules ( rules : HighlightRulesMap , prefix ?: string ) : void ;
388
+ getRules ( ) : HighlightRulesMap ;
389
+ embedRules ( rules : ( new ( ) => HighlightRules ) | HighlightRulesMap , prefix : string , escapeRules ?: boolean , append ?: boolean ) : void ;
390
+ getEmbeds ( ) : string [ ] ;
391
+ normalizeRules ( ) : void ;
392
+ createKeywordMapper ( map : Record < string , string > , defaultToken ?: string , ignoreCase ?: boolean , splitChar ?: string ) : KeywordMapper ;
393
+ }
394
+
395
+ export interface FoldMode {
396
+ foldingStartMarker : RegExp ;
397
+ foldingStopMarker ?: RegExp ;
398
+ getFoldWidget ( session : EditSession , foldStyle : string , row : number ) : string ;
399
+ getFoldWidgetRange ( session : EditSession , foldStyle : string , row : number , forceMultiline ?: boolean ) : Range | undefined ;
400
+ indentationBlock ( session : EditSession , row : number , column ?: number ) : Range | undefined ;
401
+ openingBracketBlock ( session : EditSession , bracket : string , row : number , column : number , typeRe ?: RegExp ) : Range | undefined ;
402
+ closingBracketBlock ( session : EditSession , bracket : string , row : number , column : number , typeRe ?: RegExp ) : Range | undefined ;
403
+ }
404
+
405
+ type BehaviorAction = ( state : string , action : string , editor : Editor , session : EditSession , text : string ) => { text : string , selection : number [ ] } | Range | undefined ;
406
+ type BehaviorMap = Record < string , Record < string , BehaviorAction > > ;
407
+
408
+ export interface Behaviour {
409
+ $behaviours : BehaviorMap ;
410
+ add ( name : string , action : string , callback : BehaviorAction ) : void ;
411
+ addBehaviours ( behaviours : BehaviorMap ) : void ;
412
+ remove ( name : string ) : void ;
413
+ inherit ( mode : SyntaxMode | ( new ( ) => SyntaxMode ) , filter : string [ ] ) : void ;
414
+ getBehaviours ( filter : string [ ] ) : BehaviorMap ;
415
+ }
416
+
417
+ export interface Outdent {
418
+ checkOutdent ( line : string , input : string ) : boolean ;
419
+ autoOutdent ( doc : Document , row : number ) : number | undefined ;
420
+ $getIndent ( line : string ) : string ;
421
+ }
422
+
367
423
export interface SyntaxMode {
424
+ HighlightRules : new ( ) => HighlightRules ;
425
+ foldingRules ?: FoldMode ;
426
+ $behaviour ?: Behaviour ;
427
+ $defaultBehaviour ?: Behaviour ;
428
+ lineCommentStart ?: string ;
368
429
getTokenizer ( ) : Tokenizer ;
369
430
toggleCommentLines ( state : any ,
370
431
session : EditSession ,
@@ -377,28 +438,28 @@ export namespace Ace {
377
438
getNextLineIndent ( state : any , line : string , tab : string ) : string ;
378
439
checkOutdent ( state : any , line : string , input : string ) : boolean ;
379
440
autoOutdent ( state : any , doc : Document , row : number ) : void ;
441
+ $getIndent ( line : string ) : string ;
380
442
// TODO implement WorkerClient types
381
443
createWorker ( session : EditSession ) : any ;
382
444
createModeDelegates ( mapping : { [ key : string ] : string } ) : void ;
383
- transformAction ( state : string ,
384
- action : string ,
385
- editor : Editor ,
386
- session : EditSession ,
387
- text : string ) : any ;
445
+ transformAction : BehaviorAction ;
388
446
getKeywords ( append ?: boolean ) : Array < string | RegExp > ;
389
447
getCompletions ( state : string ,
390
448
session : EditSession ,
391
449
pos : Point ,
392
450
prefix : string ) : Completion [ ] ;
393
451
}
394
452
453
+ type AfterLoadCallback = ( err : Error | null , module : unknown ) => void ;
454
+ type LoaderFunction = ( moduleName : string , afterLoad : AfterLoadCallback ) => void ;
455
+
395
456
export interface Config {
396
457
get ( key : string ) : any ;
397
458
set ( key : string , value : any ) : void ;
398
459
all ( ) : { [ key : string ] : any } ;
399
460
moduleUrl ( name : string , component ?: string ) : string ;
400
461
setModuleUrl ( name : string , subst : string ) : string ;
401
- setLoader ( cb : Function ) : void ;
462
+ setLoader ( cb : LoaderFunction ) : void ;
402
463
setModuleLoader ( name : string , onLoad : Function ) : void ;
403
464
loadModule ( moduleName : string | [ string , string ] ,
404
465
onLoad ?: ( module : any ) => void ) : void ;
@@ -455,11 +516,12 @@ export namespace Ace {
455
516
on ( name : 'tokenizerUpdate' ,
456
517
callback : ( obj : { data : { first : number , last : number } } ) => void ) : Function ;
457
518
on ( name : 'change' , callback : ( ) => void ) : Function ;
519
+ on ( name : 'changeTabSize' , callback : ( ) => void ) : Function ;
458
520
459
521
460
522
setOption < T extends keyof EditSessionOptions > ( name : T , value : EditSessionOptions [ T ] ) : void ;
461
523
getOption < T extends keyof EditSessionOptions > ( name : T ) : EditSessionOptions [ T ] ;
462
-
524
+
463
525
readonly doc : Document ;
464
526
465
527
setDocument ( doc : Document ) : void ;
@@ -817,7 +879,7 @@ export namespace Ace {
817
879
setKeyboardHandler ( keyboardHandler : string , callback ?: ( ) => void ) : void ;
818
880
setKeyboardHandler ( keyboardHandler : KeyboardHandler | null ) : void ;
819
881
getKeyboardHandler ( ) : string ;
820
- setSession ( session : EditSession ) : void ;
882
+ setSession ( session : EditSession | undefined ) : void ;
821
883
getSession ( ) : EditSession ;
822
884
setValue ( val : string , cursorPos ?: number ) : string ;
823
885
getValue ( ) : string ;
@@ -1032,7 +1094,7 @@ export const VirtualRenderer: {
1032
1094
new ( container : HTMLElement , theme ?: string ) : Ace . VirtualRenderer ;
1033
1095
} ;
1034
1096
export const EditSession : {
1035
- new ( text : string | Document , mode ?: Ace . SyntaxMode ) : Ace . EditSession ;
1097
+ new ( text : string | Ace . Document , mode ?: Ace . SyntaxMode ) : Ace . EditSession ;
1036
1098
} ;
1037
1099
export const UndoManager : {
1038
1100
new ( ) : Ace . UndoManager ;
0 commit comments