@jupyterlab/codemirror 4.6.0-alpha.1 → 4.6.0-alpha.3
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/commands.d.ts +1 -1
- package/lib/editor.d.ts +6 -4
- package/lib/editor.js.map +1 -1
- package/lib/extension.d.ts +7 -6
- package/lib/extension.js.map +1 -1
- package/lib/extensions/customStyle.d.ts +1 -1
- package/lib/extensions/customStyle.js.map +1 -1
- package/lib/extensions/ipython-md.d.ts +2 -2
- package/lib/extensions/ipython-md.js.map +1 -1
- package/lib/extensions/rulers.d.ts +1 -1
- package/lib/extensions/rulers.js +0 -1
- package/lib/extensions/rulers.js.map +1 -1
- package/lib/extensions/ybinding.d.ts +4 -2
- package/lib/extensions/ybinding.js +0 -9
- package/lib/extensions/ybinding.js.map +1 -1
- package/lib/extensions/yundomanager.d.ts +2 -1
- package/lib/extensions/yundomanager.js +0 -16
- package/lib/extensions/yundomanager.js.map +1 -1
- package/lib/factory.d.ts +3 -3
- package/lib/factory.js.map +1 -1
- package/lib/language.d.ts +6 -4
- package/lib/language.js +20 -3
- package/lib/language.js.map +1 -1
- package/lib/mimetype.d.ts +2 -2
- package/lib/mimetype.js +6 -6
- package/lib/mimetype.js.map +1 -1
- package/lib/pythonBuiltin.d.ts +4 -3
- package/lib/pythonBuiltin.js.map +1 -1
- package/lib/searchprovider.d.ts +7 -6
- package/lib/searchprovider.js.map +1 -1
- package/lib/theme.d.ts +3 -3
- package/lib/theme.js.map +1 -1
- package/lib/token.d.ts +2 -1
- package/lib/token.js.map +1 -1
- package/package.json +25 -25
- package/src/commands.ts +1 -1
- package/src/editor.ts +7 -8
- package/src/extension.ts +13 -14
- package/src/extensions/customStyle.ts +2 -1
- package/src/extensions/ipython-md.ts +3 -2
- package/src/extensions/rulers.ts +4 -2
- package/src/extensions/ybinding.ts +4 -8
- package/src/extensions/yundomanager.ts +4 -7
- package/src/factory.ts +4 -3
- package/src/language.ts +28 -8
- package/src/mimetype.ts +8 -8
- package/src/pythonBuiltin.ts +6 -9
- package/src/searchprovider.ts +16 -18
- package/src/theme.ts +4 -3
- package/src/token.ts +2 -1
- package/src/typings.d.ts +1 -1
package/src/extension.ts
CHANGED
|
@@ -9,13 +9,9 @@ import {
|
|
|
9
9
|
indentOnInput,
|
|
10
10
|
indentUnit
|
|
11
11
|
} from '@codemirror/language';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Extension,
|
|
16
|
-
Prec,
|
|
17
|
-
StateEffect
|
|
18
|
-
} from '@codemirror/state';
|
|
12
|
+
import type { Extension } from '@codemirror/state';
|
|
13
|
+
import { Compartment, EditorState, Prec, StateEffect } from '@codemirror/state';
|
|
14
|
+
import type { KeyBinding } from '@codemirror/view';
|
|
19
15
|
import {
|
|
20
16
|
crosshairCursor,
|
|
21
17
|
drawSelection,
|
|
@@ -25,20 +21,23 @@ import {
|
|
|
25
21
|
highlightSpecialChars,
|
|
26
22
|
highlightTrailingWhitespace,
|
|
27
23
|
highlightWhitespace,
|
|
28
|
-
KeyBinding,
|
|
29
24
|
keymap,
|
|
30
25
|
lineNumbers,
|
|
31
26
|
rectangularSelection,
|
|
32
27
|
scrollPastEnd,
|
|
33
28
|
tooltips
|
|
34
29
|
} from '@codemirror/view';
|
|
35
|
-
import { ITranslator
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
30
|
+
import type { ITranslator } from '@jupyterlab/translation';
|
|
31
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
32
|
+
import type { ReadonlyJSONObject } from '@lumino/coreutils';
|
|
33
|
+
import { JSONExt } from '@lumino/coreutils';
|
|
34
|
+
import type { IObservableDisposable } from '@lumino/disposable';
|
|
35
|
+
import type { ISignal } from '@lumino/signaling';
|
|
36
|
+
import { Signal } from '@lumino/signaling';
|
|
39
37
|
import { StateCommands } from './commands';
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
38
|
+
import type { CustomTheme } from './extensions';
|
|
39
|
+
import { customTheme, rulers } from './extensions';
|
|
40
|
+
import type {
|
|
42
41
|
IConfigurableExtension,
|
|
43
42
|
IEditorExtensionFactory,
|
|
44
43
|
IEditorExtensionRegistry,
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import type { Extension } from '@codemirror/state';
|
|
7
|
+
import { combineConfig, Facet } from '@codemirror/state';
|
|
7
8
|
import { EditorView } from '@codemirror/view';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { Parser } from '@lezer/common';
|
|
5
|
+
import { parseMixed } from '@lezer/common';
|
|
5
6
|
import { tags } from '@lezer/highlight';
|
|
6
|
-
import {
|
|
7
|
+
import type {
|
|
7
8
|
DelimiterType,
|
|
8
9
|
InlineContext,
|
|
9
10
|
MarkdownConfig,
|
package/src/extensions/rulers.ts
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
// Inspired by https://discuss.codemirror.net/t/how-to-implement-ruler/4616/
|
|
7
7
|
|
|
8
|
-
import { Extension
|
|
9
|
-
import {
|
|
8
|
+
import type { Extension } from '@codemirror/state';
|
|
9
|
+
import { Facet } from '@codemirror/state';
|
|
10
|
+
import type { ViewUpdate } from '@codemirror/view';
|
|
11
|
+
import { EditorView, ViewPlugin } from '@codemirror/view';
|
|
10
12
|
import { JSONExt } from '@lumino/coreutils';
|
|
11
13
|
|
|
12
14
|
const RULERS_CLASSNAME = 'cm-rulers';
|
|
@@ -7,14 +7,10 @@
|
|
|
7
7
|
* It is a simplification of https://github.com/yjs/y-codemirror.next
|
|
8
8
|
* licensed under MIT License by Kevin Jahns
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Facet,
|
|
15
|
-
SelectionRange
|
|
16
|
-
} from '@codemirror/state';
|
|
17
|
-
import { EditorView, ViewPlugin, ViewUpdate } from '@codemirror/view';
|
|
10
|
+
import type { Extension, SelectionRange } from '@codemirror/state';
|
|
11
|
+
import { Annotation, EditorSelection, Facet } from '@codemirror/state';
|
|
12
|
+
import type { EditorView, ViewUpdate } from '@codemirror/view';
|
|
13
|
+
import { ViewPlugin } from '@codemirror/view';
|
|
18
14
|
import {
|
|
19
15
|
yUndoManager,
|
|
20
16
|
YUndoManagerConfig,
|
|
@@ -14,14 +14,11 @@
|
|
|
14
14
|
* - simplified `YUndoManagerConfig` by removing public methods
|
|
15
15
|
* - moved `_onStackItemAdded`, `_onStackItemPopped` and `_storeSelection` definitions out of constructor
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
PluginValue,
|
|
20
|
-
ViewPlugin,
|
|
21
|
-
ViewUpdate
|
|
22
|
-
} from '@codemirror/view';
|
|
17
|
+
import type { PluginValue, ViewUpdate } from '@codemirror/view';
|
|
18
|
+
import { EditorView, ViewPlugin } from '@codemirror/view';
|
|
23
19
|
import { Facet } from '@codemirror/state';
|
|
24
|
-
import { YRange,
|
|
20
|
+
import type { YRange, YSyncConfig } from './ybinding';
|
|
21
|
+
import { ySyncAnnotation, ySyncFacet } from './ybinding';
|
|
25
22
|
import type { UndoManager } from 'yjs';
|
|
26
23
|
|
|
27
24
|
interface IStackItem {
|
package/src/factory.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
|
|
4
|
-
import { CodeEditor, IEditorFactoryService } from '@jupyterlab/codeeditor';
|
|
5
|
-
import { ITranslator
|
|
4
|
+
import type { CodeEditor, IEditorFactoryService } from '@jupyterlab/codeeditor';
|
|
5
|
+
import type { ITranslator } from '@jupyterlab/translation';
|
|
6
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
6
7
|
import { EditorExtensionRegistry } from './extension';
|
|
7
8
|
import { CodeMirrorEditor } from './editor';
|
|
8
9
|
import { EditorLanguageRegistry } from './language';
|
|
9
|
-
import {
|
|
10
|
+
import type {
|
|
10
11
|
IEditorExtensionFactory,
|
|
11
12
|
IEditorExtensionRegistry,
|
|
12
13
|
IEditorFactoryOptions,
|
package/src/language.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
|
|
4
|
+
import type * as SQLModule from '@codemirror/lang-sql';
|
|
5
|
+
import type { StreamParser } from '@codemirror/language';
|
|
4
6
|
import {
|
|
5
7
|
LanguageDescription,
|
|
6
8
|
LanguageSupport,
|
|
7
9
|
LRLanguage,
|
|
8
|
-
StreamLanguage
|
|
9
|
-
StreamParser
|
|
10
|
+
StreamLanguage
|
|
10
11
|
} from '@codemirror/language';
|
|
11
12
|
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
|
|
12
13
|
import { PathExt } from '@jupyterlab/coreutils';
|
|
13
|
-
import { ITranslator
|
|
14
|
+
import type { ITranslator } from '@jupyterlab/translation';
|
|
15
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
14
16
|
import { buildParser } from '@lezer/generator';
|
|
15
17
|
import { highlightTree } from '@lezer/highlight';
|
|
16
18
|
|
|
17
19
|
import { jupyterHighlightStyle } from './theme';
|
|
18
|
-
import { IEditorLanguage, IEditorLanguageRegistry } from './token';
|
|
20
|
+
import type { IEditorLanguage, IEditorLanguageRegistry } from './token';
|
|
19
21
|
import { pythonBuiltin } from './pythonBuiltin';
|
|
20
22
|
|
|
21
23
|
/**
|
|
@@ -198,7 +200,7 @@ export class EditorLanguageRegistry implements IEditorLanguageRegistry {
|
|
|
198
200
|
): IEditorLanguage | null {
|
|
199
201
|
const modename = typeof language === 'string' ? language : language.name;
|
|
200
202
|
const mimetype = typeof language !== 'string' ? language.mime : modename;
|
|
201
|
-
const ext = typeof language !== 'string' ? language.extensions ?? [] : [];
|
|
203
|
+
const ext = typeof language !== 'string' ? (language.extensions ?? []) : [];
|
|
202
204
|
|
|
203
205
|
return (
|
|
204
206
|
(modename ? this.findByName(modename) : null) ??
|
|
@@ -286,7 +288,7 @@ export namespace EditorLanguageRegistry {
|
|
|
286
288
|
* @returns Language object
|
|
287
289
|
*/
|
|
288
290
|
async function sql(
|
|
289
|
-
dialectName: keyof typeof
|
|
291
|
+
dialectName: keyof typeof SQLModule
|
|
290
292
|
): Promise<LanguageSupport> {
|
|
291
293
|
const m = await import('@codemirror/lang-sql');
|
|
292
294
|
return m.sql({ dialect: (m as any)[dialectName] });
|
|
@@ -296,10 +298,12 @@ export namespace EditorLanguageRegistry {
|
|
|
296
298
|
* Get the default editor languages
|
|
297
299
|
*
|
|
298
300
|
* @param translator Application translator
|
|
301
|
+
* @param findLanguage Optional function to find a language by name for markdown code block highlighting
|
|
299
302
|
* @returns Default CodeMirror 6 languages
|
|
300
303
|
*/
|
|
301
304
|
export function getDefaultLanguages(
|
|
302
|
-
translator?: ITranslator | null
|
|
305
|
+
translator?: ITranslator | null,
|
|
306
|
+
findLanguage?: (info: string) => IEditorLanguage | null
|
|
303
307
|
): ReadonlyArray<IEditorLanguage> {
|
|
304
308
|
const trans = (translator ?? nullTranslator).load('jupyterlab');
|
|
305
309
|
return [
|
|
@@ -416,7 +420,23 @@ export namespace EditorLanguageRegistry {
|
|
|
416
420
|
extensions: ['md', 'markdown', 'mkd'],
|
|
417
421
|
async load() {
|
|
418
422
|
const m = await import('@codemirror/lang-markdown');
|
|
419
|
-
|
|
423
|
+
if (!findLanguage) {
|
|
424
|
+
return m.markdown();
|
|
425
|
+
}
|
|
426
|
+
return m.markdown({
|
|
427
|
+
codeLanguages: (info: string) => {
|
|
428
|
+
const language = findLanguage(info);
|
|
429
|
+
if (!language) {
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
if (language instanceof LanguageDescription) {
|
|
433
|
+
// Sometimes the IEditorLanguage returned is a
|
|
434
|
+
// LanguageDescription instance, so early return in this case.
|
|
435
|
+
return language;
|
|
436
|
+
}
|
|
437
|
+
return LanguageDescription.of(language);
|
|
438
|
+
}
|
|
439
|
+
});
|
|
420
440
|
}
|
|
421
441
|
},
|
|
422
442
|
{
|
package/src/mimetype.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
|
|
5
5
|
import { PathExt } from '@jupyterlab/coreutils';
|
|
6
|
-
import * as nbformat from '@jupyterlab/nbformat';
|
|
7
|
-
import { IEditorLanguageRegistry } from './token';
|
|
6
|
+
import type * as nbformat from '@jupyterlab/nbformat';
|
|
7
|
+
import type { IEditorLanguageRegistry } from './token';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The mime type service for CodeMirror.
|
|
@@ -29,9 +29,9 @@ export class CodeMirrorMimeTypeService implements IEditorMimeTypeService {
|
|
|
29
29
|
}
|
|
30
30
|
);
|
|
31
31
|
return mode
|
|
32
|
-
?
|
|
33
|
-
? mode.mime
|
|
34
|
-
: mode.mime
|
|
32
|
+
? typeof mode.mime === 'string'
|
|
33
|
+
? mode.mime
|
|
34
|
+
: (mode.mime[0] ?? IEditorMimeTypeService.defaultMimeType)
|
|
35
35
|
: IEditorMimeTypeService.defaultMimeType;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -52,9 +52,9 @@ export class CodeMirrorMimeTypeService implements IEditorMimeTypeService {
|
|
|
52
52
|
}
|
|
53
53
|
const mode = this.languages.findByFileName(path);
|
|
54
54
|
return mode
|
|
55
|
-
?
|
|
56
|
-
? mode.mime
|
|
57
|
-
: mode.mime
|
|
55
|
+
? typeof mode.mime === 'string'
|
|
56
|
+
? mode.mime
|
|
57
|
+
: (mode.mime[0] ?? IEditorMimeTypeService.defaultMimeType)
|
|
58
58
|
: IEditorMimeTypeService.defaultMimeType;
|
|
59
59
|
}
|
|
60
60
|
}
|
package/src/pythonBuiltin.ts
CHANGED
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Language
|
|
6
|
+
import type { Language } from '@codemirror/language';
|
|
7
|
+
import { syntaxTree } from '@codemirror/language';
|
|
7
8
|
import { RangeSetBuilder } from '@codemirror/state';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
ViewPlugin,
|
|
13
|
-
ViewUpdate
|
|
14
|
-
} from '@codemirror/view';
|
|
15
|
-
import { NodeProp, SyntaxNodeRef, Tree } from '@lezer/common';
|
|
9
|
+
import type { DecorationSet, EditorView, ViewUpdate } from '@codemirror/view';
|
|
10
|
+
import { Decoration, ViewPlugin } from '@codemirror/view';
|
|
11
|
+
import type { SyntaxNodeRef, Tree } from '@lezer/common';
|
|
12
|
+
import { NodeProp } from '@lezer/common';
|
|
16
13
|
|
|
17
14
|
export class PythonBuiltin {
|
|
18
15
|
decorations: DecorationSet;
|
package/src/searchprovider.ts
CHANGED
|
@@ -30,26 +30,25 @@
|
|
|
30
30
|
THE SOFTWARE.
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
-
import { ISearchMatch } from '@jupyterlab/documentsearch';
|
|
34
|
-
import { CodeMirrorEditor } from './editor';
|
|
35
|
-
import {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} from '@codemirror/state';
|
|
42
|
-
import { Decoration, DecorationSet, EditorView } from '@codemirror/view';
|
|
43
|
-
import { CodeEditor } from '@jupyterlab/codeeditor';
|
|
44
|
-
import {
|
|
45
|
-
GenericSearchProvider,
|
|
33
|
+
import type { ISearchMatch } from '@jupyterlab/documentsearch';
|
|
34
|
+
import type { CodeMirrorEditor } from './editor';
|
|
35
|
+
import type { Extension, StateEffectType } from '@codemirror/state';
|
|
36
|
+
import { EditorSelection, StateEffect, StateField } from '@codemirror/state';
|
|
37
|
+
import type { DecorationSet } from '@codemirror/view';
|
|
38
|
+
import { Decoration, EditorView } from '@codemirror/view';
|
|
39
|
+
import type { CodeEditor } from '@jupyterlab/codeeditor';
|
|
40
|
+
import type {
|
|
46
41
|
IBaseSearchProvider,
|
|
47
42
|
IFilters,
|
|
48
|
-
IReplaceOptions
|
|
43
|
+
IReplaceOptions
|
|
44
|
+
} from '@jupyterlab/documentsearch';
|
|
45
|
+
import {
|
|
46
|
+
GenericSearchProvider,
|
|
49
47
|
TextSearchEngine
|
|
50
48
|
} from '@jupyterlab/documentsearch';
|
|
51
|
-
import { ISignal
|
|
52
|
-
import {
|
|
49
|
+
import type { ISignal } from '@lumino/signaling';
|
|
50
|
+
import { Signal } from '@lumino/signaling';
|
|
51
|
+
import type { ISharedText, SourceChange } from '@jupyter/ydoc';
|
|
53
52
|
|
|
54
53
|
/**
|
|
55
54
|
* Defines from which position the search should be executed.
|
|
@@ -93,8 +92,7 @@ export interface IHighlightAdjacentMatchOptions extends IHighlightMatchOptions {
|
|
|
93
92
|
*/
|
|
94
93
|
export abstract class EditorSearchProvider<
|
|
95
94
|
T extends CodeEditor.IModel = CodeEditor.IModel
|
|
96
|
-
> implements IBaseSearchProvider
|
|
97
|
-
{
|
|
95
|
+
> implements IBaseSearchProvider {
|
|
98
96
|
/**
|
|
99
97
|
* Constructor
|
|
100
98
|
*/
|
package/src/theme.ts
CHANGED
|
@@ -6,11 +6,12 @@ import {
|
|
|
6
6
|
HighlightStyle,
|
|
7
7
|
syntaxHighlighting
|
|
8
8
|
} from '@codemirror/language';
|
|
9
|
-
import { Extension } from '@codemirror/state';
|
|
9
|
+
import type { Extension } from '@codemirror/state';
|
|
10
10
|
import { EditorView } from '@codemirror/view';
|
|
11
|
-
import { ITranslator
|
|
11
|
+
import type { ITranslator } from '@jupyterlab/translation';
|
|
12
|
+
import { nullTranslator } from '@jupyterlab/translation';
|
|
12
13
|
import { tags as t } from '@lezer/highlight';
|
|
13
|
-
import { IEditorTheme, IEditorThemeRegistry } from './token';
|
|
14
|
+
import type { IEditorTheme, IEditorThemeRegistry } from './token';
|
|
14
15
|
|
|
15
16
|
export const jupyterEditorTheme = EditorView.theme({
|
|
16
17
|
/**
|
package/src/token.ts
CHANGED
|
@@ -8,7 +8,8 @@ import type { Extension, StateEffect } from '@codemirror/state';
|
|
|
8
8
|
import type { EditorView } from '@codemirror/view';
|
|
9
9
|
import type { CodeEditor } from '@jupyterlab/codeeditor';
|
|
10
10
|
import type { ITranslator } from '@jupyterlab/translation';
|
|
11
|
-
import { ReadonlyJSONObject
|
|
11
|
+
import type { ReadonlyJSONObject } from '@lumino/coreutils';
|
|
12
|
+
import { Token } from '@lumino/coreutils';
|
|
12
13
|
import type { IDisposable } from '@lumino/disposable';
|
|
13
14
|
import type { ISignal } from '@lumino/signaling';
|
|
14
15
|
|
package/src/typings.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
declare module '@codemirror/legacy-modes/mode/python' {
|
|
7
|
-
import { StreamParser } from '@codemirror/language';
|
|
7
|
+
import type { StreamParser } from '@codemirror/language';
|
|
8
8
|
|
|
9
9
|
export const python: StreamParser<unknown>;
|
|
10
10
|
export const cython: StreamParser<unknown>;
|