@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.
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlab/codemirror",
3
- "version": "4.0.0-alpha.9",
3
+ "version": "4.0.0-beta.1",
4
4
  "description": "JupyterLab - CodeMirror Editor Provider",
5
5
  "homepage": "https://github.com/jupyterlab/jupyterlab",
6
6
  "bugs": {
@@ -20,16 +20,15 @@
20
20
  "lib": "lib/"
21
21
  },
22
22
  "files": [
23
- "lib/*.d.ts",
24
- "lib/*.js.map",
25
- "lib/*.js",
23
+ "lib/**/*.{d.ts,js,js.map}",
26
24
  "style/*.css",
27
25
  "typings/codemirror/*.d.ts",
28
- "style/index.js"
26
+ "style/index.js",
27
+ "src/**/*.{ts,tsx}"
29
28
  ],
30
29
  "scripts": {
31
30
  "build": "tsc -b",
32
- "build:test": "tsc --build tsconfig.test.json",
31
+ "build:test": "lezer-generator test/foo.grammar -o test/foo.js && tsc --build tsconfig.test.json",
33
32
  "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
34
33
  "docs": "typedoc src",
35
34
  "test": "jest",
@@ -39,47 +38,52 @@
39
38
  "watch": "tsc -b --watch"
40
39
  },
41
40
  "dependencies": {
42
- "@jupyterlab/apputils": "^4.0.0-alpha.9",
43
- "@jupyterlab/codeeditor": "^4.0.0-alpha.9",
44
- "@jupyterlab/coreutils": "^6.0.0-alpha.9",
45
- "@jupyterlab/nbformat": "^4.0.0-alpha.9",
46
- "@jupyterlab/observables": "^5.0.0-alpha.9",
47
- "@jupyterlab/shared-models": "^4.0.0-alpha.9",
48
- "@jupyterlab/statusbar": "^4.0.0-alpha.9",
49
- "@jupyterlab/translation": "^4.0.0-alpha.9",
50
- "@jupyterlab/ui-components": "^4.0.0-alpha.24",
51
- "@lumino/algorithm": "^1.9.1",
52
- "@lumino/commands": "^1.20.0",
53
- "@lumino/coreutils": "^1.12.0",
54
- "@lumino/disposable": "^1.10.1",
55
- "@lumino/polling": "^1.10.0",
56
- "@lumino/signaling": "^1.10.1",
57
- "@lumino/widgets": "^1.31.1",
58
- "codemirror": "~5.61.0",
59
- "react": "^17.0.1",
60
- "y-codemirror": "^3.0.1"
41
+ "@codemirror/autocomplete": "^6.4.0",
42
+ "@codemirror/commands": "^6.1.0",
43
+ "@codemirror/lang-cpp": "^6.0.0",
44
+ "@codemirror/lang-css": "^6.0.0",
45
+ "@codemirror/lang-html": "^6.4.0",
46
+ "@codemirror/lang-java": "^6.0.0",
47
+ "@codemirror/lang-javascript": "^6.1.0",
48
+ "@codemirror/lang-json": "^6.0.0",
49
+ "@codemirror/lang-markdown": "^6.0.0",
50
+ "@codemirror/lang-php": "^6.0.0",
51
+ "@codemirror/lang-python": "^6.1.0",
52
+ "@codemirror/lang-rust": "^6.0.0",
53
+ "@codemirror/lang-sql": "^6.3.0",
54
+ "@codemirror/lang-wast": "^6.0.0",
55
+ "@codemirror/lang-xml": "^6.0.0",
56
+ "@codemirror/language": "^6.4.0",
57
+ "@codemirror/legacy-modes": "^6.3.0",
58
+ "@codemirror/search": "^6.2.0",
59
+ "@codemirror/state": "^6.2.0",
60
+ "@codemirror/view": "^6.7.0",
61
+ "@jupyter/ydoc": "^1.0.0",
62
+ "@jupyterlab/codeeditor": "^4.0.0-beta.1",
63
+ "@jupyterlab/coreutils": "^6.0.0-beta.1",
64
+ "@jupyterlab/documentsearch": "^4.0.0-beta.1",
65
+ "@jupyterlab/nbformat": "^4.0.0-beta.1",
66
+ "@jupyterlab/translation": "^4.0.0-beta.1",
67
+ "@lezer/common": "^1.0.0",
68
+ "@lezer/generator": "^1.0.0",
69
+ "@lezer/highlight": "^1.0.0",
70
+ "@lumino/coreutils": "^2.0.0",
71
+ "@lumino/disposable": "^2.0.0",
72
+ "@lumino/signaling": "^2.0.0",
73
+ "yjs": "^13.5.40"
61
74
  },
62
75
  "devDependencies": {
63
- "@jupyterlab/testutils": "^4.0.0-alpha.9",
64
- "@types/codemirror": "^0.0.109",
65
- "@types/jest": "^26.0.10",
66
- "jest": "^26.4.2",
76
+ "@jupyterlab/testing": "^4.0.0-beta.1",
77
+ "@lezer/generator": "^1.0.0",
78
+ "@lezer/lr": "^1.0.0",
79
+ "@types/jest": "^29.2.0",
80
+ "jest": "^29.2.0",
67
81
  "rimraf": "~3.0.0",
68
- "ts-jest": "^26.3.0",
69
- "typedoc": "~0.22.10",
70
- "typescript": "~4.6.3"
82
+ "typedoc": "~0.23.25",
83
+ "typescript": "~5.0.2"
71
84
  },
72
85
  "publishConfig": {
73
86
  "access": "public"
74
87
  },
