@jupyterlab/codemirror 0.19.1-alpha.0 → 0.19.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/LICENSE +34 -0
- package/lib/codemirror-ipython.d.ts +2 -2
- package/lib/codemirror-ipython.js +34 -34
- package/lib/codemirror-ipythongfm.d.ts +3 -3
- package/lib/codemirror-ipythongfm.js +61 -61
- package/lib/editor.d.ts +442 -442
- package/lib/editor.js +1021 -1021
- package/lib/factory.d.ts +21 -21
- package/lib/factory.js +48 -48
- package/lib/index.d.ts +10 -10
- package/lib/index.js +21 -21
- package/lib/mimetype.d.ts +21 -21
- package/lib/mimetype.js +43 -43
- package/lib/mode.d.ts +71 -71
- package/lib/mode.js +118 -118
- package/package.json +11 -8
package/lib/factory.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { CodeEditor, IEditorFactoryService } from '@jupyterlab/codeeditor';
|
|
2
|
-
import { CodeMirrorEditor } from './editor';
|
|
3
|
-
/**
|
|
4
|
-
* CodeMirror editor factory.
|
|
5
|
-
*/
|
|
6
|
-
export declare class CodeMirrorEditorFactory implements IEditorFactoryService {
|
|
7
|
-
/**
|
|
8
|
-
* Construct an IEditorFactoryService for CodeMirrorEditors.
|
|
9
|
-
*/
|
|
10
|
-
constructor(defaults?: Partial<CodeMirrorEditor.IConfig>);
|
|
11
|
-
/**
|
|
12
|
-
* Create a new editor for inline code.
|
|
13
|
-
*/
|
|
14
|
-
newInlineEditor: (options: CodeEditor.IOptions) => CodeMirrorEditor;
|
|
15
|
-
/**
|
|
16
|
-
* Create a new editor for a full document.
|
|
17
|
-
*/
|
|
18
|
-
newDocumentEditor: (options: CodeEditor.IOptions) => CodeMirrorEditor;
|
|
19
|
-
protected inlineCodeMirrorConfig: Partial<CodeMirrorEditor.IConfig>;
|
|
20
|
-
protected documentCodeMirrorConfig: Partial<CodeMirrorEditor.IConfig>;
|
|
21
|
-
}
|
|
1
|
+
import { CodeEditor, IEditorFactoryService } from '@jupyterlab/codeeditor';
|
|
2
|
+
import { CodeMirrorEditor } from './editor';
|
|
3
|
+
/**
|
|
4
|
+
* CodeMirror editor factory.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CodeMirrorEditorFactory implements IEditorFactoryService {
|
|
7
|
+
/**
|
|
8
|
+
* Construct an IEditorFactoryService for CodeMirrorEditors.
|
|
9
|
+
*/
|
|
10
|
+
constructor(defaults?: Partial<CodeMirrorEditor.IConfig>);
|
|
11
|
+
/**
|
|
12
|
+
* Create a new editor for inline code.
|
|
13
|
+
*/
|
|
14
|
+
newInlineEditor: (options: CodeEditor.IOptions) => CodeMirrorEditor;
|
|
15
|
+
/**
|
|
16
|
+
* Create a new editor for a full document.
|
|
17
|
+
*/
|
|
18
|
+
newDocumentEditor: (options: CodeEditor.IOptions) => CodeMirrorEditor;
|
|
19
|
+
protected inlineCodeMirrorConfig: Partial<CodeMirrorEditor.IConfig>;
|
|
20
|
+
protected documentCodeMirrorConfig: Partial<CodeMirrorEditor.IConfig>;
|
|
21
|
+
}
|
package/lib/factory.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Jupyter Development Team.
|
|
3
|
-
// Distributed under the terms of the Modified BSD License.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
const editor_1 = require("./editor");
|
|
6
|
-
/**
|
|
7
|
-
* CodeMirror editor factory.
|
|
8
|
-
*/
|
|
9
|
-
class CodeMirrorEditorFactory {
|
|
10
|
-
/**
|
|
11
|
-
* Construct an IEditorFactoryService for CodeMirrorEditors.
|
|
12
|
-
*/
|
|
13
|
-
constructor(defaults = {}) {
|
|
14
|
-
/**
|
|
15
|
-
* Create a new editor for inline code.
|
|
16
|
-
*/
|
|
17
|
-
this.newInlineEditor = (options) => {
|
|
18
|
-
options.host.dataset.type = 'inline';
|
|
19
|
-
return new editor_1.CodeMirrorEditor(Object.assign({}, options, { config: Object.assign({}, this.inlineCodeMirrorConfig, (options.config || {})) }));
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Create a new editor for a full document.
|
|
23
|
-
*/
|
|
24
|
-
this.newDocumentEditor = (options) => {
|
|
25
|
-
options.host.dataset.type = 'document';
|
|
26
|
-
return new editor_1.CodeMirrorEditor(Object.assign({}, options, { config: Object.assign({}, this.documentCodeMirrorConfig, (options.config || {})) }));
|
|
27
|
-
};
|
|
28
|
-
this.inlineCodeMirrorConfig = Object.assign({}, editor_1.CodeMirrorEditor.defaultConfig, { extraKeys: {
|
|
29
|
-
'Cmd-Right': 'goLineRight',
|
|
30
|
-
End: 'goLineRight',
|
|
31
|
-
'Cmd-Left': 'goLineLeft',
|
|
32
|
-
Tab: 'indentMoreOrinsertTab',
|
|
33
|
-
'Shift-Tab': 'indentLess',
|
|
34
|
-
'Cmd-/': 'toggleComment',
|
|
35
|
-
'Ctrl-/': 'toggleComment'
|
|
36
|
-
} }, defaults);
|
|
37
|
-
this.documentCodeMirrorConfig = Object.assign({}, editor_1.CodeMirrorEditor.defaultConfig, { extraKeys: {
|
|
38
|
-
Tab: 'indentMoreOrinsertTab',
|
|
39
|
-
'Shift-Tab': 'indentLess',
|
|
40
|
-
'Cmd-/': 'toggleComment',
|
|
41
|
-
'Ctrl-/': 'toggleComment',
|
|
42
|
-
'Shift-Enter': () => {
|
|
43
|
-
/* no-op */
|
|
44
|
-
}
|
|
45
|
-
}, lineNumbers: true, scrollPastEnd: true }, defaults);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.CodeMirrorEditorFactory = CodeMirrorEditorFactory;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Jupyter Development Team.
|
|
3
|
+
// Distributed under the terms of the Modified BSD License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const editor_1 = require("./editor");
|
|
6
|
+
/**
|
|
7
|
+
* CodeMirror editor factory.
|
|
8
|
+
*/
|
|
9
|
+
class CodeMirrorEditorFactory {
|
|
10
|
+
/**
|
|
11
|
+
* Construct an IEditorFactoryService for CodeMirrorEditors.
|
|
12
|
+
*/
|
|
13
|
+
constructor(defaults = {}) {
|
|
14
|
+
/**
|
|
15
|
+
* Create a new editor for inline code.
|
|
16
|
+
*/
|
|
17
|
+
this.newInlineEditor = (options) => {
|
|
18
|
+
options.host.dataset.type = 'inline';
|
|
19
|
+
return new editor_1.CodeMirrorEditor(Object.assign({}, options, { config: Object.assign({}, this.inlineCodeMirrorConfig, (options.config || {})) }));
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Create a new editor for a full document.
|
|
23
|
+
*/
|
|
24
|
+
this.newDocumentEditor = (options) => {
|
|
25
|
+
options.host.dataset.type = 'document';
|
|
26
|
+
return new editor_1.CodeMirrorEditor(Object.assign({}, options, { config: Object.assign({}, this.documentCodeMirrorConfig, (options.config || {})) }));
|
|
27
|
+
};
|
|
28
|
+
this.inlineCodeMirrorConfig = Object.assign({}, editor_1.CodeMirrorEditor.defaultConfig, { extraKeys: {
|
|
29
|
+
'Cmd-Right': 'goLineRight',
|
|
30
|
+
End: 'goLineRight',
|
|
31
|
+
'Cmd-Left': 'goLineLeft',
|
|
32
|
+
Tab: 'indentMoreOrinsertTab',
|
|
33
|
+
'Shift-Tab': 'indentLess',
|
|
34
|
+
'Cmd-/': 'toggleComment',
|
|
35
|
+
'Ctrl-/': 'toggleComment'
|
|
36
|
+
} }, defaults);
|
|
37
|
+
this.documentCodeMirrorConfig = Object.assign({}, editor_1.CodeMirrorEditor.defaultConfig, { extraKeys: {
|
|
38
|
+
Tab: 'indentMoreOrinsertTab',
|
|
39
|
+
'Shift-Tab': 'indentLess',
|
|
40
|
+
'Cmd-/': 'toggleComment',
|
|
41
|
+
'Ctrl-/': 'toggleComment',
|
|
42
|
+
'Shift-Enter': () => {
|
|
43
|
+
/* no-op */
|
|
44
|
+
}
|
|
45
|
+
}, lineNumbers: true, scrollPastEnd: true }, defaults);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.CodeMirrorEditorFactory = CodeMirrorEditorFactory;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IEditorServices } from '@jupyterlab/codeeditor';
|
|
2
|
-
import '../style/index.css';
|
|
3
|
-
export * from './mode';
|
|
4
|
-
export * from './editor';
|
|
5
|
-
export * from './factory';
|
|
6
|
-
export * from './mimetype';
|
|
7
|
-
/**
|
|
8
|
-
* The default editor services.
|
|
9
|
-
*/
|
|
10
|
-
export declare const editorServices: IEditorServices;
|
|
1
|
+
import { IEditorServices } from '@jupyterlab/codeeditor';
|
|
2
|
+
import '../style/index.css';
|
|
3
|
+
export * from './mode';
|
|
4
|
+
export * from './editor';
|
|
5
|
+
export * from './factory';
|
|
6
|
+
export * from './mimetype';
|
|
7
|
+
/**
|
|
8
|
+
* The default editor services.
|
|
9
|
+
*/
|
|
10
|
+
export declare const editorServices: IEditorServices;
|
package/lib/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Jupyter Development Team.
|
|
3
|
-
// Distributed under the terms of the Modified BSD License.
|
|
4
|
-
function __export(m) {
|
|
5
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
6
|
-
}
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
const factory_1 = require("./factory");
|
|
9
|
-
const mimetype_1 = require("./mimetype");
|
|
10
|
-
require("../style/index.css");
|
|
11
|
-
__export(require("./mode"));
|
|
12
|
-
__export(require("./editor"));
|
|
13
|
-
__export(require("./factory"));
|
|
14
|
-
__export(require("./mimetype"));
|
|
15
|
-
/**
|
|
16
|
-
* The default editor services.
|
|
17
|
-
*/
|
|
18
|
-
exports.editorServices = {
|
|
19
|
-
factoryService: new factory_1.CodeMirrorEditorFactory(),
|
|
20
|
-
mimeTypeService: new mimetype_1.CodeMirrorMimeTypeService()
|
|
21
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Jupyter Development Team.
|
|
3
|
+
// Distributed under the terms of the Modified BSD License.
|
|
4
|
+
function __export(m) {
|
|
5
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const factory_1 = require("./factory");
|
|
9
|
+
const mimetype_1 = require("./mimetype");
|
|
10
|
+
require("../style/index.css");
|
|
11
|
+
__export(require("./mode"));
|
|
12
|
+
__export(require("./editor"));
|
|
13
|
+
__export(require("./factory"));
|
|
14
|
+
__export(require("./mimetype"));
|
|
15
|
+
/**
|
|
16
|
+
* The default editor services.
|
|
17
|
+
*/
|
|
18
|
+
exports.editorServices = {
|
|
19
|
+
factoryService: new factory_1.CodeMirrorEditorFactory(),
|
|
20
|
+
mimeTypeService: new mimetype_1.CodeMirrorMimeTypeService()
|
|
21
|
+
};
|
package/lib/mimetype.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
|
|
2
|
-
import { nbformat } from '@jupyterlab/coreutils';
|
|
3
|
-
/**
|
|
4
|
-
* The mime type service for CodeMirror.
|
|
5
|
-
*/
|
|
6
|
-
export declare class CodeMirrorMimeTypeService implements IEditorMimeTypeService {
|
|
7
|
-
/**
|
|
8
|
-
* Returns a mime type for the given language info.
|
|
9
|
-
*
|
|
10
|
-
* #### Notes
|
|
11
|
-
* If a mime type cannot be found returns the defaul mime type `text/plain`, never `null`.
|
|
12
|
-
*/
|
|
13
|
-
getMimeTypeByLanguage(info: nbformat.ILanguageInfoMetadata): string;
|
|
14
|
-
/**
|
|
15
|
-
* Returns a mime type for the given file path.
|
|
16
|
-
*
|
|
17
|
-
* #### Notes
|
|
18
|
-
* If a mime type cannot be found returns the default mime type `text/plain`, never `null`.
|
|
19
|
-
*/
|
|
20
|
-
getMimeTypeByFilePath(path: string): string;
|
|
21
|
-
}
|
|
1
|
+
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
|
|
2
|
+
import { nbformat } from '@jupyterlab/coreutils';
|
|
3
|
+
/**
|
|
4
|
+
* The mime type service for CodeMirror.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CodeMirrorMimeTypeService implements IEditorMimeTypeService {
|
|
7
|
+
/**
|
|
8
|
+
* Returns a mime type for the given language info.
|
|
9
|
+
*
|
|
10
|
+
* #### Notes
|
|
11
|
+
* If a mime type cannot be found returns the defaul mime type `text/plain`, never `null`.
|
|
12
|
+
*/
|
|
13
|
+
getMimeTypeByLanguage(info: nbformat.ILanguageInfoMetadata): string;
|
|
14
|
+
/**
|
|
15
|
+
* Returns a mime type for the given file path.
|
|
16
|
+
*
|
|
17
|
+
* #### Notes
|
|
18
|
+
* If a mime type cannot be found returns the default mime type `text/plain`, never `null`.
|
|
19
|
+
*/
|
|
20
|
+
getMimeTypeByFilePath(path: string): string;
|
|
21
|
+
}
|
package/lib/mimetype.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Jupyter Development Team.
|
|
3
|
-
// Distributed under the terms of the Modified BSD License.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
const coreutils_1 = require("@jupyterlab/coreutils");
|
|
6
|
-
const mode_1 = require("./mode");
|
|
7
|
-
/**
|
|
8
|
-
* The mime type service for CodeMirror.
|
|
9
|
-
*/
|
|
10
|
-
class CodeMirrorMimeTypeService {
|
|
11
|
-
/**
|
|
12
|
-
* Returns a mime type for the given language info.
|
|
13
|
-
*
|
|
14
|
-
* #### Notes
|
|
15
|
-
* If a mime type cannot be found returns the defaul mime type `text/plain`, never `null`.
|
|
16
|
-
*/
|
|
17
|
-
getMimeTypeByLanguage(info) {
|
|
18
|
-
let ext = info.file_extension || '';
|
|
19
|
-
return mode_1.Mode.findBest(info.codemirror_mode || {
|
|
20
|
-
mimetype: info.mimetype,
|
|
21
|
-
name: info.name,
|
|
22
|
-
ext: [ext.split('.').slice(-1)[0]]
|
|
23
|
-
}).mime;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Returns a mime type for the given file path.
|
|
27
|
-
*
|
|
28
|
-
* #### Notes
|
|
29
|
-
* If a mime type cannot be found returns the default mime type `text/plain`, never `null`.
|
|
30
|
-
*/
|
|
31
|
-
getMimeTypeByFilePath(path) {
|
|
32
|
-
const ext = coreutils_1.PathExt.extname(path);
|
|
33
|
-
if (ext === '.ipy') {
|
|
34
|
-
return 'text/x-python';
|
|
35
|
-
}
|
|
36
|
-
else if (ext === '.md') {
|
|
37
|
-
return 'text/x-ipythongfm';
|
|
38
|
-
}
|
|
39
|
-
let mode = mode_1.Mode.findByFileName(path) || mode_1.Mode.findBest('');
|
|
40
|
-
return mode.mime;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.CodeMirrorMimeTypeService = CodeMirrorMimeTypeService;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Jupyter Development Team.
|
|
3
|
+
// Distributed under the terms of the Modified BSD License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const coreutils_1 = require("@jupyterlab/coreutils");
|
|
6
|
+
const mode_1 = require("./mode");
|
|
7
|
+
/**
|
|
8
|
+
* The mime type service for CodeMirror.
|
|
9
|
+
*/
|
|
10
|
+
class CodeMirrorMimeTypeService {
|
|
11
|
+
/**
|
|
12
|
+
* Returns a mime type for the given language info.
|
|
13
|
+
*
|
|
14
|
+
* #### Notes
|
|
15
|
+
* If a mime type cannot be found returns the defaul mime type `text/plain`, never `null`.
|
|
16
|
+
*/
|
|
17
|
+
getMimeTypeByLanguage(info) {
|
|
18
|
+
let ext = info.file_extension || '';
|
|
19
|
+
return mode_1.Mode.findBest(info.codemirror_mode || {
|
|
20
|
+
mimetype: info.mimetype,
|
|
21
|
+
name: info.name,
|
|
22
|
+
ext: [ext.split('.').slice(-1)[0]]
|
|
23
|
+
}).mime;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns a mime type for the given file path.
|
|
27
|
+
*
|
|
28
|
+
* #### Notes
|
|
29
|
+
* If a mime type cannot be found returns the default mime type `text/plain`, never `null`.
|
|
30
|
+
*/
|
|
31
|
+
getMimeTypeByFilePath(path) {
|
|
32
|
+
const ext = coreutils_1.PathExt.extname(path);
|
|
33
|
+
if (ext === '.ipy') {
|
|
34
|
+
return 'text/x-python';
|
|
35
|
+
}
|
|
36
|
+
else if (ext === '.md') {
|
|
37
|
+
return 'text/x-ipythongfm';
|
|
38
|
+
}
|
|
39
|
+
let mode = mode_1.Mode.findByFileName(path) || mode_1.Mode.findBest('');
|
|
40
|
+
return mode.mime;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.CodeMirrorMimeTypeService = CodeMirrorMimeTypeService;
|
package/lib/mode.d.ts
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import { JSONValue } from '@phosphor/coreutils';
|
|
2
|
-
import 'codemirror/mode/meta';
|
|
3
|
-
import 'codemirror/addon/runmode/runmode';
|
|
4
|
-
import './codemirror-ipython';
|
|
5
|
-
import './codemirror-ipythongfm';
|
|
6
|
-
import 'codemirror/mode/javascript/javascript';
|
|
7
|
-
import 'codemirror/mode/css/css';
|
|
8
|
-
import 'codemirror/mode/julia/julia';
|
|
9
|
-
import 'codemirror/mode/r/r';
|
|
10
|
-
import 'codemirror/mode/markdown/markdown';
|
|
11
|
-
import 'codemirror/mode/clike/clike';
|
|
12
|
-
import 'codemirror/mode/shell/shell';
|
|
13
|
-
import 'codemirror/mode/sql/sql';
|
|
14
|
-
/**
|
|
15
|
-
* The namespace for CodeMirror Mode functionality.
|
|
16
|
-
*/
|
|
17
|
-
export declare namespace Mode {
|
|
18
|
-
/**
|
|
19
|
-
* The interface of a codemirror modeInfo spec.
|
|
20
|
-
*/
|
|
21
|
-
interface ISpec {
|
|
22
|
-
ext?: string[];
|
|
23
|
-
name?: string;
|
|
24
|
-
mode: string;
|
|
25
|
-
mime: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* The interface of a codemirror mode spec.
|
|
29
|
-
*/
|
|
30
|
-
interface IMode {
|
|
31
|
-
name: string;
|
|
32
|
-
[key: string]: JSONValue;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Get the raw list of available modes specs.
|
|
36
|
-
*/
|
|
37
|
-
function getModeInfo(): ISpec[];
|
|
38
|
-
/**
|
|
39
|
-
* Running a CodeMirror mode outside of an editor.
|
|
40
|
-
*/
|
|
41
|
-
function run(code: string, mode: string | ISpec, el: HTMLElement): void;
|
|
42
|
-
/**
|
|
43
|
-
* Ensure a codemirror mode is available by name or Codemirror spec.
|
|
44
|
-
*
|
|
45
|
-
* @param mode - The mode to ensure. If it is a string, uses [findBest]
|
|
46
|
-
* to get the appropriate spec.
|
|
47
|
-
*
|
|
48
|
-
* @returns A promise that resolves when the mode is available.
|
|
49
|
-
*/
|
|
50
|
-
function ensure(mode: string | ISpec): Promise<ISpec>;
|
|
51
|
-
/**
|
|
52
|
-
* Find a codemirror mode by name or CodeMirror spec.
|
|
53
|
-
*/
|
|
54
|
-
function findBest(mode: string | ISpec): ISpec;
|
|
55
|
-
/**
|
|
56
|
-
* Find a codemirror mode by MIME.
|
|
57
|
-
*/
|
|
58
|
-
function findByMIME(mime: string): ISpec;
|
|
59
|
-
/**
|
|
60
|
-
* Find a codemirror mode by name.
|
|
61
|
-
*/
|
|
62
|
-
function findByName(name: string): ISpec;
|
|
63
|
-
/**
|
|
64
|
-
* Find a codemirror mode by filename.
|
|
65
|
-
*/
|
|
66
|
-
function findByFileName(name: string): ISpec;
|
|
67
|
-
/**
|
|
68
|
-
* Find a codemirror mode by extension.
|
|
69
|
-
*/
|
|
70
|
-
function findByExtension(ext: string | string[]): ISpec;
|
|
71
|
-
}
|
|
1
|
+
import { JSONValue } from '@phosphor/coreutils';
|
|
2
|
+
import 'codemirror/mode/meta';
|
|
3
|
+
import 'codemirror/addon/runmode/runmode';
|
|
4
|
+
import './codemirror-ipython';
|
|
5
|
+
import './codemirror-ipythongfm';
|
|
6
|
+
import 'codemirror/mode/javascript/javascript';
|
|
7
|
+
import 'codemirror/mode/css/css';
|
|
8
|
+
import 'codemirror/mode/julia/julia';
|
|
9
|
+
import 'codemirror/mode/r/r';
|
|
10
|
+
import 'codemirror/mode/markdown/markdown';
|
|
11
|
+
import 'codemirror/mode/clike/clike';
|
|
12
|
+
import 'codemirror/mode/shell/shell';
|
|
13
|
+
import 'codemirror/mode/sql/sql';
|
|
14
|
+
/**
|
|
15
|
+
* The namespace for CodeMirror Mode functionality.
|
|
16
|
+
*/
|
|
17
|
+
export declare namespace Mode {
|
|
18
|
+
/**
|
|
19
|
+
* The interface of a codemirror modeInfo spec.
|
|
20
|
+
*/
|
|
21
|
+
interface ISpec {
|
|
22
|
+
ext?: string[];
|
|
23
|
+
name?: string;
|
|
24
|
+
mode: string;
|
|
25
|
+
mime: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The interface of a codemirror mode spec.
|
|
29
|
+
*/
|
|
30
|
+
interface IMode {
|
|
31
|
+
name: string;
|
|
32
|
+
[key: string]: JSONValue;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get the raw list of available modes specs.
|
|
36
|
+
*/
|
|
37
|
+
function getModeInfo(): ISpec[];
|
|
38
|
+
/**
|
|
39
|
+
* Running a CodeMirror mode outside of an editor.
|
|
40
|
+
*/
|
|
41
|
+
function run(code: string, mode: string | ISpec, el: HTMLElement): void;
|
|
42
|
+
/**
|
|
43
|
+
* Ensure a codemirror mode is available by name or Codemirror spec.
|
|
44
|
+
*
|
|
45
|
+
* @param mode - The mode to ensure. If it is a string, uses [findBest]
|
|
46
|
+
* to get the appropriate spec.
|
|
47
|
+
*
|
|
48
|
+
* @returns A promise that resolves when the mode is available.
|
|
49
|
+
*/
|
|
50
|
+
function ensure(mode: string | ISpec): Promise<ISpec>;
|
|
51
|
+
/**
|
|
52
|
+
* Find a codemirror mode by name or CodeMirror spec.
|
|
53
|
+
*/
|
|
54
|
+
function findBest(mode: string | ISpec): ISpec;
|
|
55
|
+
/**
|
|
56
|
+
* Find a codemirror mode by MIME.
|
|
57
|
+
*/
|
|
58
|
+
function findByMIME(mime: string): ISpec;
|
|
59
|
+
/**
|
|
60
|
+
* Find a codemirror mode by name.
|
|
61
|
+
*/
|
|
62
|
+
function findByName(name: string): ISpec;
|
|
63
|
+
/**
|
|
64
|
+
* Find a codemirror mode by filename.
|
|
65
|
+
*/
|
|
66
|
+
function findByFileName(name: string): ISpec;
|
|
67
|
+
/**
|
|
68
|
+
* Find a codemirror mode by extension.
|
|
69
|
+
*/
|
|
70
|
+
function findByExtension(ext: string | string[]): ISpec;
|
|
71
|
+
}
|