@jupyterlab/codemirror 4.0.0-alpha.8 → 4.0.0-beta.0
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-ipythongfm.d.ts +9 -3
- package/lib/codemirror-ipythongfm.js +52 -30
- package/lib/codemirror-ipythongfm.js.map +1 -1
- package/lib/commands.d.ts +13 -0
- package/lib/commands.js +32 -0
- package/lib/commands.js.map +1 -0
- package/lib/editor.d.ts +48 -273
- package/lib/editor.js +220 -819
- package/lib/editor.js.map +1 -1
- package/lib/extension.d.ts +236 -0
- package/lib/extension.js +696 -0
- package/lib/extension.js.map +1 -0
- package/lib/extensions/customStyle.d.ts +25 -0
- package/lib/extensions/customStyle.js +51 -0
- package/lib/extensions/customStyle.js.map +1 -0
- package/lib/extensions/index.d.ts +3 -0
- package/lib/extensions/index.js +8 -0
- package/lib/extensions/index.js.map +1 -0
- package/lib/extensions/rulers.d.ts +8 -0
- package/lib/extensions/rulers.js +85 -0
- package/lib/extensions/rulers.js.map +1 -0
- package/lib/extensions/ybinding.d.ts +129 -0
- package/lib/extensions/ybinding.js +229 -0
- package/lib/extensions/ybinding.js.map +1 -0
- package/lib/factory.d.ts +15 -5
- package/lib/factory.js +53 -24
- package/lib/factory.js.map +1 -1
- package/lib/index.d.ts +7 -19
- package/lib/index.js +7 -23
- package/lib/index.js.map +1 -1
- package/lib/language.d.ts +96 -0
- package/lib/language.js +1687 -0
- package/lib/language.js.map +1 -0
- package/lib/mimetype.d.ts +3 -0
- package/lib/mimetype.js +16 -5
- package/lib/mimetype.js.map +1 -1
- package/lib/searchprovider.d.ts +219 -0
- package/lib/searchprovider.js +640 -0
- package/lib/searchprovider.js.map +1 -0
- package/lib/theme.d.ts +57 -0
- package/lib/theme.js +194 -0
- package/lib/theme.js.map +1 -0
- package/lib/token.d.ts +375 -0
- package/lib/token.js +18 -0
- package/lib/token.js.map +1 -0
- package/package.json +45 -41
- package/src/codemirror-ipythongfm.ts +109 -0
- package/src/commands.ts +34 -0
- package/src/editor.ts +783 -0
- package/src/extension.ts +890 -0
- package/src/extensions/customStyle.ts +79 -0
- package/src/extensions/index.ts +8 -0
- package/src/extensions/rulers.ts +112 -0
- package/src/extensions/ybinding.ts +295 -0
- package/src/factory.ts +100 -0
- package/src/index.ts +17 -0
- package/src/language.ts +1726 -0
- package/src/mimetype.ts +54 -0
- package/src/searchprovider.ts +813 -0
- package/src/theme.ts +219 -0
- package/src/token.ts +436 -0
- package/src/typings.d.ts +13 -0
- package/style/base.css +33 -187
- package/style/index.css +1 -7
- package/style/index.js +1 -7
- package/lib/codemirror-ipython.d.ts +0 -2
- package/lib/codemirror-ipython.js +0 -30
- package/lib/codemirror-ipython.js.map +0 -1
- package/lib/mode.d.ts +0 -82
- package/lib/mode.js +0 -150
- package/lib/mode.js.map +0 -1
- package/lib/syntaxstatus.d.ts +0 -67
- package/lib/syntaxstatus.js +0 -140
- package/lib/syntaxstatus.js.map +0 -1
- package/lib/tokens.d.ts +0 -18
- package/lib/tokens.js +0 -8
- package/lib/tokens.js.map +0 -1
- package/typings/codemirror/codemirror.d.ts +0 -227
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Define an IPython GFM (GitHub Flavored Markdown) mode.
|
|
3
|
+
*
|
|
4
|
+
* Is just a slightly altered GFM Mode with support for LaTeX.
|
|
5
|
+
* LaTeX support was supported by Codemirror GFM as of
|
|
6
|
+
* https://github.com/codemirror/CodeMirror/pull/567
|
|
7
|
+
* But was later removed in
|
|
8
|
+
* https://github.com/codemirror/CodeMirror/commit/d9c9f1b1ffe984aee41307f3e927f80d1f23590c
|
|
9
|
+
*/
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
|
-
|
|
3
|
+
// TODO: add support for LaTeX
|
|
4
|
+
// This should be coded as an extension for https://github.com/lezer-parser/markdown
|
|
5
|
+
// see https://github.com/lezer-parser/markdown/blob/main/src/extension.ts for examples
|
|
6
|
+
// Then this extension can be passed to the markdown function above:
|
|
7
|
+
//
|
|
8
|
+
// load: () => {
|
|
9
|
+
// return import('@codemirror/lang-markdown').then(m => m.markdown({extensions: latex}));
|
|
10
|
+
// }
|
|
11
|
+
/*import CodeMirror from 'codemirror';
|
|
4
12
|
import 'codemirror/addon/mode/multiplex';
|
|
5
13
|
import 'codemirror/mode/gfm/gfm';
|
|
6
14
|
import 'codemirror/mode/stex/stex';
|
|
15
|
+
*/
|
|
7
16
|
/**
|
|
8
17
|
* Define an IPython GFM (GitHub Flavored Markdown) mode.
|
|
9
18
|
*
|
|
@@ -13,74 +22,87 @@ import 'codemirror/mode/stex/stex';
|
|
|
13
22
|
* But was later removed in
|
|
14
23
|
* https://github.com/codemirror/CodeMirror/commit/d9c9f1b1ffe984aee41307f3e927f80d1f23590c
|
|
15
24
|
*/
|
|
16
|
-
CodeMirror.defineMode(
|
|
25
|
+
/*CodeMirror.defineMode(
|
|
26
|
+
'ipythongfm',
|
|
27
|
+
(config: CodeMirror.EditorConfiguration, modeOptions?: any) => {
|
|
17
28
|
const gfmMode = CodeMirror.getMode(config, {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
name: 'gfm',
|
|
30
|
+
// Override list3 with an under-used token, rather than `keyword`
|
|
31
|
+
tokenTypeOverrides: { list3: 'string-2' }
|
|
21
32
|
});
|
|
22
33
|
const texMode = CodeMirror.getMode(config, {
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
name: 'stex',
|
|
35
|
+
inMathMode: true
|
|
25
36
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
|
|
38
|
+
return CodeMirror.multiplexingMode(
|
|
39
|
+
gfmMode,
|
|
40
|
+
// force parsing inline code and code blocks with gfmMode to prevent
|
|
41
|
+
// parsing them as tex see:
|
|
42
|
+
// https://github.com/jupyterlab/jupyterlab/issues/6774
|
|
43
|
+
{
|
|
31
44
|
open: '<code>',
|
|
32
45
|
close: '</code>',
|
|
33
46
|
mode: gfmMode,
|
|
34
47
|
parseDelimiters: true
|
|
35
|
-
|
|
48
|
+
},
|
|
49
|
+
{
|
|
36
50
|
open: '<pre>',
|
|
37
51
|
close: '</pre>',
|
|
38
52
|
mode: gfmMode,
|
|
39
53
|
parseDelimiters: true
|
|
40
|
-
|
|
54
|
+
},
|
|
55
|
+
{
|
|
41
56
|
open: '```',
|
|
42
57
|
close: '```',
|
|
43
58
|
mode: gfmMode,
|
|
44
59
|
parseDelimiters: true
|
|
45
|
-
|
|
60
|
+
},
|
|
61
|
+
{
|
|
46
62
|
open: '`',
|
|
47
63
|
close: '`',
|
|
48
64
|
mode: gfmMode,
|
|
49
65
|
parseDelimiters: true
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
66
|
+
},
|
|
67
|
+
// only if we did not match a code element or block,
|
|
68
|
+
// then try do parse using the tex mode
|
|
69
|
+
{
|
|
54
70
|
open: '$$',
|
|
55
71
|
close: '$$',
|
|
56
72
|
mode: texMode,
|
|
57
73
|
delimStyle: 'delimit'
|
|
58
|
-
|
|
74
|
+
},
|
|
75
|
+
{
|
|
59
76
|
// `$math mode$` is only matched if both opening
|
|
60
77
|
// and closing $ are in the same line
|
|
61
78
|
open: /\$(?=.*\$)/,
|
|
62
79
|
close: '$',
|
|
63
80
|
mode: texMode,
|
|
64
81
|
delimStyle: 'delimit'
|
|
65
|
-
|
|
82
|
+
},
|
|
83
|
+
{
|
|
66
84
|
open: '\\(',
|
|
67
85
|
close: '\\)',
|
|
68
86
|
mode: texMode,
|
|
69
87
|
delimStyle: 'delimit'
|
|
70
|
-
|
|
88
|
+
},
|
|
89
|
+
{
|
|
71
90
|
open: '\\[',
|
|
72
91
|
close: '\\]',
|
|
73
92
|
mode: texMode,
|
|
74
93
|
delimStyle: 'delimit'
|
|
75
|
-
|
|
76
|
-
|
|
94
|
+
}
|
|
95
|
+
// .. more multiplexed styles can follow here
|
|
77
96
|
);
|
|
78
|
-
},
|
|
97
|
+
},
|
|
98
|
+
'gfm'
|
|
99
|
+
);
|
|
100
|
+
|
|
79
101
|
CodeMirror.defineMIME('text/x-ipythongfm', 'ipythongfm');
|
|
80
102
|
CodeMirror.modeInfo.push({
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
})
|
|
103
|
+
ext: [],
|
|
104
|
+
mime: 'text/x-ipythongfm',
|
|
105
|
+
mode: 'ipythongfm',
|
|
106
|
+
name: 'ipythongfm'
|
|
107
|
+
});*/
|
|
86
108
|
//# 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,
|
|
1
|
+
{"version":3,"file":"codemirror-ipythongfm.js","sourceRoot":"","sources":["../src/codemirror-ipythongfm.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,8BAA8B;AAC9B,oFAAoF;AACpF,uFAAuF;AACvF,oEAAoE;AACpE,EAAE;AACF,gBAAgB;AAChB,2FAA2F;AAC3F,IAAI;AAEJ;;;;EAIE;AACF;;;;;;;;GAQG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkFK"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EditorState, Transaction } from '@codemirror/state';
|
|
2
|
+
/**
|
|
3
|
+
* CodeMirror commands namespace
|
|
4
|
+
*/
|
|
5
|
+
export declare namespace StateCommands {
|
|
6
|
+
/**
|
|
7
|
+
* Indent or insert a tab as appropriate.
|
|
8
|
+
*/
|
|
9
|
+
function indentMoreOrInsertTab(target: {
|
|
10
|
+
state: EditorState;
|
|
11
|
+
dispatch: (transaction: Transaction) => void;
|
|
12
|
+
}): boolean;
|
|
13
|
+
}
|
package/lib/commands.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Jupyter Development Team.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { indentMore, insertTab } from '@codemirror/commands';
|
|
6
|
+
/**
|
|
7
|
+
* CodeMirror commands namespace
|
|
8
|
+
*/
|
|
9
|
+
export var StateCommands;
|
|
10
|
+
(function (StateCommands) {
|
|
11
|
+
/**
|
|
12
|
+
* Indent or insert a tab as appropriate.
|
|
13
|
+
*/
|
|
14
|
+
function indentMoreOrInsertTab(target) {
|
|
15
|
+
const arg = { state: target.state, dispatch: target.dispatch };
|
|
16
|
+
const from = target.state.selection.main.from;
|
|
17
|
+
const to = target.state.selection.main.to;
|
|
18
|
+
if (from != to) {
|
|
19
|
+
return indentMore(arg);
|
|
20
|
+
}
|
|
21
|
+
const line = target.state.doc.lineAt(from);
|
|
22
|
+
const before = target.state.doc.slice(line.from, from).toString();
|
|
23
|
+
if (/^\s*$/.test(before)) {
|
|
24
|
+
return indentMore(arg);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return insertTab(arg);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
StateCommands.indentMoreOrInsertTab = indentMoreOrInsertTab;
|
|
31
|
+
})(StateCommands || (StateCommands = {}));
|
|
32
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAG7D;;GAEG;AACH,MAAM,KAAW,aAAa,CAsB7B;AAtBD,WAAiB,aAAa;IAC5B;;OAEG;IACH,SAAgB,qBAAqB,CAAC,MAGrC;QACC,MAAM,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC/D,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;QAC9C,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,IAAI,IAAI,IAAI,EAAE,EAAE;YACd,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC;SACxB;QACD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;QAClE,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YACxB,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC;SACxB;aAAM;YACL,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;SACvB;IACH,CAAC;IAjBe,mCAAqB,wBAiBpC,CAAA;AACH,CAAC,EAtBgB,aAAa,KAAb,aAAa,QAsB7B"}
|
package/lib/editor.d.ts
CHANGED
|
@@ -1,32 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { EditorState, Extension, StateCommand, Text } from '@codemirror/state';
|
|
2
|
+
import { Command, EditorView } from '@codemirror/view';
|
|
2
3
|
import { CodeEditor } from '@jupyterlab/codeeditor';
|
|
3
|
-
import { ITranslator } from '@jupyterlab/translation';
|
|
4
|
-
import { IDisposable } from '@lumino/disposable';
|
|
5
4
|
import { Signal } from '@lumino/signaling';
|
|
6
|
-
import
|
|
7
|
-
import '
|
|
8
|
-
import 'codemirror/addon/display/rulers.js';
|
|
9
|
-
import 'codemirror/addon/edit/closebrackets.js';
|
|
10
|
-
import 'codemirror/addon/edit/matchbrackets.js';
|
|
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 './codemirror-ipythongfm';
|
|
6
|
+
import { IEditorExtensionRegistry, IEditorLanguageRegistry, IExtensionsHandler } from './token';
|
|
30
7
|
/**
|
|
31
8
|
* CodeMirror editor.
|
|
32
9
|
*/
|
|
@@ -35,10 +12,6 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
35
12
|
* Construct a CodeMirror editor.
|
|
36
13
|
*/
|
|
37
14
|
constructor(options: CodeMirrorEditor.IOptions);
|
|
38
|
-
/**
|
|
39
|
-
* Initialize the editor binding.
|
|
40
|
-
*/
|
|
41
|
-
private _initializeEditorBinding;
|
|
42
15
|
/**
|
|
43
16
|
* A signal emitted when either the top or bottom edge is requested.
|
|
44
17
|
*/
|
|
@@ -52,19 +25,14 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
52
25
|
*/
|
|
53
26
|
get uuid(): string;
|
|
54
27
|
set uuid(value: string);
|
|
55
|
-
/**
|
|
56
|
-
* The selection style of this editor.
|
|
57
|
-
*/
|
|
58
|
-
get selectionStyle(): CodeEditor.ISelectionStyle;
|
|
59
|
-
set selectionStyle(value: CodeEditor.ISelectionStyle);
|
|
60
28
|
/**
|
|
61
29
|
* Get the codemirror editor wrapped by the editor.
|
|
62
30
|
*/
|
|
63
|
-
get editor():
|
|
31
|
+
get editor(): EditorView;
|
|
64
32
|
/**
|
|
65
33
|
* Get the codemirror doc wrapped by the widget.
|
|
66
34
|
*/
|
|
67
|
-
get doc():
|
|
35
|
+
get doc(): Text;
|
|
68
36
|
/**
|
|
69
37
|
* Get the number of lines in the editor.
|
|
70
38
|
*/
|
|
@@ -92,11 +60,15 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
92
60
|
/**
|
|
93
61
|
* Get a config option for the editor.
|
|
94
62
|
*/
|
|
95
|
-
getOption
|
|
63
|
+
getOption(option: string): unknown;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the option exists or not.
|
|
66
|
+
*/
|
|
67
|
+
hasOption(option: string): boolean;
|
|
96
68
|
/**
|
|
97
69
|
* Set a config option for the editor.
|
|
98
70
|
*/
|
|
99
|
-
setOption
|
|
71
|
+
setOption(option: string, value: unknown): void;
|
|
100
72
|
/**
|
|
101
73
|
* Set config options for the editor.
|
|
102
74
|
*
|
|
@@ -105,7 +77,15 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
105
77
|
* the costly update at the end, and not after every option
|
|
106
78
|
* is set.
|
|
107
79
|
*/
|
|
108
|
-
setOptions(options:
|
|
80
|
+
setOptions(options: Record<string, any>): void;
|
|
81
|
+
/**
|
|
82
|
+
* Inject an extension into the editor
|
|
83
|
+
*
|
|
84
|
+
* @alpha
|
|
85
|
+
* @experimental
|
|
86
|
+
* @param ext CodeMirror 6 extension
|
|
87
|
+
*/
|
|
88
|
+
injectExtension(ext: Extension): void;
|
|
109
89
|
/**
|
|
110
90
|
* Returns the content for the given line number.
|
|
111
91
|
*/
|
|
@@ -142,46 +122,21 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
142
122
|
* Explicitly blur the editor.
|
|
143
123
|
*/
|
|
144
124
|
blur(): void;
|
|
145
|
-
|
|
146
|
-
* Repaint editor.
|
|
147
|
-
*/
|
|
148
|
-
refresh(): void;
|
|
149
|
-
/**
|
|
150
|
-
* Refresh the editor if it is focused;
|
|
151
|
-
* otherwise postpone refreshing till focusing.
|
|
152
|
-
*/
|
|
153
|
-
resizeToFit(): void;
|
|
154
|
-
addOverlay(mode: string | object, options?: object): void;
|
|
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;
|
|
125
|
+
get state(): EditorState;
|
|
160
126
|
firstLine(): number;
|
|
161
127
|
lastLine(): number;
|
|
162
|
-
scrollIntoView(pos: {
|
|
163
|
-
from: CodeMirror.Position;
|
|
164
|
-
to: CodeMirror.Position;
|
|
165
|
-
}, margin: number): void;
|
|
166
|
-
scrollIntoViewCentered(pos: CodeMirror.Position): void;
|
|
167
128
|
cursorCoords(where: boolean, mode?: 'window' | 'page' | 'local'): {
|
|
168
129
|
left: number;
|
|
169
130
|
top: number;
|
|
170
131
|
bottom: number;
|
|
171
132
|
};
|
|
172
|
-
getRange(from:
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
*/
|
|
180
|
-
addKeydownHandler(handler: CodeEditor.KeydownHandler): IDisposable;
|
|
181
|
-
/**
|
|
182
|
-
* Set the size of the editor in pixels.
|
|
183
|
-
*/
|
|
184
|
-
setSize(dimension: CodeEditor.IDimension | null): void;
|
|
133
|
+
getRange(from: {
|
|
134
|
+
line: number;
|
|
135
|
+
ch: number;
|
|
136
|
+
}, to: {
|
|
137
|
+
line: number;
|
|
138
|
+
ch: number;
|
|
139
|
+
}, separator?: string): string;
|
|
185
140
|
/**
|
|
186
141
|
* Reveal the given position in the editor.
|
|
187
142
|
*/
|
|
@@ -239,6 +194,8 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
239
194
|
/**
|
|
240
195
|
* Replaces the current selection with the given text.
|
|
241
196
|
*
|
|
197
|
+
* Behaviour for multiple selections is undefined.
|
|
198
|
+
*
|
|
242
199
|
* @param text The text to be inserted.
|
|
243
200
|
*/
|
|
244
201
|
replaceSelection(text: string): void;
|
|
@@ -249,7 +206,11 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
249
206
|
/**
|
|
250
207
|
* Get the token at a given editor position.
|
|
251
208
|
*/
|
|
252
|
-
|
|
209
|
+
getTokenAt(offset: number): CodeEditor.IToken;
|
|
210
|
+
/**
|
|
211
|
+
* Get the token a the cursor position.
|
|
212
|
+
*/
|
|
213
|
+
getTokenAtCursor(): CodeEditor.IToken;
|
|
253
214
|
/**
|
|
254
215
|
* Insert a new indented line at the current cursor position.
|
|
255
216
|
*/
|
|
@@ -259,31 +220,16 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
259
220
|
*
|
|
260
221
|
* @param command - The name of the command to execute.
|
|
261
222
|
*/
|
|
262
|
-
execCommand(command:
|
|
223
|
+
execCommand(command: Command | StateCommand): void;
|
|
224
|
+
protected onConfigChanged(configurator: IExtensionsHandler, changes: Record<string, any>): void;
|
|
263
225
|
/**
|
|
264
226
|
* Handle keydown events from the editor.
|
|
265
227
|
*/
|
|
266
228
|
protected onKeydown(event: KeyboardEvent): boolean;
|
|
267
|
-
/**
|
|
268
|
-
* Converts selections to code mirror selections.
|
|
269
|
-
*/
|
|
270
|
-
private _toCodeMirrorSelections;
|
|
271
229
|
/**
|
|
272
230
|
* Handles a mime type change.
|
|
273
231
|
*/
|
|
274
232
|
private _onMimeTypeChanged;
|
|
275
|
-
/**
|
|
276
|
-
* Handles a selections change.
|
|
277
|
-
*/
|
|
278
|
-
private _onSelectionsChanged;
|
|
279
|
-
/**
|
|
280
|
-
* Clean selections for the given uuid.
|
|
281
|
-
*/
|
|
282
|
-
private _cleanSelections;
|
|
283
|
-
/**
|
|
284
|
-
* Marks selections.
|
|
285
|
-
*/
|
|
286
|
-
private _markSelections;
|
|
287
233
|
/**
|
|
288
234
|
* Handles a cursor activity event.
|
|
289
235
|
*/
|
|
@@ -292,14 +238,6 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
292
238
|
* Converts a code mirror selection to an editor selection.
|
|
293
239
|
*/
|
|
294
240
|
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
241
|
/**
|
|
304
242
|
* Convert a code mirror position to an editor position.
|
|
305
243
|
*/
|
|
@@ -308,14 +246,10 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
308
246
|
* Convert an editor position to a code mirror position.
|
|
309
247
|
*/
|
|
310
248
|
private _toCodeMirrorPosition;
|
|
311
|
-
/**
|
|
312
|
-
* Handle model value changes.
|
|
313
|
-
*/
|
|
314
|
-
private _onValueChanged;
|
|
315
249
|
/**
|
|
316
250
|
* Handles document changes.
|
|
317
251
|
*/
|
|
318
|
-
private
|
|
252
|
+
private _onDocChanged;
|
|
319
253
|
/**
|
|
320
254
|
* Handle the DOM events for the editor.
|
|
321
255
|
*
|
|
@@ -335,45 +269,13 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
335
269
|
* Handle `blur` events for the editor.
|
|
336
270
|
*/
|
|
337
271
|
private _evtBlur;
|
|
338
|
-
|
|
339
|
-
* Handle `scroll` events for the editor.
|
|
340
|
-
*/
|
|
341
|
-
private _evtScroll;
|
|
342
|
-
/**
|
|
343
|
-
* Clear the hover for a caret, due to things like
|
|
344
|
-
* scrolling, resizing, deactivation, etc, where
|
|
345
|
-
* the position is no longer valid.
|
|
346
|
-
*/
|
|
347
|
-
private _clearHover;
|
|
348
|
-
/**
|
|
349
|
-
* Construct a caret element representing the position
|
|
350
|
-
* of a collaborator's cursor.
|
|
351
|
-
*/
|
|
352
|
-
private _getCaret;
|
|
353
|
-
/**
|
|
354
|
-
* Check for an out of sync editor.
|
|
355
|
-
*/
|
|
356
|
-
private _checkSync;
|
|
357
|
-
protected translator: ITranslator;
|
|
358
|
-
private _trans;
|
|
359
|
-
private _model;
|
|
272
|
+
private _configurator;
|
|
360
273
|
private _editor;
|
|
361
|
-
protected selectionMarkers: {
|
|
362
|
-
[key: string]: CodeMirror.TextMarker[] | undefined;
|
|
363
|
-
};
|
|
364
|
-
private _caretHover;
|
|
365
|
-
private readonly _config;
|
|
366
|
-
private _hoverTimeout;
|
|
367
|
-
private _hoverId;
|
|
368
|
-
private _keydownHandlers;
|
|
369
|
-
private _changeGuard;
|
|
370
|
-
private _selectionStyle;
|
|
371
|
-
private _uuid;
|
|
372
|
-
private _needsRefresh;
|
|
373
274
|
private _isDisposed;
|
|
374
|
-
private
|
|
375
|
-
private
|
|
376
|
-
private
|
|
275
|
+
private _language;
|
|
276
|
+
private _languages;
|
|
277
|
+
private _model;
|
|
278
|
+
private _uuid;
|
|
377
279
|
}
|
|
378
280
|
/**
|
|
379
281
|
* The namespace for `CodeMirrorEditor` statics.
|
|
@@ -384,139 +286,12 @@ export declare namespace CodeMirrorEditor {
|
|
|
384
286
|
*/
|
|
385
287
|
interface IOptions extends CodeEditor.IOptions {
|
|
386
288
|
/**
|
|
387
|
-
*
|
|
388
|
-
*/
|
|
389
|
-
config?: Partial<IConfig>;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* The configuration options for a codemirror editor.
|
|
393
|
-
*/
|
|
394
|
-
interface IConfig extends CodeEditor.IConfig {
|
|
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).
|
|
289
|
+
* CodeMirror extensions registry
|
|
444
290
|
*/
|
|
445
|
-
|
|
291
|
+
extensionsRegistry?: IEditorExtensionRegistry;
|
|
446
292
|
/**
|
|
447
|
-
*
|
|
293
|
+
* CodeMirror languages registry
|
|
448
294
|
*/
|
|
449
|
-
|
|
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;
|
|
295
|
+
languages?: IEditorLanguageRegistry;
|
|
509
296
|
}
|
|
510
|
-
/**
|
|
511
|
-
* The default configuration options for an editor.
|
|
512
|
-
*/
|
|
513
|
-
const defaultConfig: Required<IConfig>;
|
|
514
|
-
/**
|
|
515
|
-
* Add a command to CodeMirror.
|
|
516
|
-
*
|
|
517
|
-
* @param name - The name of the command to add.
|
|
518
|
-
*
|
|
519
|
-
* @param command - The command function.
|
|
520
|
-
*/
|
|
521
|
-
function addCommand(name: string, command: (cm: CodeMirror.Editor) => void): void;
|
|
522
297
|
}
|