75
- "jupyterlab": {
76
- "extraStyles": {
77
- "codemirror": [
78
- "lib/codemirror.css",
79
- "addon/dialog/dialog.css",
80
- "addon/fold/foldgutter.css"
81
- ]
82
- }
83
- },
84
88
  "styleModule": "style/index.js"
85
89
  }
@@ -0,0 +1,109 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ // TODO: add support for LaTeX
5
+ // This should be coded as an extension for https://github.com/lezer-parser/markdown
6
+ // see https://github.com/lezer-parser/markdown/blob/main/src/extension.ts for examples
7
+ // Then this extension can be passed to the markdown function above:
8
+ //
9
+ // load: () => {
10
+ // return import('@codemirror/lang-markdown').then(m => m.markdown({extensions: latex}));
11
+ // }
12
+
13
+ /*import CodeMirror from 'codemirror';
14
+ import 'codemirror/addon/mode/multiplex';
15
+ import 'codemirror/mode/gfm/gfm';
16
+ import 'codemirror/mode/stex/stex';
17
+ */
18
+ /**
19
+ * Define an IPython GFM (GitHub Flavored Markdown) mode.
20
+ *
21
+ * Is just a slightly altered GFM Mode with support for LaTeX.
22
+ * LaTeX support was supported by Codemirror GFM as of
23
+ * https://github.com/codemirror/CodeMirror/pull/567
24
+ * But was later removed in
25
+ * https://github.com/codemirror/CodeMirror/commit/d9c9f1b1ffe984aee41307f3e927f80d1f23590c
26
+ */
27
+ /*CodeMirror.defineMode(
28
+ 'ipythongfm',
29
+ (config: CodeMirror.EditorConfiguration, modeOptions?: any) => {
30
+ const gfmMode = CodeMirror.getMode(config, {
31
+ name: 'gfm',
32
+ // Override list3 with an under-used token, rather than `keyword`
33
+ tokenTypeOverrides: { list3: 'string-2' }
34
+ });
35
+ const texMode = CodeMirror.getMode(config, {
36
+ name: 'stex',
37
+ inMathMode: true
38
+ });
39
+
40
+ return CodeMirror.multiplexingMode(
41
+ gfmMode,
42
+ // force parsing inline code and code blocks with gfmMode to prevent
43
+ // parsing them as tex see:
44
+ // https://github.com/jupyterlab/jupyterlab/issues/6774
45
+ {
46
+ open: '<code>',
47
+ close: '</code>',
48
+ mode: gfmMode,
49
+ parseDelimiters: true
50
+ },
51
+ {
52
+ open: '<pre>',
53
+ close: '</pre>',
54
+ mode: gfmMode,
55
+ parseDelimiters: true
56
+ },
57
+ {
58
+ open: '```',
59
+ close: '```',
60
+ mode: gfmMode,
61
+ parseDelimiters: true
62
+ },
63
+ {
64
+ open: '`',
65
+ close: '`',
66
+ mode: gfmMode,
67
+ parseDelimiters: true
68
+ },
69
+ // only if we did not match a code element or block,
70
+ // then try do parse using the tex mode
71
+ {
72
+ open: '$$',
73
+ close: '$$',
74
+ mode: texMode,
75
+ delimStyle: 'delimit'
76
+ },
77
+ {
78
+ // `$math mode$` is only matched if both opening
79
+ // and closing $ are in the same line
80
+ open: /\$(?=.*\$)/,
81
+ close: '$',
82
+ mode: texMode,
83
+ delimStyle: 'delimit'
84
+ },
85
+ {
86
+ open: '\\(',
87
+ close: '\\)',
88
+ mode: texMode,
89
+ delimStyle: 'delimit'
90
+ },
91
+ {
92
+ open: '\\[',
93
+ close: '\\]',
94
+ mode: texMode,
95
+ delimStyle: 'delimit'
96
+ }
97
+ // .. more multiplexed styles can follow here
98
+ );
99
+ },
100
+ 'gfm'
101
+ );
102
+
103
+ CodeMirror.defineMIME('text/x-ipythongfm', 'ipythongfm');
104
+ CodeMirror.modeInfo.push({
105
+ ext: [],
106
+ mime: 'text/x-ipythongfm',
107
+ mode: 'ipythongfm',
108
+ name: 'ipythongfm'
109
+ });*/
@@ -0,0 +1,34 @@
1
+ /*
2
+ * Copyright (c) Jupyter Development Team.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+
6
+ import { indentMore, insertTab } from '@codemirror/commands';
7
+ import { EditorState, Transaction } from '@codemirror/state';
8
+
9
+ /**
10
+ * CodeMirror commands namespace
11
+ */
12
+ export namespace StateCommands {
13
+ /**
14
+ * Indent or insert a tab as appropriate.
15
+ */
16
+ export function indentMoreOrInsertTab(target: {
17
+ state: EditorState;
18
+ dispatch: (transaction: Transaction) => void;
19
+ }): boolean {
20
+ const arg = { state: target.state, dispatch: target.dispatch };
21
+ const from = target.state.selection.main.from;
22
+ const to = target.state.selection.main.to;
23
+ if (from != to) {
24
+ return indentMore(arg);
25
+ }
26
+ const line = target.state.doc.lineAt(from);
27
+ const before = target.state.doc.slice(line.from, from).toString();
28
+ if (/^\s*$/.test(before)) {
29
+ return indentMore(arg);
30
+ } else {
31
+ return insertTab(arg);
32
+ }
33
+ }
34
+ }