@difizen/libro-codemirror 0.0.0-snapshot-20241017072317

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 (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -0
  3. package/es/auto-complete/closebrackets.d.ts +12 -0
  4. package/es/auto-complete/closebrackets.d.ts.map +1 -0
  5. package/es/auto-complete/closebrackets.js +409 -0
  6. package/es/auto-complete/completion.d.ts +57 -0
  7. package/es/auto-complete/completion.d.ts.map +1 -0
  8. package/es/auto-complete/completion.js +267 -0
  9. package/es/auto-complete/config.d.ts +22 -0
  10. package/es/auto-complete/config.d.ts.map +1 -0
  11. package/es/auto-complete/config.js +44 -0
  12. package/es/auto-complete/filter.d.ts +13 -0
  13. package/es/auto-complete/filter.d.ts.map +1 -0
  14. package/es/auto-complete/filter.js +190 -0
  15. package/es/auto-complete/index.d.ts +17 -0
  16. package/es/auto-complete/index.d.ts.map +1 -0
  17. package/es/auto-complete/index.js +107 -0
  18. package/es/auto-complete/snippet.d.ts +14 -0
  19. package/es/auto-complete/snippet.d.ts.map +1 -0
  20. package/es/auto-complete/snippet.js +445 -0
  21. package/es/auto-complete/state.d.ts +63 -0
  22. package/es/auto-complete/state.d.ts.map +1 -0
  23. package/es/auto-complete/state.js +448 -0
  24. package/es/auto-complete/theme.d.ts +6 -0
  25. package/es/auto-complete/theme.d.ts.map +1 -0
  26. package/es/auto-complete/theme.js +150 -0
  27. package/es/auto-complete/tooltip.d.ts +5 -0
  28. package/es/auto-complete/tooltip.d.ts.map +1 -0
  29. package/es/auto-complete/tooltip.js +365 -0
  30. package/es/auto-complete/view.d.ts +38 -0
  31. package/es/auto-complete/view.d.ts.map +1 -0
  32. package/es/auto-complete/view.js +368 -0
  33. package/es/auto-complete/word.d.ts +3 -0
  34. package/es/auto-complete/word.d.ts.map +1 -0
  35. package/es/auto-complete/word.js +119 -0
  36. package/es/completion.d.ts +6 -0
  37. package/es/completion.d.ts.map +1 -0
  38. package/es/completion.js +84 -0
  39. package/es/config.d.ts +189 -0
  40. package/es/config.d.ts.map +1 -0
  41. package/es/config.js +482 -0
  42. package/es/editor-contribution.d.ts +9 -0
  43. package/es/editor-contribution.d.ts.map +1 -0
  44. package/es/editor-contribution.js +35 -0
  45. package/es/editor.d.ts +397 -0
  46. package/es/editor.d.ts.map +1 -0
  47. package/es/editor.js +1338 -0
  48. package/es/factory.d.ts +4 -0
  49. package/es/factory.d.ts.map +1 -0
  50. package/es/factory.js +24 -0
  51. package/es/hyperlink.d.ts +15 -0
  52. package/es/hyperlink.d.ts.map +1 -0
  53. package/es/hyperlink.js +120 -0
  54. package/es/indent.d.ts +8 -0
  55. package/es/indent.d.ts.map +1 -0
  56. package/es/indent.js +58 -0
  57. package/es/indentation-markers/config.d.ts +17 -0
  58. package/es/indentation-markers/config.d.ts.map +1 -0
  59. package/es/indentation-markers/config.js +10 -0
  60. package/es/indentation-markers/index.d.ts +3 -0
  61. package/es/indentation-markers/index.d.ts.map +1 -0
  62. package/es/indentation-markers/index.js +160 -0
  63. package/es/indentation-markers/map.d.ts +77 -0
  64. package/es/indentation-markers/map.d.ts.map +1 -0
  65. package/es/indentation-markers/map.js +265 -0
  66. package/es/indentation-markers/utils.d.ts +27 -0
  67. package/es/indentation-markers/utils.d.ts.map +1 -0
  68. package/es/indentation-markers/utils.js +91 -0
  69. package/es/index.d.ts +13 -0
  70. package/es/index.d.ts.map +1 -0
  71. package/es/index.js +12 -0
  72. package/es/libro-icon.d.ts +3 -0
  73. package/es/libro-icon.d.ts.map +1 -0
  74. package/es/libro-icon.js +2 -0
  75. package/es/lsp/completion.d.ts +5 -0
  76. package/es/lsp/completion.d.ts.map +1 -0
  77. package/es/lsp/completion.js +245 -0
  78. package/es/lsp/format.d.ts +7 -0
  79. package/es/lsp/format.d.ts.map +1 -0
  80. package/es/lsp/format.js +193 -0
  81. package/es/lsp/index.d.ts +7 -0
  82. package/es/lsp/index.d.ts.map +1 -0
  83. package/es/lsp/index.js +6 -0
  84. package/es/lsp/lint.d.ts +3 -0
  85. package/es/lsp/lint.d.ts.map +1 -0
  86. package/es/lsp/lint.js +113 -0
  87. package/es/lsp/protocol.d.ts +7 -0
  88. package/es/lsp/protocol.d.ts.map +1 -0
  89. package/es/lsp/protocol.js +1 -0
  90. package/es/lsp/tooltip.d.ts +3 -0
  91. package/es/lsp/tooltip.d.ts.map +1 -0
  92. package/es/lsp/tooltip.js +113 -0
  93. package/es/lsp/util.d.ts +15 -0
  94. package/es/lsp/util.d.ts.map +1 -0
  95. package/es/lsp/util.js +57 -0
  96. package/es/mimetype.d.ts +22 -0
  97. package/es/mimetype.d.ts.map +1 -0
  98. package/es/mimetype.js +59 -0
  99. package/es/mode.d.ts +86 -0
  100. package/es/mode.d.ts.map +1 -0
  101. package/es/mode.js +280 -0
  102. package/es/module.d.ts +3 -0
  103. package/es/module.d.ts.map +1 -0
  104. package/es/module.js +4 -0
  105. package/es/monitor.d.ts +32 -0
  106. package/es/monitor.d.ts.map +1 -0
  107. package/es/monitor.js +129 -0
  108. package/es/python-lang.d.ts +3 -0
  109. package/es/python-lang.d.ts.map +1 -0
  110. package/es/python-lang.js +7 -0
  111. package/es/style/base.css +129 -0
  112. package/es/style/theme.css +12 -0
  113. package/es/style/variables.css +405 -0
  114. package/es/theme.d.ts +35 -0
  115. package/es/theme.d.ts.map +1 -0
  116. package/es/theme.js +223 -0
  117. package/es/tooltip.d.ts +10 -0
  118. package/es/tooltip.d.ts.map +1 -0
  119. package/es/tooltip.js +168 -0
  120. package/package.json +74 -0
  121. package/src/auto-complete/README.md +71 -0
  122. package/src/auto-complete/closebrackets.ts +423 -0
  123. package/src/auto-complete/completion.ts +345 -0
  124. package/src/auto-complete/config.ts +101 -0
  125. package/src/auto-complete/filter.ts +214 -0
  126. package/src/auto-complete/index.ts +112 -0
  127. package/src/auto-complete/snippet.ts +392 -0
  128. package/src/auto-complete/state.ts +465 -0
  129. package/src/auto-complete/theme.ts +127 -0
  130. package/src/auto-complete/tooltip.ts +386 -0
  131. package/src/auto-complete/view.ts +339 -0
  132. package/src/auto-complete/word.ts +118 -0
  133. package/src/completion.ts +61 -0
  134. package/src/config.ts +701 -0
  135. package/src/editor-contribution.ts +22 -0
  136. package/src/editor.ts +1287 -0
  137. package/src/factory.ts +31 -0
  138. package/src/hyperlink.ts +95 -0
  139. package/src/indent.ts +69 -0
  140. package/src/indentation-markers/config.ts +31 -0
  141. package/src/indentation-markers/index.ts +192 -0
  142. package/src/indentation-markers/map.ts +273 -0
  143. package/src/indentation-markers/utils.ts +84 -0
  144. package/src/index.spec.ts +12 -0
  145. package/src/index.ts +14 -0
  146. package/src/libro-icon.tsx +4 -0
  147. package/src/lsp/completion.ts +175 -0
  148. package/src/lsp/format.ts +144 -0
  149. package/src/lsp/index.ts +6 -0
  150. package/src/lsp/lint.ts +125 -0
  151. package/src/lsp/protocol.ts +8 -0
  152. package/src/lsp/tooltip.ts +76 -0
  153. package/src/lsp/util.ts +69 -0
  154. package/src/mimetype.ts +49 -0
  155. package/src/mode.ts +265 -0
  156. package/src/module.ts +8 -0
  157. package/src/monitor.ts +105 -0
  158. package/src/python-lang.ts +7 -0
  159. package/src/style/base.css +129 -0
  160. package/src/style/theme.css +12 -0
  161. package/src/style/variables.css +405 -0
  162. package/src/theme.ts +231 -0
  163. package/src/tooltip.ts +143 -0
package/es/config.d.ts ADDED
@@ -0,0 +1,189 @@
1
+ import type { Extension } from '@codemirror/state';
2
+ import { Compartment, StateEffect } from '@codemirror/state';
3
+ import type { KeyBinding } from '@codemirror/view';
4
+ import { EditorView } from '@codemirror/view';
5
+ import type { IEditorConfig } from '@difizen/libro-code-editor';
6
+ import type { IOptions } from './editor.js';
7
+ /**
8
+ * The configuration options for a codemirror editor.
9
+ */
10
+ export interface CodeMirrorConfig extends IEditorConfig {
11
+ /**
12
+ * The mode to use.
13
+ */
14
+ mode?: string;
15
+ /**
16
+ * content mimetype
17
+ */
18
+ mimetype?: string;
19
+ /**
20
+ * Whether to use the context-sensitive indentation that the mode provides
21
+ * (or just indent the same as the line before).
22
+ */
23
+ smartIndent?: boolean;
24
+ /**
25
+ * Configures whether the editor should re-indent the current line when a
26
+ * character is typed that might change its proper indentation
27
+ * (only works if the mode supports indentation).
28
+ */
29
+ electricChars?: boolean;
30
+ /**
31
+ * Configures the keymap to use. The default is "default", which is the
32
+ * only keymap defined in codemirror.js itself.
33
+ * Extra keymaps are found in the CodeMirror keymap directory.
34
+ */
35
+ keyMap?: string;
36
+ /**
37
+ * Can be used to specify extra keybindings for the editor, alongside the
38
+ * ones defined by keyMap. Should be either null, or a valid keymap value.
39
+ */
40
+ extraKeys?: KeyBinding[] | null;
41
+ /**
42
+ * Can be used to add extra gutters (beyond or instead of the line number
43
+ * gutter).
44
+ * Should be an array of CSS class names, each of which defines a width
45
+ * (and optionally a background),
46
+ * and which will be used to draw the background of the gutters.
47
+ * May include the CodeMirror-linenumbers class, in order to explicitly
48
+ * set the position of the line number gutter
49
+ * (it will default to be to the right of all other gutters).
50
+ * These class names are the keys passed to setGutterMarker.
51
+ */
52
+ gutters?: string[];
53
+ /**
54
+ * Determines whether the gutter scrolls along with the content
55
+ * horizontally (false)
56
+ * or whether it stays fixed during horizontal scrolling (true,
57
+ * the default).
58
+ */
59
+ fixedGutter?: boolean;
60
+ /**
61
+ * Whether the cursor should be drawn when a selection is active.
62
+ */
63
+ showCursorWhenSelecting?: boolean;
64
+ /**
65
+ * When fixedGutter is on, and there is a horizontal scrollbar, by default
66
+ * the gutter will be visible to the left of this scrollbar. If this
67
+ * option is set to true, it will be covered by an element with class
68
+ * CodeMirror-gutter-filler.
69
+ */
70
+ coverGutterNextToScrollbar?: boolean;
71
+ /**
72
+ * Controls whether drag-and-drop is enabled.
73
+ */
74
+ dragDrop?: boolean;
75
+ /**
76
+ * Explicitly set the line separator for the editor.
77
+ * By default (value null), the document will be split on CRLFs as well as
78
+ * lone CRs and LFs, and a single LF will be used as line separator in all
79
+ * output (such as getValue). When a specific string is given, lines will
80
+ * only be split on that string, and output will, by default, use that
81
+ * same separator.
82
+ */
83
+ lineSeparator?: string | null;
84
+ /**
85
+ * Chooses a scrollbar implementation. The default is "native", showing
86
+ * native scrollbars. The core library also provides the "null" style,
87
+ * which completely hides the scrollbars. Addons can implement additional
88
+ * scrollbar models.
89
+ */
90
+ scrollbarStyle?: string;
91
+ /**
92
+ * When enabled, which is the default, doing copy or cut when there is no
93
+ * selection will copy or cut the whole lines that have cursors on them.
94
+ */
95
+ lineWiseCopyCut?: boolean;
96
+ /**
97
+ * Whether to scroll past the end of the buffer.
98
+ */
99
+ scrollPastEnd?: boolean;
100
+ /**
101
+ * Whether to give the wrapper of the line that contains the cursor the class
102
+ * cm-activeLine.
103
+ */
104
+ styleActiveLine?: boolean;
105
+ /**
106
+ * Whether to causes the selected text to be marked with the CSS class
107
+ * CodeMirror-selectedtext. Useful to change the colour of the selection
108
+ * (in addition to the background).
109
+ */
110
+ styleSelectedText?: boolean;
111
+ /**
112
+ * Defines the mouse cursor appearance when hovering over the selection.
113
+ * It can be set to a string, like "pointer", or to true,
114
+ * in which case the "default" (arrow) cursor will be used.
115
+ */
116
+ selectionPointer?: boolean | string;
117
+ highlightActiveLineGutter?: boolean;
118
+ highlightSpecialChars?: boolean;
119
+ history?: boolean;
120
+ drawSelection?: boolean;
121
+ dropCursor?: boolean;
122
+ allowMultipleSelections?: boolean;
123
+ autocompletion?: boolean;
124
+ rectangularSelection?: boolean;
125
+ crosshairCursor?: boolean;
126
+ highlightSelectionMatches?: boolean;
127
+ foldGutter?: boolean;
128
+ syntaxHighlighting?: boolean;
129
+ /**
130
+ * 是否从kernel获取completion
131
+ */
132
+ jupyterKernelCompletion?: boolean;
133
+ /**
134
+ * 是否从kernel获取tooltip
135
+ */
136
+ jupyterKernelTooltip?: boolean;
137
+ indentationMarkers?: boolean;
138
+ hyperLink?: boolean;
139
+ /**
140
+ * 是否开启tab触发completion和tooltip
141
+ */
142
+ tabEditorFunction?: boolean;
143
+ lspCompletion?: boolean;
144
+ lspTooltip?: boolean;
145
+ lspLint?: boolean;
146
+ placeholder?: HTMLElement | string;
147
+ }
148
+ /**
149
+ * Builds an extension in a compartment that can
150
+ * be reconfigured.
151
+ */
152
+ interface IConfigurableBuilder {
153
+ of: <T>(value: T) => Extension;
154
+ reconfigure: <T>(value: T) => StateEffect<unknown>;
155
+ }
156
+ /**
157
+ * Editor configuration: provides APIs to get and reconfigure CodeMirror 6
158
+ * extensions from option names. Also allows to register new themes and
159
+ * inject ne extensions in already configured editor instances.
160
+ */
161
+ export declare class EditorConfiguration {
162
+ constructor(options: IOptions);
163
+ /**
164
+ * Reconfigures the extension mapped with key with the provided value.
165
+ */
166
+ reconfigureExtension<T>(view: EditorView, key: string, value: T): void;
167
+ /**
168
+ * Reconfigures all the extensions mapped with the options from the
169
+ * provided partial configuration.
170
+ */
171
+ reconfigureExtensions(view: EditorView, config: Partial<CodeMirrorConfig>): void;
172
+ /**
173
+ * Appends extensions to the top-level configuration of the
174
+ * editor.
175
+ */
176
+ injectExtension(view: EditorView, ext: Extension): void;
177
+ /**
178
+ * Returns the list of initial extensions of an editor
179
+ * based on the provided configuration.
180
+ */
181
+ getInitialExtensions(config: CodeMirrorConfig): Extension[];
182
+ protected updateThemeOverload(config: Partial<CodeMirrorConfig> | Record<string, any>): Extension;
183
+ protected get(key: string): IConfigurableBuilder | undefined;
184
+ protected _configurableBuilderMap: Map<string, IConfigurableBuilder>;
185
+ protected _themeOverloaderSpec: Record<string, Record<string, string>>;
186
+ protected _themeOverloader: Compartment;
187
+ }
188
+ export {};
189
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"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"}
package/es/config.js ADDED
@@ -0,0 +1,482 @@
1
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
9
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
14
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
16
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
17
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
18
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
19
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
21
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
23
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
24
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
25
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
26
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
27
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
28
+ import { defaultKeymap, history, historyKeymap } from '@codemirror/commands';
29
+ import { pythonLanguage } from '@codemirror/lang-python';
30
+ import { bracketMatching, defaultHighlightStyle, foldGutter, foldKeymap, indentOnInput, indentUnit, syntaxHighlighting } from '@codemirror/language';
31
+ import { lintKeymap } from '@codemirror/lint';
32
+ import { highlightSelectionMatches } from '@codemirror/search';
33
+ import { Compartment, EditorState, StateEffect } from '@codemirror/state';
34
+ import { crosshairCursor, drawSelection, dropCursor, EditorView, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, keymap, lineNumbers, placeholder, rectangularSelection } from '@codemirror/view';
35
+ import { autocompletion, closeBrackets, closeBracketsKeymap, completionKeymap } from "./auto-complete/index.js";
36
+ import { kernelCompletions } from "./completion.js";
37
+ import { hyperLink } from "./hyperlink.js";
38
+ import { indentationMarkers } from "./indentation-markers/index.js";
39
+ import { FoldIcon, UnFoldIcon } from "./libro-icon.js";
40
+ import { lspPythonCompletion } from "./lsp/completion.js";
41
+ import { formatKeymap } from "./lsp/format.js";
42
+ import { lspLint, lspTooltip } from "./lsp/index.js";
43
+ import { ensure } from "./mode.js";
44
+ import { getTheme, defaultTheme } from "./theme.js";
45
+ import { tabTooltip, tooltipKeymap } from "./tooltip.js";
46
+
47
+ /**
48
+ * The configuration options for a codemirror editor.
49
+ */
50
+
51
+ /**
52
+ * Extension builder (we use the same trick as in CM Extension
53
+ * to emulate empty interface)
54
+ */
55
+ /**
56
+ * Builder for extensions from value of type T
57
+ */
58
+ var ExtensionBuilder = /*#__PURE__*/function () {
59
+ function ExtensionBuilder() {
60
+ _classCallCheck(this, ExtensionBuilder);
61
+ }
62
+ _createClass(ExtensionBuilder, [{
63
+ key: "extensionBuilder",
64
+ get: function get() {
65
+ return this;
66
+ }
67
+ }]);
68
+ return ExtensionBuilder;
69
+ }();
70
+ /**
71
+ * Extension builder that simply forwards a value as an extension.
72
+ */
73
+ var ExtensionForwarder = /*#__PURE__*/function (_ExtensionBuilder) {
74
+ _inherits(ExtensionForwarder, _ExtensionBuilder);
75
+ var _super = _createSuper(ExtensionForwarder);
76
+ function ExtensionForwarder() {
77
+ _classCallCheck(this, ExtensionForwarder);
78
+ return _super.apply(this, arguments);
79
+ }
80
+ _createClass(ExtensionForwarder, [{
81
+ key: "of",
82
+ value: function of(value) {
83
+ return value;
84
+ }
85
+ }]);
86
+ return ExtensionForwarder;
87
+ }(ExtensionBuilder);
88
+ /**
89
+ * Extension builder that builds an extension from a facet.
90
+ */
91
+ var FacetWrapper = /*#__PURE__*/function (_ExtensionBuilder2) {
92
+ _inherits(FacetWrapper, _ExtensionBuilder2);
93
+ var _super2 = _createSuper(FacetWrapper);
94
+ function FacetWrapper(facet) {
95
+ var _this;
96
+ _classCallCheck(this, FacetWrapper);
97
+ _this = _super2.call(this);
98
+ _this._facet = facet;
99
+ return _this;
100
+ }
101
+ _createClass(FacetWrapper, [{
102
+ key: "of",
103
+ value: function of(value) {
104
+ return this._facet.of(value);
105
+ }
106
+ }]);
107
+ return FacetWrapper;
108
+ }(ExtensionBuilder);
109
+ /**
110
+ * Extension builder that provides an extension depending
111
+ * on a boolean value.
112
+ */
113
+ var ConditionalExtension = /*#__PURE__*/function (_ExtensionBuilder3) {
114
+ _inherits(ConditionalExtension, _ExtensionBuilder3);
115
+ var _super3 = _createSuper(ConditionalExtension);
116
+ function ConditionalExtension(truthy) {
117
+ var _this2;
118
+ var falsy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
119
+ _classCallCheck(this, ConditionalExtension);
120
+ _this2 = _super3.call(this);
121
+ _this2._truthy = truthy;
122
+ _this2._falsy = falsy;
123
+ return _this2;
124
+ }
125
+ _createClass(ConditionalExtension, [{
126
+ key: "of",
127
+ value: function of(value) {
128
+ return value ? this._truthy : this._falsy;
129
+ }
130
+ }]);
131
+ return ConditionalExtension;
132
+ }(ExtensionBuilder);
133
+ /**
134
+ * Extension builds that provides an extension depending on
135
+ * conditional function operating on a value.
136
+ */
137
+ var GenConditionalExtension = /*#__PURE__*/function (_ExtensionBuilder4) {
138
+ _inherits(GenConditionalExtension, _ExtensionBuilder4);
139
+ var _super4 = _createSuper(GenConditionalExtension);
140
+ function GenConditionalExtension(fn, truthy) {
141
+ var _this3;
142
+ var falsy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
143
+ _classCallCheck(this, GenConditionalExtension);
144
+ _this3 = _super4.call(this);
145
+ _this3._fn = fn;
146
+ _this3._builder = new ConditionalExtension(truthy, falsy);
147
+ return _this3;
148
+ }
149
+ _createClass(GenConditionalExtension, [{
150
+ key: "of",
151
+ value: function of(value) {
152
+ return this._builder.of(this._fn(value));
153
+ }
154
+ }]);
155
+ return GenConditionalExtension;
156
+ }(ExtensionBuilder);
157
+ /**
158
+ * Builds an extension in a compartment that can
159
+ * be reconfigured.
160
+ */
161
+ /**
162
+ * IConfigurableBuilder implementation *
163
+ */
164
+ var ConfigurableBuilder = /*#__PURE__*/function () {
165
+ function ConfigurableBuilder(builder) {
166
+ _classCallCheck(this, ConfigurableBuilder);
167
+ this._compartment = new Compartment();
168
+ this._builder = builder;
169
+ }
170
+ _createClass(ConfigurableBuilder, [{
171
+ key: "of",
172
+ value: function of(value) {
173
+ return this._compartment.of(this._builder.of(value));
174
+ }
175
+ }, {
176
+ key: "reconfigure",
177
+ value: function reconfigure(value) {
178
+ return this._compartment.reconfigure(this._builder.of(value));
179
+ }
180
+ }]);
181
+ return ConfigurableBuilder;
182
+ }();
183
+ /*
184
+ * Specific builder for themes. Provide a default theme and
185
+ * allows to register new themes.
186
+ */
187
+ var ThemeBuilder = /*#__PURE__*/function () {
188
+ function ThemeBuilder() {
189
+ _classCallCheck(this, ThemeBuilder);
190
+ this._compartment = new Compartment();
191
+ }
192
+ _createClass(ThemeBuilder, [{
193
+ key: "of",
194
+ value: function of(value) {
195
+ var v = value;
196
+ return this._compartment.of(getTheme(v));
197
+ }
198
+ }, {
199
+ key: "reconfigure",
200
+ value: function reconfigure(value) {
201
+ var v = value;
202
+ return this._compartment.reconfigure(getTheme(v));
203
+ }
204
+ }]);
205
+ return ThemeBuilder;
206
+ }();
207
+ /*
208
+ * Specific builder for themes. Provide a default theme and
209
+ * allows to register new themes.
210
+ */
211
+ var PlaceHolderBuilder = /*#__PURE__*/function () {
212
+ function PlaceHolderBuilder() {
213
+ _classCallCheck(this, PlaceHolderBuilder);
214
+ this._compartment = new Compartment();
215
+ }
216
+ _createClass(PlaceHolderBuilder, [{
217
+ key: "of",
218
+ value: function of(value) {
219
+ var v = value;
220
+ return this._compartment.of(placeholder(v));
221
+ }
222
+ }, {
223
+ key: "reconfigure",
224
+ value: function reconfigure(value) {
225
+ var v = value;
226
+ return this._compartment.reconfigure(placeholder(v));
227
+ }
228
+ }]);
229
+ return PlaceHolderBuilder;
230
+ }();
231
+ /**
232
+ * Creates a ConfigurableBuilder based on an ExtensionForwarder.
233
+ */
234
+ function createForwarderBuilder() {
235
+ return new ConfigurableBuilder(new ExtensionForwarder());
236
+ }
237
+
238
+ /**
239
+ * Creates a ConfigurableBuilder based on a Facet.
240
+ */
241
+ function createConfigurableBuilder(facet) {
242
+ return new ConfigurableBuilder(new FacetWrapper(facet));
243
+ }
244
+
245
+ /**
246
+ * Creates a ConditionalBuilder from two extensions.
247
+ */
248
+ function createConditionalBuilder(truthy) {
249
+ var falsy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
250
+ return new ConfigurableBuilder(new ConditionalExtension(truthy, falsy));
251
+ }
252
+
253
+ /**
254
+ * Creates a ConditionalBuilder based on two extensions and a
255
+ * conditional function.
256
+ */
257
+ function createGenConditionalBuilder(fn, truthy) {
258
+ var falsy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
259
+ return new ConfigurableBuilder(new GenConditionalExtension(fn, truthy, falsy));
260
+ }
261
+
262
+ /**
263
+ * Creates a theme builder.
264
+ */
265
+ function createThemeBuilder() {
266
+ return new ThemeBuilder();
267
+ }
268
+
269
+ /**
270
+ * Creates a theme builder.
271
+ */
272
+ function createPlaceHolderBuilder() {
273
+ return new PlaceHolderBuilder();
274
+ }
275
+
276
+ /**
277
+ * Editor configuration: provides APIs to get and reconfigure CodeMirror 6
278
+ * extensions from option names. Also allows to register new themes and
279
+ * inject ne extensions in already configured editor instances.
280
+ */
281
+ export var EditorConfiguration = /*#__PURE__*/function () {
282
+ function EditorConfiguration(options) {
283
+ var _options$config;
284
+ _classCallCheck(this, EditorConfiguration);
285
+ // Order does not matter
286
+ this._configurableBuilderMap = new Map([['tabSize', createConfigurableBuilder(EditorState.tabSize)], ['readOnly', createConfigurableBuilder(EditorState.readOnly)], ['editable', createConfigurableBuilder(EditorView.editable)], ['keymap', createConfigurableBuilder(keymap)], ['indentUnit', createConfigurableBuilder(indentUnit)], ['smartIndent', createConditionalBuilder(indentOnInput())], ['autoClosingBrackets', createConditionalBuilder(closeBrackets())], ['matchBrackets', createConditionalBuilder(bracketMatching())], ['styleActiveLine', createConditionalBuilder(highlightActiveLine())], ['lineNumbers', createConditionalBuilder(lineNumbers())], ['lineWrap', createGenConditionalBuilder(function (a) {
287
+ return a !== 'off';
288
+ }, EditorView.lineWrapping)], ['language', createForwarderBuilder()], ['theme', createThemeBuilder()],
289
+ // addtional
290
+ ['highlightActiveLineGutter', createConditionalBuilder(highlightActiveLineGutter())], ['highlightSpecialChars', createConditionalBuilder(highlightSpecialChars())], ['history', createConditionalBuilder(history())], ['drawSelection', createConditionalBuilder(drawSelection())], ['dropCursor', createConditionalBuilder(dropCursor())], ['allowMultipleSelections', createConfigurableBuilder(EditorState.allowMultipleSelections)], ['autocompletion', createConditionalBuilder(autocompletion({
291
+ activateOnTyping: ((_options$config = options.config) === null || _options$config === void 0 ? void 0 : _options$config.lspCompletion) === true
292
+ }))], ['rectangularSelection', createConditionalBuilder(rectangularSelection())], ['crosshairCursor', createConditionalBuilder(crosshairCursor())], ['highlightSelectionMatches', createConditionalBuilder(highlightSelectionMatches())], ['foldGutter', createConditionalBuilder(foldGutter({
293
+ markerDOM: function markerDOM(open) {
294
+ if (open) {
295
+ var iconElement = document.createElement('div');
296
+ iconElement.innerHTML = FoldIcon;
297
+ iconElement.style.display = 'flex';
298
+ iconElement.style.cursor = 'pointer';
299
+ return iconElement;
300
+ } else {
301
+ var _iconElement = document.createElement('div');
302
+ _iconElement.innerHTML = UnFoldIcon;
303
+ _iconElement.style.cursor = 'pointer';
304
+ return _iconElement;
305
+ }
306
+ }
307
+ }))], ['syntaxHighlighting', createConditionalBuilder(syntaxHighlighting(defaultHighlightStyle, {
308
+ fallback: true
309
+ }))], ['jupyterKernelCompletion', createConditionalBuilder(pythonLanguage.data.of({
310
+ autocomplete: kernelCompletions(options.completionProvider)
311
+ }))], ['jupyterKernelTooltip', createConditionalBuilder(tabTooltip(options.tooltipProvider))], ['indentationMarkers', createConditionalBuilder(indentationMarkers())], ['hyperLink', createConditionalBuilder(hyperLink)], ['placeholder', createPlaceHolderBuilder()], ['lspTooltip', createConditionalBuilder(lspTooltip({
312
+ lspProvider: options.lspProvider
313
+ }))], ['lspLint', createConditionalBuilder(lspLint({
314
+ lspProvider: options.lspProvider
315
+ }))], ['lspCompletion', createConditionalBuilder(lspPythonCompletion({
316
+ lspProvider: options.lspProvider
317
+ }))]]);
318
+ this._themeOverloaderSpec = {
319
+ '&': {},
320
+ '.cm-line': {}
321
+ };
322
+ this._themeOverloader = new Compartment();
323
+ }
324
+
325
+ /**
326
+ * Reconfigures the extension mapped with key with the provided value.
327
+ */
328
+ _createClass(EditorConfiguration, [{
329
+ key: "reconfigureExtension",
330
+ value: function reconfigureExtension(view, key, value) {
331
+ var builder = this.get(key);
332
+ if (builder) {
333
+ view.dispatch({
334
+ effects: builder.reconfigure(value)
335
+ });
336
+ } else {
337
+ var config = {};
338
+ config[key] = value;
339
+ var themeOverload = this.updateThemeOverload(config);
340
+ view.dispatch({
341
+ effects: this._themeOverloader.reconfigure(themeOverload)
342
+ });
343
+ }
344
+ }
345
+
346
+ /**
347
+ * Reconfigures all the extensions mapped with the options from the
348
+ * provided partial configuration.
349
+ */
350
+ }, {
351
+ key: "reconfigureExtensions",
352
+ value: function reconfigureExtensions(view, config) {
353
+ var eff = [];
354
+ for (var _i = 0, _Object$entries = Object.entries(config); _i < _Object$entries.length; _i++) {
355
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
356
+ key = _Object$entries$_i[0],
357
+ _value = _Object$entries$_i[1];
358
+ var builder = this.get(key);
359
+ if (builder) {
360
+ eff.push(builder.reconfigure(_value));
361
+ }
362
+ }
363
+ var themeOverload = this.updateThemeOverload(config);
364
+ eff.push(this._themeOverloader.reconfigure(themeOverload));
365
+ view.dispatch({
366
+ effects: eff
367
+ });
368
+ }
369
+
370
+ /**
371
+ * Appends extensions to the top-level configuration of the
372
+ * editor.
373
+ */
374
+ }, {
375
+ key: "injectExtension",
376
+ value: function injectExtension(view, ext) {
377
+ view.dispatch({
378
+ effects: StateEffect.appendConfig.of(ext)
379
+ });
380
+ }
381
+
382
+ /**
383
+ * Returns the list of initial extensions of an editor
384
+ * based on the provided configuration.
385
+ */
386
+ }, {
387
+ key: "getInitialExtensions",
388
+ value: function getInitialExtensions(config) {
389
+ var _config$mimetype,
390
+ _this4 = this;
391
+ var keys = Object.keys(config).filter(function (v) {
392
+ return v !== 'insertSpaces' && v !== 'extraKeys';
393
+ });
394
+ var extensions = [];
395
+ var _iterator = _createForOfIteratorHelper(keys),
396
+ _step;
397
+ try {
398
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
399
+ var k = _step.value;
400
+ var _builder = this.get(k);
401
+ if (_builder) {
402
+ var _value2 = config[k];
403
+ extensions.push(_builder.of(_value2));
404
+ }
405
+ }
406
+ } catch (err) {
407
+ _iterator.e(err);
408
+ } finally {
409
+ _iterator.f();
410
+ }
411
+ var libroDefaultKeymap = defaultKeymap.filter(function (item) {
412
+ return item.key !== 'Mod-Enter';
413
+ });
414
+ if (!config.theme) {
415
+ extensions.push(defaultTheme());
416
+ }
417
+ var builder = this.get('keymap');
418
+ var initialKeymap = [].concat(_toConsumableArray(libroDefaultKeymap), _toConsumableArray(closeBracketsKeymap), _toConsumableArray(historyKeymap), _toConsumableArray(foldKeymap), _toConsumableArray(completionKeymap), _toConsumableArray(lintKeymap), _toConsumableArray(tooltipKeymap), _toConsumableArray(formatKeymap));
419
+ var keymapExt = builder.of(config.extraKeys ? [initialKeymap].concat(_toConsumableArray(config.extraKeys)) : _toConsumableArray(initialKeymap));
420
+ var indentBuilder = this.get('indentUnit');
421
+ var insertExt = indentBuilder.of(config.insertSpaces ? ' '.repeat(config.tabSize) : '\t');
422
+ var themeOverload = this.updateThemeOverload(config);
423
+ extensions.push(this._themeOverloader.of(themeOverload), insertExt, keymapExt);
424
+ ensure((_config$mimetype = config === null || config === void 0 ? void 0 : config.mimetype) !== null && _config$mimetype !== void 0 ? _config$mimetype : 'text/x-python').then(function (spec) {
425
+ if (spec) {
426
+ var _this4$get;
427
+ extensions.push((_this4$get = _this4.get('language')) === null || _this4$get === void 0 ? void 0 : _this4$get.of(spec.support));
428
+ }
429
+ return undefined;
430
+ }).catch(function (error) {
431
+ console.error('Could not load language parser:');
432
+ console.error(error);
433
+ });
434
+ return extensions;
435
+ }
436
+ }, {
437
+ key: "updateThemeOverload",
438
+ value: function updateThemeOverload(config) {
439
+ var fontFamily = config.fontFamily,
440
+ fontSize = config.fontSize,
441
+ lineHeight = config.lineHeight,
442
+ lineWrap = config.lineWrap,
443
+ wordWrapColumn = config.wordWrapColumn;
444
+ var needUpdate = false;
445
+ var parentStyle = {};
446
+ if (fontSize) {
447
+ parentStyle['fontSize'] = fontSize + 'px';
448
+ needUpdate = true;
449
+ }
450
+ if (fontFamily) {
451
+ parentStyle['fontFamily'] = fontFamily;
452
+ needUpdate = true;
453
+ }
454
+ if (lineHeight) {
455
+ parentStyle['lineHeight'] = lineHeight.toString();
456
+ needUpdate = true;
457
+ }
458
+ var lineStyle = {};
459
+ if (lineWrap === 'wordWrapColumn') {
460
+ lineStyle['width'] = wordWrapColumn + 'ch';
461
+ needUpdate = true;
462
+ } else if (lineWrap === 'bounded') {
463
+ lineStyle['maxWidth'] = wordWrapColumn + 'ch';
464
+ needUpdate = true;
465
+ }
466
+ if (needUpdate) {
467
+ var newThemeSpec = {
468
+ '&': parentStyle,
469
+ '.cm-line': lineStyle
470
+ };
471
+ this._themeOverloaderSpec = _objectSpread(_objectSpread({}, this._themeOverloaderSpec), newThemeSpec);
472
+ }
473
+ return EditorView.theme(this._themeOverloaderSpec);
474
+ }
475
+ }, {
476
+ key: "get",
477
+ value: function get(key) {
478
+ return this._configurableBuilderMap.get(key);
479
+ }
480
+ }]);
481
+ return EditorConfiguration;
482
+ }();