@jupyterlab/codemirror 4.0.0-alpha.9 → 4.0.0-beta.1
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
package/lib/syntaxstatus.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { interactiveItem, showPopup, TextItem } from '@jupyterlab/statusbar';
|
|
2
|
-
import { nullTranslator } from '@jupyterlab/translation';
|
|
3
|
-
import { VDomModel, VDomRenderer } from '@jupyterlab/ui-components';
|
|
4
|
-
import { Menu } from '@lumino/widgets';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { Mode } from '.';
|
|
7
|
-
/**
|
|
8
|
-
* A pure function that returns a tsx component for an editor syntax item.
|
|
9
|
-
*
|
|
10
|
-
* @param props: the props for the component.
|
|
11
|
-
*
|
|
12
|
-
* @returns an editor syntax component.
|
|
13
|
-
*/
|
|
14
|
-
function EditorSyntaxComponent(props) {
|
|
15
|
-
return React.createElement(TextItem, { source: props.mode, onClick: props.handleClick });
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* StatusBar item to change the language syntax highlighting of the file editor.
|
|
19
|
-
*/
|
|
20
|
-
export class EditorSyntaxStatus extends VDomRenderer {
|
|
21
|
-
/**
|
|
22
|
-
* Construct a new VDomRenderer for the status item.
|
|
23
|
-
*/
|
|
24
|
-
constructor(opts) {
|
|
25
|
-
super(new EditorSyntaxStatus.Model());
|
|
26
|
-
/**
|
|
27
|
-
* Create a menu for selecting the mode of the editor.
|
|
28
|
-
*/
|
|
29
|
-
this._handleClick = () => {
|
|
30
|
-
const modeMenu = new Menu({ commands: this._commands });
|
|
31
|
-
const command = 'codemirror:change-mode';
|
|
32
|
-
if (this._popup) {
|
|
33
|
-
this._popup.dispose();
|
|
34
|
-
}
|
|
35
|
-
Mode.getModeInfo()
|
|
36
|
-
.sort((a, b) => {
|
|
37
|
-
const aName = a.name || '';
|
|
38
|
-
const bName = b.name || '';
|
|
39
|
-
return aName.localeCompare(bName);
|
|
40
|
-
})
|
|
41
|
-
.forEach(spec => {
|
|
42
|
-
if (spec.mode.indexOf('brainf') === 0) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const args = {
|
|
46
|
-
insertSpaces: true,
|
|
47
|
-
name: spec.name
|
|
48
|
-
};
|
|
49
|
-
modeMenu.addItem({
|
|
50
|
-
command,
|
|
51
|
-
args
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
this._popup = showPopup({
|
|
55
|
-
body: modeMenu,
|
|
56
|
-
anchor: this,
|
|
57
|
-
align: 'left'
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
this._popup = null;
|
|
61
|
-
this._commands = opts.commands;
|
|
62
|
-
this.translator = opts.translator || nullTranslator;
|
|
63
|
-
const trans = this.translator.load('jupyterlab');
|
|
64
|
-
this.addClass(interactiveItem);
|
|
65
|
-
this.title.caption = trans.__('Change text editor syntax highlighting');
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Render the status item.
|
|
69
|
-
*/
|
|
70
|
-
render() {
|
|
71
|
-
if (!this.model) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
return (React.createElement(EditorSyntaxComponent, { mode: this.model.mode, handleClick: this._handleClick }));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* A namespace for EditorSyntax statics.
|
|
79
|
-
*/
|
|
80
|
-
(function (EditorSyntaxStatus) {
|
|
81
|
-
/**
|
|
82
|
-
* A VDomModel for the current editor/mode combination.
|
|
83
|
-
*/
|
|
84
|
-
class Model extends VDomModel {
|
|
85
|
-
constructor() {
|
|
86
|
-
super(...arguments);
|
|
87
|
-
/**
|
|
88
|
-
* If the editor mode changes, update the model.
|
|
89
|
-
*/
|
|
90
|
-
this._onMIMETypeChange = (mode, change) => {
|
|
91
|
-
const oldMode = this._mode;
|
|
92
|
-
const spec = Mode.findByMIME(change.newValue);
|
|
93
|
-
this._mode = spec.name || spec.mode;
|
|
94
|
-
this._triggerChange(oldMode, this._mode);
|
|
95
|
-
};
|
|
96
|
-
this._mode = '';
|
|
97
|
-
this._editor = null;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* The current mode for the editor. If no editor is present,
|
|
101
|
-
* returns the empty string.
|
|
102
|
-
*/
|
|
103
|
-
get mode() {
|
|
104
|
-
return this._mode;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* The current editor for the application editor tracker.
|
|
108
|
-
*/
|
|
109
|
-
get editor() {
|
|
110
|
-
return this._editor;
|
|
111
|
-
}
|
|
112
|
-
set editor(editor) {
|
|
113
|
-
const oldEditor = this._editor;
|
|
114
|
-
if (oldEditor !== null) {
|
|
115
|
-
oldEditor.model.mimeTypeChanged.disconnect(this._onMIMETypeChange);
|
|
116
|
-
}
|
|
117
|
-
const oldMode = this._mode;
|
|
118
|
-
this._editor = editor;
|
|
119
|
-
if (this._editor === null) {
|
|
120
|
-
this._mode = '';
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
const spec = Mode.findByMIME(this._editor.model.mimeType);
|
|
124
|
-
this._mode = spec.name || spec.mode;
|
|
125
|
-
this._editor.model.mimeTypeChanged.connect(this._onMIMETypeChange);
|
|
126
|
-
}
|
|
127
|
-
this._triggerChange(oldMode, this._mode);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Trigger a rerender of the model.
|
|
131
|
-
*/
|
|
132
|
-
_triggerChange(oldState, newState) {
|
|
133
|
-
if (oldState !== newState) {
|
|
134
|
-
this.stateChanged.emit(void 0);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
EditorSyntaxStatus.Model = Model;
|
|
139
|
-
})(EditorSyntaxStatus || (EditorSyntaxStatus = {}));
|
|
140
|
-
//# sourceMappingURL=syntaxstatus.js.map
|
package/lib/syntaxstatus.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"syntaxstatus.js","sourceRoot":"","sources":["../src/syntaxstatus.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAEf,SAAS,EACT,QAAQ,EACT,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAe,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGpE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;AAwBzB;;;;;;GAMG;AACH,SAAS,qBAAqB,CAC5B,KAAmC;IAEnC,OAAO,oBAAC,QAAQ,IAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,WAAW,GAAI,CAAC;AACtE,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,YAAsC;IAC5E;;OAEG;IACH,YAAY,IAAi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AAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC;YAC/B,IAAI,SAAS,KAAK,IAAI,EAAE;gBACtB,SAAS,CAAC,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACpE;YACD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC;YAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;YACtB,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;gBACzB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;aACjB;iBAAM;gBACL,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAC1D,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC;gBAEpC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACpE;YAED,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC;QAgBD;;WAEG;QACK,cAAc,CAAC,QAAgB,EAAE,QAAgB;YACvD,IAAI,QAAQ,KAAK,QAAQ,EAAE;gBACzB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;aAChC;QACH,CAAC;KAIF;IA3DY,wBAAK,QA2DjB,CAAA;AAgBH,CAAC,EA/EgB,kBAAkB,KAAlB,kBAAkB,QA+ElC"}
|
package/lib/tokens.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Token } from '@lumino/coreutils';
|
|
2
|
-
import CodeMirror from 'codemirror';
|
|
3
|
-
/**
|
|
4
|
-
* The CodeMirror token.
|
|
5
|
-
*/
|
|
6
|
-
export declare const ICodeMirror: Token<ICodeMirror>;
|
|
7
|
-
/** The CodeMirror interface. */
|
|
8
|
-
export interface ICodeMirror {
|
|
9
|
-
/**
|
|
10
|
-
* A singleton CodeMirror module, rexported.
|
|
11
|
-
*/
|
|
12
|
-
CodeMirror: typeof CodeMirror;
|
|
13
|
-
/**
|
|
14
|
-
* A function to allow extensions to ensure that
|
|
15
|
-
* the vim keymap has been imported
|
|
16
|
-
*/
|
|
17
|
-
ensureVimKeymap: () => Promise<void>;
|
|
18
|
-
}
|
package/lib/tokens.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Jupyter Development Team.
|
|
2
|
-
// Distributed under the terms of the Modified BSD License.
|
|
3
|
-
import { Token } from '@lumino/coreutils';
|
|
4
|
-
/**
|
|
5
|
-
* The CodeMirror token.
|
|
6
|
-
*/
|
|
7
|
-
export const ICodeMirror = new Token('@jupyterlab/codemirror:ICodeMirror');
|
|
8
|
-
//# sourceMappingURL=tokens.js.map
|
package/lib/tokens.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,KAAK,CAClC,oCAAoC,CACrC,CAAC"}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
// Type definitions for CodeMirror
|
|
2
|
-
// Project: https://github.com/marijnh/CodeMirror
|
|
3
|
-
// Definitions by: mihailik <https://github.com/mihailik>
|
|
4
|
-
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
|
5
|
-
|
|
6
|
-
import * as CodeMirror from 'codemirror';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Define extra codemirror types that do not exist in the DefinitelyTyped
|
|
10
|
-
* type resources
|
|
11
|
-
*/
|
|
12
|
-
declare module 'codemirror' {
|
|
13
|
-
/**
|
|
14
|
-
* id will be the id for the defined mode. Typically, you should use this second argument to defineMode as your module scope function
|
|
15
|
-
* (modes should not leak anything into the global scope!), i.e. write your whole mode inside this function.
|
|
16
|
-
*/
|
|
17
|
-
function defineMode(
|
|
18
|
-
id: string,
|
|
19
|
-
modefactory: ModeFactory<any>,
|
|
20
|
-
base: any
|
|
21
|
-
): void;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* An implementation of the CodeMirror simple mode object
|
|
25
|
-
* https://github.com/codemirror/CodeMirror/blob/master/addon/mode/simple.js
|
|
26
|
-
*
|
|
27
|
-
* Optionally generic over [S]tate names and [T]okens
|
|
28
|
-
*/
|
|
29
|
-
interface ISimpleState<S, T> {
|
|
30
|
-
/**
|
|
31
|
-
* The regular expression that matches the token. May be a string or a
|
|
32
|
-
* regex object. When a regex, the ignoreCase flag will be taken into
|
|
33
|
-
* account when matching the token. This regex has to capture groups when
|
|
34
|
-
* the token property is an array. If it captures groups, it must capture
|
|
35
|
-
* all of the string (since JS provides no way to find out where a group
|
|
36
|
-
* matched).
|
|
37
|
-
*/
|
|
38
|
-
regex: string | RegExp;
|
|
39
|
-
/**
|
|
40
|
-
* An optional token style. Multiple styles can be specified by separating
|
|
41
|
-
* them with dots or spaces. When this property holds an array of token styles,
|
|
42
|
-
* the regex for this rule must capture a group for each array item.
|
|
43
|
-
*/
|
|
44
|
-
token?: T | null | (T | null)[];
|
|
45
|
-
/**
|
|
46
|
-
* When true, this token will only match at the start of the line.
|
|
47
|
-
* (The ^ regexp marker doesn't work as you'd expect in this context because
|
|
48
|
-
* of limitations in JavaScript's RegExp API.)
|
|
49
|
-
*/
|
|
50
|
-
sol?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* When a next property is present, the mode will transfer to the state
|
|
53
|
-
* named by the property when the token is encountered.
|
|
54
|
-
*/
|
|
55
|
-
next?: S;
|
|
56
|
-
/**
|
|
57
|
-
* Like next, but instead replacing the current state by the new state, the
|
|
58
|
-
* current state is kept on a stack, and can be returned to with the pop
|
|
59
|
-
* directive.
|
|
60
|
-
*/
|
|
61
|
-
push?: S;
|
|
62
|
-
/**
|
|
63
|
-
* When true, and there is another state on the state stack, will cause the
|
|
64
|
-
* mode to pop that state off the stack and transition to it.
|
|
65
|
-
*/
|
|
66
|
-
pop?: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Can be used to embed another mode inside a mode. When present, must hold
|
|
69
|
-
* an object with a spec property that describes the embedded mode, and an
|
|
70
|
-
* optional end end property that specifies the regexp that will end the
|
|
71
|
-
* extent of the mode. When a persistent property is set (and true), the
|
|
72
|
-
* nested mode's state will be preserved between occurrences of the mode.
|
|
73
|
-
*/
|
|
74
|
-
mode?: {
|
|
75
|
-
spec: string;
|
|
76
|
-
end?: string | RegExp;
|
|
77
|
-
persistent?: boolean;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* When true, this token changes the indentation to be one unit more than
|
|
81
|
-
* the current line's indentation.
|
|
82
|
-
*/
|
|
83
|
-
indent?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* When true, this token will pop one scope off the indentation stack.
|
|
86
|
-
*/
|
|
87
|
-
dedent?: boolean;
|
|
88
|
-
/**
|
|
89
|
-
* If a token has its dedent property set, it will, by default, cause lines
|
|
90
|
-
* where it appears at the start to be dedented. Set this property to false
|
|
91
|
-
* to prevent that behavior.
|
|
92
|
-
*/
|
|
93
|
-
dedentIfLineStart?: boolean;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Special mode values interpreted by simple modes
|
|
98
|
-
*/
|
|
99
|
-
export interface ISimpleMode<S> extends CodeMirror.Mode<S> {
|
|
100
|
-
/**
|
|
101
|
-
* Keys of simple states that should not be indented.
|
|
102
|
-
*/
|
|
103
|
-
dontIndentStates?: S[];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* A string-keyed set of simple state rule lists.
|
|
108
|
-
*/
|
|
109
|
-
export type TSimpleStates<S = string, T = any> = {
|
|
110
|
-
[key: string]: ISimpleState<S, T>[];
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* The special-case for mode metadata in an otherwise state-keyed map.
|
|
115
|
-
*/
|
|
116
|
-
export interface ISimpleMeta<S, T> {
|
|
117
|
-
meta: ISimpleMode<S>;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* A top-level simple state.
|
|
122
|
-
*/
|
|
123
|
-
export type TSimpleTopState<S, T> = Partial<
|
|
124
|
-
TSimpleStates<S, T> & ISimpleMeta<S, T>
|
|
125
|
-
>;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Create an instance of a simple mode from its config and states.
|
|
129
|
-
*/
|
|
130
|
-
function simpleMode<S, T>(config: any, states: TSimpleTopState<S, T>): void;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Define a named simple mode from states and optional metadata
|
|
134
|
-
*
|
|
135
|
-
* ### Notes
|
|
136
|
-
* Provide generic States (S) and Tokens (T) for more precision.
|
|
137
|
-
*/
|
|
138
|
-
function defineSimpleMode<S, T>(
|
|
139
|
-
name: string,
|
|
140
|
-
states: TSimpleTopState<S, T>
|
|
141
|
-
): void;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Define a mimetype.
|
|
145
|
-
*/
|
|
146
|
-
function defineMIME(mimetype: string, mode: any): void;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* A mode that encompasses many mode types.
|
|
150
|
-
*/
|
|
151
|
-
function multiplexingMode<T>(...modes: any[]): Mode<T>;
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Fired on a keydown event on the editor.
|
|
155
|
-
*/
|
|
156
|
-
function on(
|
|
157
|
-
editor: Editor,
|
|
158
|
-
eventName: 'keydown',
|
|
159
|
-
handler: (instance: Editor, event: KeyboardEvent) => void
|
|
160
|
-
): void;
|
|
161
|
-
function off(
|
|
162
|
-
editor: Editor,
|
|
163
|
-
eventName: 'keydown',
|
|
164
|
-
handler: (instance: Editor, event: KeyboardEvent) => void
|
|
165
|
-
): void;
|
|
166
|
-
|
|
167
|
-
interface Editor {
|
|
168
|
-
/** Scrolls the given element into view. pos is a { from, to } object, in editor-local coordinates.
|
|
169
|
-
The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */
|
|
170
|
-
scrollIntoView(
|
|
171
|
-
pos: { from: CodeMirror.Position; to: CodeMirror.Position },
|
|
172
|
-
margin?: number
|
|
173
|
-
): void;
|
|
174
|
-
|
|
175
|
-
/** Trigger key events onto the editor instance. Not for production use, only for testing.
|
|
176
|
-
See this comment: https://github.com/codemirror/CodeMirror/issues/1935#issuecomment-28178991 */
|
|
177
|
-
triggerOnKeyDown(event: Event): void;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
interface Selection {
|
|
181
|
-
/**
|
|
182
|
-
* the fixed side of the selection
|
|
183
|
-
*/
|
|
184
|
-
anchor: Position;
|
|
185
|
-
/**
|
|
186
|
-
* the side of the selection that moves
|
|
187
|
-
*/
|
|
188
|
-
head: Position;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// findMode* functions are from loading the codemirror/mode/meta module
|
|
192
|
-
interface modespec {
|
|
193
|
-
ext?: string[];
|
|
194
|
-
name?: string;
|
|
195
|
-
mode: string;
|
|
196
|
-
mime: string;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function runMode(
|
|
200
|
-
code: string,
|
|
201
|
-
mode: modespec | string,
|
|
202
|
-
el: HTMLElement
|
|
203
|
-
): void;
|
|
204
|
-
|
|
205
|
-
function findModeByName(name: string): modespec;
|
|
206
|
-
function findModeByExtension(name: string): modespec;
|
|
207
|
-
function findModeByFileName(name: string): modespec;
|
|
208
|
-
function findModeByMIME(mime: string): modespec;
|
|
209
|
-
|
|
210
|
-
// come back to this later
|
|
211
|
-
interface Context {
|
|
212
|
-
state: any;
|
|
213
|
-
doc: Document;
|
|
214
|
-
line: number;
|
|
215
|
-
maxLookAhead: number;
|
|
216
|
-
baseTokens: string[];
|
|
217
|
-
baseTokenPos: number;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
interface StringStream {
|
|
221
|
-
lineOracle: Context;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
interface EditorConfiguration {
|
|
225
|
-
lineSeparator?: string | null;
|
|
226
|
-
}
|
|
227
|
-
}
|