@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.
Files changed (78) hide show
  1. package/lib/codemirror-ipythongfm.d.ts +9 -3
  2. package/lib/codemirror-ipythongfm.js +52 -30
  3. package/lib/codemirror-ipythongfm.js.map +1 -1
  4. package/lib/commands.d.ts +13 -0
  5. package/lib/commands.js +32 -0
  6. package/lib/commands.js.map +1 -0
  7. package/lib/editor.d.ts +48 -273
  8. package/lib/editor.js +220 -819
  9. package/lib/editor.js.map +1 -1
  10. package/lib/extension.d.ts +236 -0
  11. package/lib/extension.js +696 -0
  12. package/lib/extension.js.map +1 -0
  13. package/lib/extensions/customStyle.d.ts +25 -0
  14. package/lib/extensions/customStyle.js +51 -0
  15. package/lib/extensions/customStyle.js.map +1 -0
  16. package/lib/extensions/index.d.ts +3 -0
  17. package/lib/extensions/index.js +8 -0
  18. package/lib/extensions/index.js.map +1 -0
  19. package/lib/extensions/rulers.d.ts +8 -0
  20. package/lib/extensions/rulers.js +85 -0
  21. package/lib/extensions/rulers.js.map +1 -0
  22. package/lib/extensions/ybinding.d.ts +129 -0
  23. package/lib/extensions/ybinding.js +229 -0
  24. package/lib/extensions/ybinding.js.map +1 -0
  25. package/lib/factory.d.ts +15 -5
  26. package/lib/factory.js +53 -24
  27. package/lib/factory.js.map +1 -1
  28. package/lib/index.d.ts +7 -19
  29. package/lib/index.js +7 -23
  30. package/lib/index.js.map +1 -1
  31. package/lib/language.d.ts +96 -0
  32. package/lib/language.js +1687 -0
  33. package/lib/language.js.map +1 -0
  34. package/lib/mimetype.d.ts +3 -0
  35. package/lib/mimetype.js +16 -5
  36. package/lib/mimetype.js.map +1 -1
  37. package/lib/searchprovider.d.ts +219 -0
  38. package/lib/searchprovider.js +640 -0
  39. package/lib/searchprovider.js.map +1 -0
  40. package/lib/theme.d.ts +57 -0
  41. package/lib/theme.js +194 -0
  42. package/lib/theme.js.map +1 -0
  43. package/lib/token.d.ts +375 -0
  44. package/lib/token.js +18 -0
  45. package/lib/token.js.map +1 -0
  46. package/package.json +45 -41
  47. package/src/codemirror-ipythongfm.ts +109 -0
  48. package/src/commands.ts +34 -0
  49. package/src/editor.ts +783 -0
  50. package/src/extension.ts +890 -0
  51. package/src/extensions/customStyle.ts +79 -0
  52. package/src/extensions/index.ts +8 -0
  53. package/src/extensions/rulers.ts +112 -0
  54. package/src/extensions/ybinding.ts +295 -0
  55. package/src/factory.ts +100 -0
  56. package/src/index.ts +17 -0
  57. package/src/language.ts +1726 -0
  58. package/src/mimetype.ts +54 -0
  59. package/src/searchprovider.ts +813 -0
  60. package/src/theme.ts +219 -0
  61. package/src/token.ts +436 -0
  62. package/src/typings.d.ts +13 -0
  63. package/style/base.css +33 -187
  64. package/style/index.css +1 -7
  65. package/style/index.js +1 -7
  66. package/lib/codemirror-ipython.d.ts +0 -2
  67. package/lib/codemirror-ipython.js +0 -30
  68. package/lib/codemirror-ipython.js.map +0 -1
  69. package/lib/mode.d.ts +0 -82
  70. package/lib/mode.js +0 -150
  71. package/lib/mode.js.map +0 -1
  72. package/lib/syntaxstatus.d.ts +0 -67
  73. package/lib/syntaxstatus.js +0 -140
  74. package/lib/syntaxstatus.js.map +0 -1
  75. package/lib/tokens.d.ts +0 -18
  76. package/lib/tokens.js +0 -8
  77. package/lib/tokens.js.map +0 -1
  78. package/typings/codemirror/codemirror.d.ts +0 -227
