@jupyterlab/codemirror 4.0.0-alpha.1 → 4.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/codemirror-ipython.d.ts +1 -2
- package/lib/codemirror-ipython.js +7 -25
- package/lib/codemirror-ipython.js.map +1 -1
- package/lib/codemirror-ipythongfm.d.ts +10 -3
- package/lib/codemirror-ipythongfm.js +60 -30
- package/lib/codemirror-ipythongfm.js.map +1 -1
- package/lib/editor.d.ts +51 -206
- package/lib/editor.js +385 -625
- package/lib/editor.js.map +1 -1
- package/lib/editorconfiguration.d.ts +149 -0
- package/lib/editorconfiguration.js +286 -0
- package/lib/editorconfiguration.js.map +1 -0
- package/lib/editortheme.d.ts +41 -0
- package/lib/editortheme.js +167 -0
- package/lib/editortheme.js.map +1 -0
- package/lib/factory.js +22 -19
- package/lib/factory.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/mimetype.js +9 -3
- package/lib/mimetype.js.map +1 -1
- package/lib/mode.d.ts +61 -54
- package/lib/mode.js +1472 -105
- package/lib/mode.js.map +1 -1
- package/lib/searchprovider.d.ts +181 -0
- package/lib/searchprovider.js +648 -0
- package/lib/searchprovider.js.map +1 -0
- package/lib/syntaxstatus.js +9 -3
- package/lib/syntaxstatus.js.map +1 -1
- package/package.json +47 -30
- package/style/base.css +14 -154
- package/style/index.css +2 -4
- package/style/index.js +2 -4
- package/lib/tokens.d.ts +0 -18
- package/lib/tokens.js +0 -9
- package/lib/tokens.js.map +0 -1
- package/typings/codemirror/codemirror.d.ts +0 -227
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import 'codemirror/mode/python/python';
|
|
1
|
+
export {};
|
|
@@ -1,30 +1,12 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
|
-
import
|
|
4
|
-
import 'codemirror/mode/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Define an IPython codemirror mode.
|
|
8
|
-
*
|
|
9
|
-
* It is a slightly altered Python Mode with a `?` operator.
|
|
10
|
-
*/
|
|
11
|
-
CodeMirror.defineMode('ipython', (config, modeOptions) => {
|
|
12
|
-
const pythonConf = {};
|
|
13
|
-
for (const prop in modeOptions) {
|
|
14
|
-
if (modeOptions.hasOwnProperty(prop)) {
|
|
15
|
-
pythonConf[prop] = modeOptions[prop];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
pythonConf.name = 'python';
|
|
19
|
-
pythonConf.singleOperators = new RegExp('^[\\+\\-\\*/%&|@\\^~<>!\\?]');
|
|
20
|
-
pythonConf.identifiers = new RegExp('^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*');
|
|
21
|
-
return CodeMirror.getMode(config, pythonConf);
|
|
22
|
-
}, 'python');
|
|
23
|
-
CodeMirror.defineMIME('text/x-ipython', 'ipython');
|
|
24
|
-
CodeMirror.modeInfo.push({
|
|
25
|
-
ext: [],
|
|
3
|
+
import { Mode } from './mode';
|
|
4
|
+
import { mkPython } from '@codemirror/legacy-modes/mode/python';
|
|
5
|
+
Mode.registerModeInfo({
|
|
6
|
+
name: 'ipython',
|
|
26
7
|
mime: 'text/x-ipython',
|
|
27
|
-
|
|
28
|
-
|
|
8
|
+
load: () => {
|
|
9
|
+
return Promise.resolve(Mode.legacy(mkPython({ singleOperators: /\?/ })));
|
|
10
|
+
}
|
|
29
11
|
});
|
|
30
12
|
//# sourceMappingURL=codemirror-ipython.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codemirror-ipython.js","sourceRoot":"","sources":["../src/codemirror-ipython.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,
|
|
1
|
+
{"version":3,"file":"codemirror-ipython.js","sourceRoot":"","sources":["../src/codemirror-ipython.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAEhE,IAAI,CAAC,gBAAgB,CAAC;IACpB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE,GAAG,EAAE;QACT,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3E,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export {};
|
|
2
|
+
/**
|
|
3
|
+
* Define an IPython GFM (GitHub Flavored Markdown) mode.
|
|
4
|
+
*
|
|
5
|
+
* Is just a slightly altered GFM Mode with support for LaTeX.
|
|
6
|
+
* LaTeX support was supported by Codemirror GFM as of
|
|
7
|
+
* https://github.com/codemirror/CodeMirror/pull/567
|
|
8
|
+
* But was later removed in
|
|
9
|
+
* https://github.com/codemirror/CodeMirror/commit/d9c9f1b1ffe984aee41307f3e927f80d1f23590c
|
|
10
|
+
*/
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
|
-
import
|
|
3
|
+
import { Mode } from './mode';
|
|
4
|
+
Mode.registerModeInfo({
|
|
5
|
+
name: 'ipythongfm',
|
|
6
|
+
mime: 'text/x-ipythongfm',
|
|
7
|
+
load: () => {
|
|
8
|
+
return import('@codemirror/lang-markdown').then(m => m.markdown({ codeLanguages: Mode.getModeInfo() }));
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
// TODO: add support for LaTeX
|
|
12
|
+
// This should be coded as an extension for https://github.com/lezer-parser/markdown
|
|
13
|
+
// see https://github.com/lezer-parser/markdown/blob/main/src/extension.ts for examples
|
|
14
|
+
// Then this extension can be passed to the markdown function above:
|
|
15
|
+
//
|
|
16
|
+
// load: () => {
|
|
17
|
+
// return import('@codemirror/lang-markdown').then(m => m.markdown({extensions: latex}));
|
|
18
|
+
// }
|
|
19
|
+
/*import CodeMirror from 'codemirror';
|
|
4
20
|
import 'codemirror/addon/mode/multiplex';
|
|
5
21
|
import 'codemirror/mode/gfm/gfm';
|
|
6
22
|
import 'codemirror/mode/stex/stex';
|
|
23
|
+
*/
|
|
7
24
|
/**
|
|
8
25
|
* Define an IPython GFM (GitHub Flavored Markdown) mode.
|
|
9
26
|
*
|
|
@@ -13,74 +30,87 @@ import 'codemirror/mode/stex/stex';
|
|
|
13
30
|
* But was later removed in
|
|
14
31
|
* https://github.com/codemirror/CodeMirror/commit/d9c9f1b1ffe984aee41307f3e927f80d1f23590c
|
|
15
32
|
*/
|
|
16
|
-
CodeMirror.defineMode(
|
|
33
|
+
/*CodeMirror.defineMode(
|
|
34
|
+
'ipythongfm',
|
|
35
|
+
(config: CodeMirror.EditorConfiguration, modeOptions?: any) => {
|
|
17
36
|
const gfmMode = CodeMirror.getMode(config, {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
37
|
+
name: 'gfm',
|
|
38
|
+
// Override list3 with an under-used token, rather than `keyword`
|
|
39
|
+
tokenTypeOverrides: { list3: 'string-2' }
|
|
21
40
|
});
|
|
22
41
|
const texMode = CodeMirror.getMode(config, {
|
|
23
|
-
|
|
24
|
-
|
|
42
|
+
name: 'stex',
|
|
43
|
+
inMathMode: true
|
|
25
44
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
45
|
+
|
|
46
|
+
return CodeMirror.multiplexingMode(
|
|
47
|
+
gfmMode,
|
|
48
|
+
// force parsing inline code and code blocks with gfmMode to prevent
|
|
49
|
+
// parsing them as tex see:
|
|
50
|
+
// https://github.com/jupyterlab/jupyterlab/issues/6774
|
|
51
|
+
{
|
|
31
52
|
open: '<code>',
|
|
32
53
|
close: '</code>',
|
|
33
54
|
mode: gfmMode,
|
|
34
55
|
parseDelimiters: true
|
|
35
|
-
|
|
56
|
+
},
|
|
57
|
+
{
|
|
36
58
|
open: '<pre>',
|
|
37
59
|
close: '</pre>',
|
|
38
60
|
mode: gfmMode,
|
|
39
61
|
parseDelimiters: true
|
|
40
|
-
|
|
62
|
+
},
|
|
63
|
+
{
|
|
41
64
|
open: '```',
|
|
42
65
|
close: '```',
|
|
43
66
|
mode: gfmMode,
|
|
44
67
|
parseDelimiters: true
|
|
45
|
-
|
|
68
|
+
},
|
|
69
|
+
{
|
|
46
70
|
open: '`',
|
|
47
71
|
close: '`',
|
|
48
72
|
mode: gfmMode,
|
|
49
73
|
parseDelimiters: true
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
74
|
+
},
|
|
75
|
+
// only if we did not match a code element or block,
|
|
76
|
+
// then try do parse using the tex mode
|
|
77
|
+
{
|
|
54
78
|
open: '$$',
|
|
55
79
|
close: '$$',
|
|
56
80
|
mode: texMode,
|
|
57
81
|
delimStyle: 'delimit'
|
|
58
|
-
|
|
82
|
+
},
|
|
83
|
+
{
|
|
59
84
|
// `$math mode$` is only matched if both opening
|
|
60
85
|
// and closing $ are in the same line
|
|
61
86
|
open: /\$(?=.*\$)/,
|
|
62
87
|
close: '$',
|
|
63
88
|
mode: texMode,
|
|
64
89
|
delimStyle: 'delimit'
|
|
65
|
-
|
|
90
|
+
},
|
|
91
|
+
{
|
|
66
92
|
open: '\\(',
|
|
67
93
|
close: '\\)',
|
|
68
94
|
mode: texMode,
|
|
69
95
|
delimStyle: 'delimit'
|
|
70
|
-
|
|
96
|
+
},
|
|
97
|
+
{
|
|
71
98
|
open: '\\[',
|
|
72
99
|
close: '\\]',
|
|
73
100
|
mode: texMode,
|
|
74
101
|
delimStyle: 'delimit'
|
|
75
|
-
|
|
76
|
-
|
|
102
|
+
}
|
|
103
|
+
// .. more multiplexed styles can follow here
|
|
77
104
|
);
|
|
78
|
-
},
|
|
105
|
+
},
|
|
106
|
+
'gfm'
|
|
107
|
+
);
|
|
108
|
+
|
|
79
109
|
CodeMirror.defineMIME('text/x-ipythongfm', 'ipythongfm');
|
|
80
110
|
CodeMirror.modeInfo.push({
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
})
|
|
111
|
+
ext: [],
|
|
112
|
+
mime: 'text/x-ipythongfm',
|
|
113
|
+
mode: 'ipythongfm',
|
|
114
|
+
name: 'ipythongfm'
|
|
115
|
+
});*/
|
|
86
116
|
//# sourceMappingURL=codemirror-ipythongfm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codemirror-ipythongfm.js","sourceRoot":"","sources":["../src/codemirror-ipythongfm.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,
|
|
1
|
+
{"version":3,"file":"codemirror-ipythongfm.js","sourceRoot":"","sources":["../src/codemirror-ipythongfm.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,IAAI,CAAC,gBAAgB,CAAC;IACpB,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,GAAG,EAAE;QACT,OAAO,MAAM,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAClD,CAAC,CAAC,QAAQ,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,WAAW,EAAS,EAAE,CAAC,CACzD,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,8BAA8B;AAC9B,oFAAoF;AACpF,uFAAuF;AACvF,oEAAoE;AACpE,EAAE;AACF,gBAAgB;AAChB,2FAA2F;AAC3F,IAAI;AAEJ;;;;EAIE;AACF;;;;;;;;GAQG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkFK"}
|
package/lib/editor.d.ts
CHANGED
|
@@ -1,32 +1,12 @@
|
|
|
1
|
-
/// <reference types="@types/codemirror/addon/search/searchcursor" />
|
|
2
1
|
import { CodeEditor } from '@jupyterlab/codeeditor';
|
|
3
2
|
import { ITranslator } from '@jupyterlab/translation';
|
|
4
3
|
import { IDisposable } from '@lumino/disposable';
|
|
5
4
|
import { Signal } from '@lumino/signaling';
|
|
6
|
-
import
|
|
7
|
-
import 'codemirror/
|
|
8
|
-
import '
|
|
9
|
-
import 'codemirror
|
|
10
|
-
import 'codemirror
|
|
11
|
-
import 'codemirror/addon/fold/brace-fold.js';
|
|
12
|
-
import 'codemirror/addon/fold/comment-fold.js';
|
|
13
|
-
import 'codemirror/addon/fold/foldcode.js';
|
|
14
|
-
import 'codemirror/addon/fold/foldgutter.js';
|
|
15
|
-
import 'codemirror/addon/fold/indent-fold.js';
|
|
16
|
-
import 'codemirror/addon/fold/markdown-fold.js';
|
|
17
|
-
import 'codemirror/addon/fold/xml-fold.js';
|
|
18
|
-
import 'codemirror/addon/mode/simple';
|
|
19
|
-
import 'codemirror/addon/scroll/scrollpastend.js';
|
|
20
|
-
import 'codemirror/addon/search/jump-to-line';
|
|
21
|
-
import 'codemirror/addon/search/search';
|
|
22
|
-
import 'codemirror/addon/search/searchcursor';
|
|
23
|
-
import 'codemirror/addon/selection/active-line';
|
|
24
|
-
import 'codemirror/addon/selection/mark-selection';
|
|
25
|
-
import 'codemirror/addon/selection/selection-pointer';
|
|
26
|
-
import 'codemirror/addon/edit/trailingspace.js';
|
|
27
|
-
import 'codemirror/keymap/emacs.js';
|
|
28
|
-
import 'codemirror/keymap/sublime.js';
|
|
29
|
-
import { Mode } from './mode';
|
|
5
|
+
import { EditorState, Extension, StateCommand, Text, Transaction } from '@codemirror/state';
|
|
6
|
+
import { Command, EditorView } from '@codemirror/view';
|
|
7
|
+
import { Configuration } from './editorconfiguration';
|
|
8
|
+
import './codemirror-ipython';
|
|
9
|
+
import './codemirror-ipythongfm';
|
|
30
10
|
/**
|
|
31
11
|
* CodeMirror editor.
|
|
32
12
|
*/
|
|
@@ -39,6 +19,7 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
39
19
|
* Initialize the editor binding.
|
|
40
20
|
*/
|
|
41
21
|
private _initializeEditorBinding;
|
|
22
|
+
save: () => void;
|
|
42
23
|
/**
|
|
43
24
|
* A signal emitted when either the top or bottom edge is requested.
|
|
44
25
|
*/
|
|
@@ -60,11 +41,11 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
60
41
|
/**
|
|
61
42
|
* Get the codemirror editor wrapped by the editor.
|
|
62
43
|
*/
|
|
63
|
-
get editor():
|
|
44
|
+
get editor(): EditorView;
|
|
64
45
|
/**
|
|
65
46
|
* Get the codemirror doc wrapped by the widget.
|
|
66
47
|
*/
|
|
67
|
-
get doc():
|
|
48
|
+
get doc(): Text;
|
|
68
49
|
/**
|
|
69
50
|
* Get the number of lines in the editor.
|
|
70
51
|
*/
|
|
@@ -105,7 +86,8 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
105
86
|
* the costly update at the end, and not after every option
|
|
106
87
|
* is set.
|
|
107
88
|
*/
|
|
108
|
-
setOptions
|
|
89
|
+
setOptions(options: Partial<CodeMirrorEditor.IConfig>): void;
|
|
90
|
+
injectExtension(ext: Extension): void;
|
|
109
91
|
/**
|
|
110
92
|
* Returns the content for the given line number.
|
|
111
93
|
*/
|
|
@@ -142,34 +124,26 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
142
124
|
* Explicitly blur the editor.
|
|
143
125
|
*/
|
|
144
126
|
blur(): void;
|
|
145
|
-
/**
|
|
146
|
-
* Repaint editor.
|
|
147
|
-
*/
|
|
148
|
-
refresh(): void;
|
|
149
127
|
/**
|
|
150
128
|
* Refresh the editor if it is focused;
|
|
151
129
|
* otherwise postpone refreshing till focusing.
|
|
152
130
|
*/
|
|
153
131
|
resizeToFit(): void;
|
|
154
|
-
|
|
155
|
-
removeOverlay(mode: string | object): void;
|
|
156
|
-
getSearchCursor(query: string | RegExp, start?: CodeMirror.Position, caseFold?: boolean): CodeMirror.SearchCursor;
|
|
157
|
-
getCursor(start?: string): CodeMirror.Position;
|
|
158
|
-
get state(): any;
|
|
159
|
-
operation<T>(fn: () => T): T;
|
|
132
|
+
get state(): EditorState;
|
|
160
133
|
firstLine(): number;
|
|
161
134
|
lastLine(): number;
|
|
162
|
-
scrollIntoView(pos: {
|
|
163
|
-
from: CodeMirror.Position;
|
|
164
|
-
to: CodeMirror.Position;
|
|
165
|
-
}, margin: number): void;
|
|
166
|
-
scrollIntoViewCentered(pos: CodeMirror.Position): void;
|
|
167
135
|
cursorCoords(where: boolean, mode?: 'window' | 'page' | 'local'): {
|
|
168
136
|
left: number;
|
|
169
137
|
top: number;
|
|
170
138
|
bottom: number;
|
|
171
139
|
};
|
|
172
|
-
getRange(from:
|
|
140
|
+
getRange(from: {
|
|
141
|
+
line: number;
|
|
142
|
+
ch: number;
|
|
143
|
+
}, to: {
|
|
144
|
+
line: number;
|
|
145
|
+
ch: number;
|
|
146
|
+
}, separator?: string): string;
|
|
173
147
|
/**
|
|
174
148
|
* Add a keydown handler to the editor.
|
|
175
149
|
*
|
|
@@ -178,10 +152,6 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
178
152
|
* @returns A disposable that can be used to remove the handler.
|
|
179
153
|
*/
|
|
180
154
|
addKeydownHandler(handler: CodeEditor.KeydownHandler): IDisposable;
|
|
181
|
-
/**
|
|
182
|
-
* Set the size of the editor in pixels.
|
|
183
|
-
*/
|
|
184
|
-
setSize(dimension: CodeEditor.IDimension | null): void;
|
|
185
155
|
/**
|
|
186
156
|
* Reveal the given position in the editor.
|
|
187
157
|
*/
|
|
@@ -249,7 +219,11 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
249
219
|
/**
|
|
250
220
|
* Get the token at a given editor position.
|
|
251
221
|
*/
|
|
252
|
-
|
|
222
|
+
getTokenAt(offset: number): CodeEditor.IToken;
|
|
223
|
+
/**
|
|
224
|
+
* Get the token a the cursor position.
|
|
225
|
+
*/
|
|
226
|
+
getTokenAtCursor(): CodeEditor.IToken;
|
|
253
227
|
/**
|
|
254
228
|
* Insert a new indented line at the current cursor position.
|
|
255
229
|
*/
|
|
@@ -259,15 +233,11 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
259
233
|
*
|
|
260
234
|
* @param command - The name of the command to execute.
|
|
261
235
|
*/
|
|
262
|
-
execCommand(command:
|
|
236
|
+
execCommand(command: Command | StateCommand): void;
|
|
263
237
|
/**
|
|
264
238
|
* Handle keydown events from the editor.
|
|
265
239
|
*/
|
|
266
240
|
protected onKeydown(event: KeyboardEvent): boolean;
|
|
267
|
-
/**
|
|
268
|
-
* Converts selections to code mirror selections.
|
|
269
|
-
*/
|
|
270
|
-
private _toCodeMirrorSelections;
|
|
271
241
|
/**
|
|
272
242
|
* Handles a mime type change.
|
|
273
243
|
*/
|
|
@@ -280,6 +250,16 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
280
250
|
* Clean selections for the given uuid.
|
|
281
251
|
*/
|
|
282
252
|
private _cleanSelections;
|
|
253
|
+
private _buildMarkDecoration;
|
|
254
|
+
/**
|
|
255
|
+
* Converts the selection style to a text marker options.
|
|
256
|
+
*/
|
|
257
|
+
private _toMarkSpec;
|
|
258
|
+
/**
|
|
259
|
+
* Construct a caret element representing the position
|
|
260
|
+
* of a collaborator's cursor.
|
|
261
|
+
*/
|
|
262
|
+
private _getCaret;
|
|
283
263
|
/**
|
|
284
264
|
* Marks selections.
|
|
285
265
|
*/
|
|
@@ -292,14 +272,6 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
292
272
|
* Converts a code mirror selection to an editor selection.
|
|
293
273
|
*/
|
|
294
274
|
private _toSelection;
|
|
295
|
-
/**
|
|
296
|
-
* Converts the selection style to a text marker options.
|
|
297
|
-
*/
|
|
298
|
-
private _toTextMarkerOptions;
|
|
299
|
-
/**
|
|
300
|
-
* Converts an editor selection to a code mirror selection.
|
|
301
|
-
*/
|
|
302
|
-
private _toCodeMirrorSelection;
|
|
303
275
|
/**
|
|
304
276
|
* Convert a code mirror position to an editor position.
|
|
305
277
|
*/
|
|
@@ -308,14 +280,10 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
308
280
|
* Convert an editor position to a code mirror position.
|
|
309
281
|
*/
|
|
310
282
|
private _toCodeMirrorPosition;
|
|
311
|
-
/**
|
|
312
|
-
* Handle model value changes.
|
|
313
|
-
*/
|
|
314
|
-
private _onValueChanged;
|
|
315
283
|
/**
|
|
316
284
|
* Handles document changes.
|
|
317
285
|
*/
|
|
318
|
-
private
|
|
286
|
+
private _onDocChanged;
|
|
319
287
|
/**
|
|
320
288
|
* Handle the DOM events for the editor.
|
|
321
289
|
*
|
|
@@ -345,11 +313,6 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
345
313
|
* the position is no longer valid.
|
|
346
314
|
*/
|
|
347
315
|
private _clearHover;
|
|
348
|
-
/**
|
|
349
|
-
* Construct a caret element representing the position
|
|
350
|
-
* of a collaborator's cursor.
|
|
351
|
-
*/
|
|
352
|
-
private _getCaret;
|
|
353
316
|
/**
|
|
354
317
|
* Check for an out of sync editor.
|
|
355
318
|
*/
|
|
@@ -358,27 +321,29 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
358
321
|
private _trans;
|
|
359
322
|
private _model;
|
|
360
323
|
private _editor;
|
|
361
|
-
|
|
362
|
-
[key: string]: CodeMirror.TextMarker[] | undefined;
|
|
363
|
-
};
|
|
324
|
+
private _selectionMarkers;
|
|
364
325
|
private _caretHover;
|
|
365
|
-
private
|
|
326
|
+
private _config;
|
|
366
327
|
private _hoverTimeout;
|
|
367
328
|
private _hoverId;
|
|
368
329
|
private _keydownHandlers;
|
|
369
|
-
private _changeGuard;
|
|
370
330
|
private _selectionStyle;
|
|
371
331
|
private _uuid;
|
|
372
|
-
private _needsRefresh;
|
|
373
332
|
private _isDisposed;
|
|
374
333
|
private _lastChange;
|
|
375
334
|
private _poll;
|
|
376
335
|
private _yeditorBinding;
|
|
336
|
+
private _editorConfig;
|
|
337
|
+
private _addMark;
|
|
338
|
+
private _removeMark;
|
|
339
|
+
private _markField;
|
|
377
340
|
}
|
|
378
341
|
/**
|
|
379
342
|
* The namespace for `CodeMirrorEditor` statics.
|
|
380
343
|
*/
|
|
381
344
|
export declare namespace CodeMirrorEditor {
|
|
345
|
+
interface IConfig extends Configuration.IConfig {
|
|
346
|
+
}
|
|
382
347
|
/**
|
|
383
348
|
* The options used to initialize a code mirror editor.
|
|
384
349
|
*/
|
|
@@ -389,140 +354,20 @@ export declare namespace CodeMirrorEditor {
|
|
|
389
354
|
config?: Partial<IConfig>;
|
|
390
355
|
}
|
|
391
356
|
/**
|
|
392
|
-
* The
|
|
357
|
+
* The options used to set several options at once with reconfigure.
|
|
393
358
|
*/
|
|
394
|
-
interface
|
|
395
|
-
|
|
396
|
-
* The mode to use.
|
|
397
|
-
*/
|
|
398
|
-
mode?: string | Mode.IMode;
|
|
399
|
-
/**
|
|
400
|
-
* The theme to style the editor with.
|
|
401
|
-
* You must make sure the CSS file defining the corresponding
|
|
402
|
-
* .cm-s-[name] styles is loaded.
|
|
403
|
-
*/
|
|
404
|
-
theme?: string;
|
|
405
|
-
/**
|
|
406
|
-
* Whether to use the context-sensitive indentation that the mode provides
|
|
407
|
-
* (or just indent the same as the line before).
|
|
408
|
-
*/
|
|
409
|
-
smartIndent?: boolean;
|
|
410
|
-
/**
|
|
411
|
-
* Configures whether the editor should re-indent the current line when a
|
|
412
|
-
* character is typed that might change its proper indentation
|
|
413
|
-
* (only works if the mode supports indentation).
|
|
414
|
-
*/
|
|
415
|
-
electricChars?: boolean;
|
|
416
|
-
/**
|
|
417
|
-
* Configures the keymap to use. The default is "default", which is the
|
|
418
|
-
* only keymap defined in codemirror.js itself.
|
|
419
|
-
* Extra keymaps are found in the CodeMirror keymap directory.
|
|
420
|
-
*/
|
|
421
|
-
keyMap?: string;
|
|
422
|
-
/**
|
|
423
|
-
* Can be used to specify extra keybindings for the editor, alongside the
|
|
424
|
-
* ones defined by keyMap. Should be either null, or a valid keymap value.
|
|
425
|
-
*/
|
|
426
|
-
extraKeys?: CodeMirror.KeyMap | null;
|
|
427
|
-
/**
|
|
428
|
-
* Can be used to add extra gutters (beyond or instead of the line number
|
|
429
|
-
* gutter).
|
|
430
|
-
* Should be an array of CSS class names, each of which defines a width
|
|
431
|
-
* (and optionally a background),
|
|
432
|
-
* and which will be used to draw the background of the gutters.
|
|
433
|
-
* May include the CodeMirror-linenumbers class, in order to explicitly
|
|
434
|
-
* set the position of the line number gutter
|
|
435
|
-
* (it will default to be to the right of all other gutters).
|
|
436
|
-
* These class names are the keys passed to setGutterMarker.
|
|
437
|
-
*/
|
|
438
|
-
gutters?: string[];
|
|
439
|
-
/**
|
|
440
|
-
* Determines whether the gutter scrolls along with the content
|
|
441
|
-
* horizontally (false)
|
|
442
|
-
* or whether it stays fixed during horizontal scrolling (true,
|
|
443
|
-
* the default).
|
|
444
|
-
*/
|
|
445
|
-
fixedGutter?: boolean;
|
|
446
|
-
/**
|
|
447
|
-
* Whether the folding gutter should be drawn
|
|
448
|
-
*/
|
|
449
|
-
foldGutter?: boolean;
|
|
450
|
-
/**
|
|
451
|
-
* Whether the cursor should be drawn when a selection is active.
|
|
452
|
-
*/
|
|
453
|
-
showCursorWhenSelecting?: boolean;
|
|
454
|
-
/**
|
|
455
|
-
* When fixedGutter is on, and there is a horizontal scrollbar, by default
|
|
456
|
-
* the gutter will be visible to the left of this scrollbar. If this
|
|
457
|
-
* option is set to true, it will be covered by an element with class
|
|
458
|
-
* CodeMirror-gutter-filler.
|
|
459
|
-
*/
|
|
460
|
-
coverGutterNextToScrollbar?: boolean;
|
|
461
|
-
/**
|
|
462
|
-
* Controls whether drag-and-drop is enabled.
|
|
463
|
-
*/
|
|
464
|
-
dragDrop?: boolean;
|
|
465
|
-
/**
|
|
466
|
-
* Explicitly set the line separator for the editor.
|
|
467
|
-
* By default (value null), the document will be split on CRLFs as well as
|
|
468
|
-
* lone CRs and LFs, and a single LF will be used as line separator in all
|
|
469
|
-
* output (such as getValue). When a specific string is given, lines will
|
|
470
|
-
* only be split on that string, and output will, by default, use that
|
|
471
|
-
* same separator.
|
|
472
|
-
*/
|
|
473
|
-
lineSeparator?: string | null;
|
|
474
|
-
/**
|
|
475
|
-
* Chooses a scrollbar implementation. The default is "native", showing
|
|
476
|
-
* native scrollbars. The core library also provides the "null" style,
|
|
477
|
-
* which completely hides the scrollbars. Addons can implement additional
|
|
478
|
-
* scrollbar models.
|
|
479
|
-
*/
|
|
480
|
-
scrollbarStyle?: string;
|
|
481
|
-
/**
|
|
482
|
-
* When enabled, which is the default, doing copy or cut when there is no
|
|
483
|
-
* selection will copy or cut the whole lines that have cursors on them.
|
|
484
|
-
*/
|
|
485
|
-
lineWiseCopyCut?: boolean;
|
|
486
|
-
/**
|
|
487
|
-
* Whether to scroll past the end of the buffer.
|
|
488
|
-
*/
|
|
489
|
-
scrollPastEnd?: boolean;
|
|
490
|
-
/**
|
|
491
|
-
* Whether to give the wrapper of the line that contains the cursor the class
|
|
492
|
-
* CodeMirror-activeline, adds a background with the class
|
|
493
|
-
* CodeMirror-activeline-background, and adds the class
|
|
494
|
-
* CodeMirror-activeline-gutter to the line's gutter space is enabled.
|
|
495
|
-
*/
|
|
496
|
-
styleActiveLine: boolean | CodeMirror.StyleActiveLine;
|
|
497
|
-
/**
|
|
498
|
-
* Whether to causes the selected text to be marked with the CSS class
|
|
499
|
-
* CodeMirror-selectedtext. Useful to change the colour of the selection
|
|
500
|
-
* (in addition to the background).
|
|
501
|
-
*/
|
|
502
|
-
styleSelectedText: boolean;
|
|
503
|
-
/**
|
|
504
|
-
* Defines the mouse cursor appearance when hovering over the selection.
|
|
505
|
-
* It can be set to a string, like "pointer", or to true,
|
|
506
|
-
* in which case the "default" (arrow) cursor will be used.
|
|
507
|
-
*/
|
|
508
|
-
selectionPointer: boolean | string;
|
|
359
|
+
interface IConfigOptions<K extends keyof IConfig> {
|
|
360
|
+
K: IConfig[K];
|
|
509
361
|
}
|
|
510
362
|
/**
|
|
511
363
|
* The default configuration options for an editor.
|
|
512
364
|
*/
|
|
513
365
|
const defaultConfig: Required<IConfig>;
|
|
514
366
|
/**
|
|
515
|
-
*
|
|
516
|
-
*/
|
|
517
|
-
interface IConfigOptions<K extends keyof IConfig> {
|
|
518
|
-
K: IConfig[K];
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Add a command to CodeMirror.
|
|
522
|
-
*
|
|
523
|
-
* @param name - The name of the command to add.
|
|
524
|
-
*
|
|
525
|
-
* @param command - The command function.
|
|
367
|
+
* Indent or insert a tab as appropriate.
|
|
526
368
|
*/
|
|
527
|
-
function
|
|
369
|
+
function indentMoreOrInsertTab(target: {
|
|
370
|
+
state: EditorState;
|
|
371
|
+
dispatch: (transaction: Transaction) => void;
|
|
372
|
+
}): boolean;
|
|
528
373
|
}
|