@@ -9,119 +9,131 @@ import type * as lezerCommon from '@lezer/common';
99import type * as lezerHighlight from '@lezer/highlight' ;
1010import type * as lezerLr from '@lezer/lr' ;
1111
12- declare global {
13- const MarkEdit : {
12+ export const MarkEdit : MarkEdit ;
13+
14+ export interface MarkEdit {
15+ /**
16+ * CodeMirror EditorView instance of the current editor.
17+ */
18+ editorView : EditorView ;
19+
20+ /**
21+ * Convenient text editing interfaces.
22+ */
23+ editorAPI : TextEditable ;
24+
25+ /**
26+ * CodeMirror modules used by MarkEdit.
27+ */
28+ codemirror : {
1429 /**
15- * CodeMirror EditorView instance of the current editor .
30+ * The `@codemirror/view` module .
1631 */
17- editorView : EditorView ;
32+ view : typeof cmView ;
1833
1934 /**
20- * Convenient text editing interfaces .
35+ * The `@codemirror/state` module .
2136 */
22- editorAPI : TextEditable ;
37+ state : typeof cmState ;
2338
2439 /**
25- * Add an extension to MarkEdit.
26- * @param extension CodeMirror extension.
40+ * The `@codemirror/language` module.
2741 */
28- addExtension : ( extension : Extension ) => void ;
42+ language : typeof cmLanguage ;
43+ } ;
2944
45+ /**
46+ * Lezer modules used by MarkEdit.
47+ */
48+ lezer : {
3049 /**
31- * CodeMirror modules used by MarkEdit .
50+ * The `@lezer/common` module .
3251 */
33- codemirror : {
34- /**
35- * The `@codemirror/view` module.
36- */
37- view : typeof cmView ;
38- /**
39- * The `@codemirror/state` module.
40- */
41- state : typeof cmState ;
42- /**
43- * The `@codemirror/language` module.
44- */
45- language : typeof cmLanguage ;
46- } ;
52+ common : typeof lezerCommon ;
4753
4854 /**
49- * Lezer modules used by MarkEdit .
55+ * The `@lezer/highlight` module .
5056 */
51- lezer : {
52- /**
53- * The `@lezer/common` module.
54- */
55- common : typeof lezerCommon ;
56- /**
57- * The `@lezer/highlight` module.
58- */
59- highlight : typeof lezerHighlight ;
60- /**
61- * The `@lezer/lr` module.
62- */
63- lr : typeof lezerLr ;
64- } ,
65- }
57+ highlight : typeof lezerHighlight ;
58+
59+ /**
60+ * The `@lezer/lr` module.
61+ */
62+ lr : typeof lezerLr ;
63+ } ,
64+
65+ /**
66+ * Add an extension to MarkEdit.
67+ * @param extension CodeMirror extension.
68+ */
69+ addExtension : ( extension : Extension ) => void ;
6670}
6771
68- declare interface TextEditable {
72+ export interface TextEditable {
6973 /**
7074 * Get text of the document.
7175 * @param range The range of the text. If no range is provided, the entire document is returned.
7276 */
7377 getText ( range ?: TextRange ) : string ;
78+
7479 /**
7580 * Set text for the document.
7681 * @param text The text to set.
7782 * @param range The range of the text. If no range is provided, the entire document is overwritten.
7883 */
7984 setText ( text : string , range ?: TextRange ) : void ;
85+
8086 /**
8187 * Get text selections.
8288 */
8389 getSelections ( ) : TextRange [ ] ;
90+
8491 /**
8592 * Set text selections.
8693 * @param ranges Text ranges to set.
8794 */
8895 setSelections ( ranges : TextRange [ ] ) : void ;
96+
8997 /**
9098 * Get the line number (0-indexed) of given text position.
9199 * @param position The text position.
92100 */
93101 getLineNumber ( position : number ) : number ;
102+
94103 /**
95104 * Get line range of given row (0-indexed).
96105 * @param row The line number.
97106 */
98107 getLineRange ( row : number ) : TextRange ;
108+
99109 /**
100110 * Get number of lines.
101111 */
102112 getLineCount ( ) : number ;
113+
103114 /**
104115 * Get line separator.
105116 */
106117 getLineBreak ( ) : string ;
118+
107119 /**
108120 * Get CodeMirror syntax node name of given position.
109121 * @param position The text position.
110122 */
111123 getNodeName ( position : number ) : string ;
124+
112125 /**
113126 * Undo a change.
114127 */
115128 undo ( ) : void ;
129+
116130 /**
117131 * Redo a change.
118132 */
119133 redo ( ) : void ;
120134}
121135
122- declare type TextRange = {
136+ export type TextRange = {
123137 from : number ;
124138 to : number ;
125- } ;
126-
127- export { MarkEdit , TextEditable , TextRange } ;
139+ }
0 commit comments