package/src/theme.ts ADDED
@@ -0,0 +1,219 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import {
5
+ defaultHighlightStyle,
6
+ HighlightStyle,
7
+ syntaxHighlighting
8
+ } from '@codemirror/language';
9
+ import { Extension } from '@codemirror/state';
10
+ import { EditorView } from '@codemirror/view';
11
+ import { ITranslator, nullTranslator } from '@jupyterlab/translation';
12
+ import { tags as t } from '@lezer/highlight';
13
+ import { IEditorTheme, IEditorThemeRegistry } from './token';
14
+
15
+ export const jupyterEditorTheme = EditorView.theme({
16
+ /**
17
+ * CodeMirror themes are handling the background/color in this way. This works
18
+ * fine for CodeMirror editors outside the notebook, but the notebook styles
19
+ * these things differently.
20
+ */
21
+ '&': {
22
+ background: 'var(--jp-layout-color0)',
23
+ color: 'var(--jp-content-font-color1)'
24
+ },
25
+
26
+ /* In the notebook, we want this styling to be handled by its container */
27
+ '.jp-CodeConsole &, .jp-Notebook &': {
28
+ background: 'transparent'
29
+ },
30
+
31
+ '.cm-content': {
32
+ caretColor: 'var(--jp-editor-cursor-color)'
33
+ },
34
+
35
+ '.cm-cursor, .cm-dropCursor': {
36
+ borderLeft:
37
+ 'var(--jp-code-cursor-width0) solid var(--jp-editor-cursor-color)'
38
+ },
39
+
40
+ '.cm-selectionBackground, .cm-content ::selection': {
41
+ backgroundColor: 'var(--jp-editor-selected-background)'
42
+ },
43
+
44
+ '&.cm-focused .cm-selectionBackground': {
45
+ backgroundColor: 'var(--jp-editor-selected-focused-background)'
46
+ },
47
+
48
+ '.cm-gutters': {
49
+ borderRight: '1px solid var(--jp-border-color2)',
50
+ backgroundColor: 'var(--jp-layout-color2)'
51
+ },
52
+
53
+ '.cm-gutter, .cm-activeLine': {
54
+ backgroundColor: 'var(--jp-layout-color2)'
55
+ },
56
+
57
+ '.cm-searchMatch': {
58
+ backgroundColor: 'var(--jp-search-unselected-match-background-color)',
59
+ color: 'var(--jp-search-unselected-match-color)'
60
+ },
61
+
62
+ '.cm-searchMatch.cm-searchMatch-selected': {
63
+ backgroundColor:
64
+ 'var(--jp-search-selected-match-background-color) !important',
65
+ color: 'var(--jp-search-selected-match-color) !important'
66
+ }
67
+ });
68
+
69
+ // The list of available tags for syntax highlighting is available at
70
+ // https://lezer.codemirror.net/docs/ref/#highlight.tags
71
+ export const jupyterHighlightStyle = HighlightStyle.define([
72
+ // Order matters - a rule will override the previous ones; important for example for in headings styles.
73
+ { tag: t.meta, color: 'var(--jp-mirror-editor-meta-color)' },
74
+ { tag: t.heading, color: 'var(--jp-mirror-editor-header-color)' },
75
+ {
76
+ tag: [t.heading1, t.heading2, t.heading3, t.heading4],
77
+ color: 'var(--jp-mirror-editor-header-color)',
78
+ fontWeight: 'bold'
79
+ },
80
+ {
81
+ tag: t.keyword,
82
+ color: 'var(--jp-mirror-editor-keyword-color)',
83
+ fontWeight: 'bold'
84
+ },
85
+ { tag: t.atom, color: 'var(--jp-mirror-editor-atom-color)' },
86
+ { tag: t.number, color: 'var(--jp-mirror-editor-number-color)' },
87
+ {
88
+ tag: [t.definition(t.name), t.function(t.definition(t.variableName))],
89
+ color: 'var(--jp-mirror-editor-def-color)'
90
+ },
91
+ {
92
+ tag: t.standard(t.variableName),
93
+ color: 'var(--jp-mirror-editor-builtin-color)'
94
+ },
95
+ {
96
+ tag: [t.special(t.variableName), t.self],
97
+ color: 'var(--jp-mirror-editor-variable-2-color)'
98
+ },
99
+ { tag: t.punctuation, color: 'var(--jp-mirror-editor-punctuation-color)' },
100
+ { tag: t.propertyName, color: 'var(--jp-mirror-editor-property-color)' },
101
+ {
102
+ tag: t.operator,
103
+ color: 'var(--jp-mirror-editor-operator-color)',
104
+ fontWeight: 'bold'
105
+ },
106
+ {
107
+ tag: t.comment,
108
+ color: 'var(--jp-mirror-editor-comment-color)',
109
+ fontStyle: 'italic'
110
+ },
111
+ { tag: t.string, color: 'var(--jp-mirror-editor-string-color)' },
112
+ {
113
+ tag: [t.labelName, t.monospace, t.special(t.string)],
114
+ color: 'var(--jp-mirror-editor-string-2-color)'
115
+ },
116
+ { tag: t.bracket, color: 'var(--jp-mirror-editor-bracket-color)' },
117
+ { tag: t.tagName, color: 'var(--jp-mirror-editor-tag-color)' },
118
+ { tag: t.attributeName, color: 'var(--jp-mirror-editor-attribute-color)' },
119
+ { tag: t.quote, color: 'var(--jp-mirror-editor-quote-color)' },
120
+ {
121
+ tag: t.link,
122
+ color: 'var(--jp-mirror-editor-link-color)',
123
+ textDecoration: 'underline'
124
+ },
125
+ { tag: [t.separator, t.derefOperator, t.paren], color: '' },
126
+ { tag: t.strong, fontWeight: 'bold' },
127
+ { tag: t.emphasis, fontStyle: 'italic' },
128
+ { tag: t.strikethrough, textDecoration: 'line-through' }
129
+ ]);
130
+
131
+ /**
132
+ * JupyterLab CodeMirror 6 theme
133
+ */
134
+ export const jupyterTheme: Extension = [
135
+ jupyterEditorTheme,
136
+ syntaxHighlighting(jupyterHighlightStyle)
137
+ ];
138
+
139
+ /**
140
+ * CodeMirror 6 theme registry
141
+ */
142
+ export class EditorThemeRegistry implements IEditorThemeRegistry {
143
+ /**
144
+ * CodeMirror 6 themes
145
+ */
146
+ private _themeMap: Map<string, IEditorTheme> = new Map([
147
+ ['jupyter', Object.freeze({ name: 'jupyter', theme: jupyterTheme })]
148
+ ]);
149
+
150
+ /**
151
+ * Get all themes
152
+ */
153
+ get themes(): IEditorTheme[] {
154
+ return Array.from(this._themeMap.values());
155
+ }
156
+
157
+ /**
158
+ * Get the default CodeMirror 6 theme for JupyterLab
159
+ *
160
+ * @returns Default theme
161
+ */
162
+ defaultTheme(): Extension {
163
+ return this._themeMap.get('jupyter')!.theme;
164
+ }
165
+
166
+ /**
167
+ * Register a new theme.
168
+ *
169
+ * @param theme Codemirror 6 theme
170
+ */
171
+ addTheme(theme: IEditorTheme) {
172
+ if (this._themeMap.has(theme.name)) {
173
+ throw new Error(`A theme named '${theme.name}' is already registered.`);
174
+ }
175
+ this._themeMap.set(theme.name, { displayName: theme.name, ...theme });
176
+ }
177
+
178
+ /**
179
+ * Get a theme.
180
+ *
181
+ * #### Notes
182
+ * It falls back to the default theme
183
+ *
184
+ * @param name Theme name
185
+ * @returns Theme extension
186
+ */
187
+ getTheme(name: string): Extension {
188
+ const ext = this._themeMap.get(name)?.theme;
189
+
190
+ return ext ?? this.defaultTheme();
191
+ }
192
+ }
193
+
194
+ /**
195
+ * EditorThemeRegistry namespace
196
+ */
197
+ export namespace EditorThemeRegistry {
198
+ /**
199
+ * Get the default editor themes.
200
+ *
201
+ * @param translator Application translator
202
+ * @returns Default CodeMirror 6 themes
203
+ */
204
+ export function getDefaultThemes(
205
+ translator?: ITranslator | null
206
+ ): ReadonlyArray<Readonly<IEditorTheme>> {
207
+ const trans = (translator ?? nullTranslator).load('jupyterlab');
208
+ return [
209
+ Object.freeze({
210
+ name: 'codemirror',
211
+ displayName: trans.__('codemirror'),
212
+ theme: [
213
+ EditorView.baseTheme({}),
214
+ syntaxHighlighting(defaultHighlightStyle)
215
+ ]
216
+ })
217
+ ];
218
+ }
219
+ }
package/src/token.ts ADDED
@@ -0,0 +1,436 @@
1
+ /*
2
+ * Copyright (c) Jupyter Development Team.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+
6
+ import type { LanguageSupport } from '@codemirror/language';
7
+ import type { Extension, StateEffect } from '@codemirror/state';
8
+ import type { EditorView } from '@codemirror/view';
9
+ import type { CodeEditor } from '@jupyterlab/codeeditor';
10
+ import type { ITranslator } from '@jupyterlab/translation';
11
+ import { ReadonlyJSONObject, Token } from '@lumino/coreutils';
12
+ import type { IDisposable } from '@lumino/disposable';
13
+ import type { ISignal } from '@lumino/signaling';
14
+
15
+ /**
16
+ * Dynamically configurable editor extension interface.
17
+ */
18
+ export interface IConfigurableExtension<T> {
19
+ /**
20
+ * Create an editor extension for the provided value.
21
+ *
22
+ * @param value Editor extension parameter value
23
+ * @returns The editor extension
24
+ */
25
+ instance(value: T): Extension;
26
+ /**
27
+ * Reconfigure an editor extension.
28
+ *
29
+ * ### Notes
30
+ * Return `null` if the value does not trigger
31
+ * a state effect. In particular for immutable extension.
32
+ *
33
+ * @param value Editor extension value
34
+ * @returns Editor state effect
35
+ */
36
+ reconfigure(value: T): StateEffect<T> | null;
37
+ }
38
+
39
+ /**
40
+ * Editor language token.
41
+ */
42
+ export const IEditorExtensionRegistry = new Token<IEditorExtensionRegistry>(
43
+ '@jupyterlab/codemirror:IEditorExtensionRegistry'
44
+ );
45
+
46
+ /**
47
+ * Interface of CodeMirror editor extensions handler
48
+ *
49
+ * ### Notes
50
+ * This handler is instantiated for each editor to manage its own
51
+ * set of extensions.
52
+ */
53
+ export interface IExtensionsHandler extends IDisposable {
54
+ /**
55
+ * Signal triggered when the editor configuration changes.
56
+ * It provides the mapping of the new configuration (only those that changed).
57
+ *
58
+ * It should result in a call to `IExtensionsHandler.reconfigureExtensions`.
59
+ */
60
+ readonly configChanged: ISignal<this, Record<string, any>>;
61
+
62
+ /**
63
+ * Get a config option for the editor.
64
+ */
65
+ getOption(option: string): unknown;
66
+
67
+ /**
68
+ * Whether the option exists or not.
69
+ */
70
+ hasOption(option: string): boolean;
71
+
72
+ /**
73
+ * Set a config option for the editor.
74
+ *
75
+ * You will need to reconfigure the editor extensions by listening
76
+ * to `IExtensionsHandler.configChanged`.
77
+ */
78
+ setOption(option: string, value: unknown): void;
79
+
80
+ /**
81
+ * Set config options for the editor.
82
+ *
83
+ * You will need to reconfigure the editor extensions by listening
84
+ * to `IExtensionsHandler.configChanged`.
85
+ *
86
+ * This method is preferred when setting several options. The
87
+ * options are set within an operation, which only performs
88
+ * the costly update at the end, and not after every option
89
+ * is set.
90
+ */
91
+ setOptions(options: Record<string, any>): void;
92
+
93
+ /**
94
+ * Returns the list of initial extensions of an editor.
95
+ *
96
+ * @returns The initial editor extensions
97
+ */
98
+ getInitialExtensions(): Extension[];
99
+
100
+ /**
101
+ * Appends extensions to the top-level configuration of the
102
+ * editor.
103
+ *
104
+ * @alpha
105
+ * @param view Editor view
106
+ * @param extension Editor extension to inject
107
+ */
108
+ injectExtension(view: EditorView, extension: Extension): void;
109
+
110
+ /**
111
+ * Reconfigures the extension mapped with key with the provided value.
112
+ *
113
+ * @param view Editor view
114
+ * @param key Parameter unique key
115
+ * @param value Parameter value to be applied
116
+ */
117
+ reconfigureExtension<T>(view: EditorView, key: string, value: T): void;
118
+
119
+ /**
120
+ * Reconfigures all the extensions mapped with the options from the
121
+ * provided partial configuration.
122
+ *
123
+ * @param view Editor view
124
+ * @param configuration Editor configuration
125
+ */
126
+ reconfigureExtensions(
127
+ view: EditorView,
128
+ configuration: Record<string, any>
129
+ ): void;
130
+ }
131
+
132
+ /**
133
+ * Editor extension factory interface.
134
+ *
135
+ * @template T Extension parameter type.
136
+ */
137
+ export interface IEditorExtensionFactory<T = undefined> {
138
+ /**
139
+ * Editor extension unique identifier.
140
+ */
141
+ readonly name: string;
142
+ /**
143
+ * Extension factory.
144
+ *
145
+ * @param options
146
+ * @returns The extension builder or null if the extension is not active for that document
147
+ */
148
+ readonly factory: (
149
+ options: IEditorExtensionFactory.IOptions
150
+ ) => IConfigurableExtension<T> | null;
151
+ /**
152
+ * Extension default value
153
+ *
154
+ * ### Notes
155
+ * If undefined but has a schema, the default value will be `null` to be JSON serializable.
156
+ */
157
+ readonly default?: T;
158
+ /**
159
+ * JSON schema defining the configurable option through user settings.
160
+ *
161
+ * If this is defined, every time the setting changes, `IConfigurableExtension.reconfigure`
162
+ * will be called with the new setting value.
163
+ *
164
+ * ### Notes
165
+ * If no default value is provided, `IEditorExtensionFactory.default` will be used.
166
+ * If the extension is to be handled by the code only, this should not be defined.
167
+ */
168
+ readonly schema?: ReadonlyJSONObject;
169
+ }
170
+
171
+ /**
172
+ * CodeMirror extension factory namespace
173
+ */
174
+ export namespace IEditorExtensionFactory {
175
+ /**
176
+ * CodeMirror extension factory options
177
+ */
178
+ export interface IOptions {
179
+ /**
180
+ * Whether the editor will be inline or not.
181
+ */
182
+ inline: boolean;
183
+ /**
184
+ * The model used by the editor.
185
+ */
186
+ model: CodeEditor.IModel;
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Interface for generating editor configuration registry.
192
+ */
193
+ export interface IEditorExtensionRegistry {
194
+ /**
195
+ * Base editor configuration
196
+ *
197
+ * This is the default configuration.
198
+ */
199
+ readonly baseConfiguration: Record<string, any>;
200
+
201
+ /**
202
+ * Add a default editor extension
203
+ *
204
+ * @template T Extension parameter type
205
+ * @param factory Extension factory
206
+ */
207
+ addExtension<T>(factory: IEditorExtensionFactory<T>): void;
208
+
209
+ /**
210
+ * Create a new extensions handler for an editor
211
+ *
212
+ * @param options Extensions options and initial editor configuration
213
+ */
214
+ createNew(
215
+ options: IEditorExtensionFactory.IOptions & {
216
+ /**
217
+ * The configuration options for the editor.
218
+ */
219
+ config?: Record<string, any>;
220
+ }
221
+ ): IExtensionsHandler;
222
+ }
223
+
224
+ /**
225
+ * Editor factory constructor options
226
+ */
227
+ export interface IEditorFactoryOptions {
228
+ /**
229
+ * Editor extensions registry
230
+ */
231
+ extensions?: IEditorExtensionRegistry;
232
+ /**
233
+ * Editor languages registry
234
+ */
235
+ languages?: IEditorLanguageRegistry;
236
+ /**
237
+ * Application translation registry
238
+ */
239
+ translator?: ITranslator;
240
+ }
241
+
242
+ /**
243
+ * Editor language token.
244
+ */
245
+ export const IEditorLanguageRegistry = new Token<IEditorLanguageRegistry>(
246
+ '@jupyterlab/codemirror:IEditorLanguageRegistry'
247
+ );
248
+
249
+ /**
250
+ * The interface of a codemirror language specification.
251
+ */
252
+ export interface IEditorLanguage {
253
+ /**
254
+ * Language name.
255
+ */
256
+ readonly name: string;
257
+ /**
258
+ * Language displayed name.
259
+ */
260
+ readonly displayName?: string;
261
+ /**
262
+ * Language name alias.
263
+ */
264
+ readonly alias?: readonly string[];
265
+ /**
266
+ * Language mime types.
267
+ */
268
+ readonly mime: string | readonly string[];
269
+ /**
270
+ * Language support loader.
271
+ */
272
+ readonly load?: () => Promise<LanguageSupport>;
273
+ /**
274
+ * Supported file extensions.
275
+ */
276
+ readonly extensions?: readonly string[];
277
+ /**
278
+ * Filename expression supported by the language.
279
+ */
280
+ readonly filename?: RegExp;
281
+ /**
282
+ * CodeMirror language support.
283
+ *
284
+ * ### Notes
285
+ * It can provided directly or it will be obtained using `load`.
286
+ */
287
+ support?: LanguageSupport;
288
+ }
289
+
290
+ /**
291
+ * Editor language interface
292
+ */
293
+ export interface IEditorLanguageRegistry {
294
+ /**
295
+ * Register a new language for CodeMirror
296
+ *
297
+ * @param language Language to register
298
+ */
299
+ addLanguage(language: IEditorLanguage): void;
300
+
301
+ /**
302
+ * Find a codemirror language by name or CodeMirror spec.
303
+ *
304
+ * @param language The CodeMirror language
305
+ * @param fallback Whether to fallback to default mimetype spec or not
306
+ * @returns The language or null
307
+ */
308
+ findBest(
309
+ language: string | IEditorLanguage,
310
+ fallback?: boolean
311
+ ): IEditorLanguage | null;
312
+
313
+ /**
314
+ * Find a codemirror language by MIME.
315
+ *
316
+ * @param mime Mime type to look for
317
+ * @returns The language or null
318
+ */
319
+ findByMIME(mime: string | readonly string[]): IEditorLanguage | null;
320
+
321
+ /**
322
+ * Find a codemirror language by name.
323
+ *
324
+ * @param name The language name
325
+ * @returns The language or null
326
+ */
327
+ findByName(name: string): IEditorLanguage | null;
328
+
329
+ /**
330
+ * Find a codemirror language by extension.
331
+ *
332
+ * @param ext The extension name
333
+ * @returns The language or null
334
+ */
335
+ findByExtension(ext: string | readonly string[]): IEditorLanguage | null;
336
+
337
+ /**
338
+ * Find a codemirror language by filename.
339
+ *
340
+ * @param name File name
341
+ * @returns The language or null
342
+ */
343
+ findByFileName(name: string): IEditorLanguage | null;
344
+
345
+ /**
346
+ * Load a CodeMirror language specified by name or Codemirror spec.
347
+ *
348
+ * @param language - The language to ensure. If it is a string, uses {@link findBest}
349
+ * to get the appropriate spec.
350
+ *
351
+ * @returns A promise that resolves when the language is available.
352
+ */
353
+ getLanguage(
354
+ language: string | IEditorLanguage
355
+ ): Promise<IEditorLanguage | null>;
356
+
357
+ /**
358
+ * Get the raw list of available languages specs.
359
+ *
360
+ * @returns The available languages
361
+ */
362
+ getLanguages(): IEditorLanguage[];
363
+
364
+ /**
365
+ * Parse and style a string.
366
+ *
367
+ * @param code Code to highlight
368
+ * @param language Code language
369
+ * @param el HTML element into which the highlighted code will be inserted
370
+ */
371
+ highlight(
372
+ code: string,
373
+ language: IEditorLanguage | null,
374
+ el: HTMLElement
375
+ ): Promise<void>;
376
+ }
377
+
378
+ /**
379
+ * Editor theme token.
380
+ */
381
+ export const IEditorThemeRegistry = new Token<IEditorThemeRegistry>(
382
+ '@jupyterlab/codemirror:IEditorThemeRegistry'
383
+ );
384
+
385
+ /**
386
+ * Editor theme interface
387
+ */
388
+ export interface IEditorTheme {
389
+ /**
390
+ * Theme unique identifier
391
+ */
392
+ readonly name: string;
393
+ /**
394
+ * Theme name
395
+ */
396
+ readonly displayName?: string;
397
+ /**
398
+ * Editor extension for the theme
399
+ */
400
+ readonly theme: Extension;
401
+ }
402
+
403
+ /**
404
+ * Theme editor registry interface
405
+ */
406
+ export interface IEditorThemeRegistry {
407
+ /**
408
+ * Register a new theme.
409
+ *
410
+ * @param theme Codemirror 6 theme
411
+ */
412
+ addTheme(theme: IEditorTheme): void;
413
+
414
+ /**
415
+ * Get the default CodeMirror 6 theme for JupyterLab
416
+ *
417
+ * @returns Default theme as a CodeMirror extension
418
+ */
419
+ defaultTheme(): Extension;
420
+
421
+ /**
422
+ * Get a theme.
423
+ *
424
+ * #### Notes
425
+ * It falls back to the default theme
426
+ *
427
+ * @param name Theme name
428
+ * @returns Theme extension
429
+ */
430
+ getTheme(name: string): Extension;
431
+
432
+ /**
433
+ * Get all themes
434
+ */
435
+ readonly themes: IEditorTheme[];
436
+ }
@@ -0,0 +1,13 @@
1
+ /*
2
+ * Copyright (c) Jupyter Development Team.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+
6
+ declare module '@codemirror/legacy-modes/mode/python' {
7
+ import { StreamParser } from '@codemirror/language';
8
+
9
+ export const python: StreamParser<unknown>;
10
+ export const cython: StreamParser<unknown>;
11
+
12
+ export function mkPython(parserConf: any): StreamParser<unknown>;
13
+ }