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