@uiw/react-codemirror 4.15.0 → 4.16.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/README.md +3 -1
- package/dist/mdeditor.js +132 -94
- package/dist/mdeditor.min.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ npm install @uiw/react-codemirror --save
|
|
|
41
41
|
**All Packages**
|
|
42
42
|
|
|
43
43
|
| Name | NPM Version | Website |
|
|
44
|
-
|
|
|
44
|
+
| :------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
45
45
|
| `@uiw/react-codemirror` | [](https://www.npmjs.com/package/@uiw/react-codemirror) [](https://www.npmjs.com/package/@uiw/react-codemirror) | [`#preview`](https://uiwjs.github.io/react-codemirror/) |
|
|
46
46
|
| `@uiw/codemirror-extensions-basic-setup` | [](https://www.npmjs.com/package/@uiw/codemirror-extensions-basic-setup) [](https://www.npmjs.com/package/@uiw/codemirror-extensions-basic-setup) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/extensions/basic-setup) |
|
|
47
47
|
| `@uiw/codemirror-extensions-color` | [](https://www.npmjs.com/package/@uiw/codemirror-extensions-color) [](https://www.npmjs.com/package/@uiw/codemirror-extensions-color) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/extensions/color) |
|
|
@@ -50,6 +50,7 @@ npm install @uiw/react-codemirror --save
|
|
|
50
50
|
| `@uiw/codemirror-extensions-langs` | [](https://www.npmjs.com/package/@uiw/codemirror-extensions-langs) [](https://www.npmjs.com/package/@uiw/codemirror-extensions-langs) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/extensions/languages) |
|
|
51
51
|
| `@uiw/codemirror-extensions-line-numbers-relative` | [](https://www.npmjs.com/package/@uiw/codemirror-extensions-line-numbers-relative) [](https://www.npmjs.com/package/@uiw/codemirror-extensions-line-numbers-relative) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/extensions/line-numbers-relative) |
|
|
52
52
|
| `@uiw/codemirror-extensions-mentions` | [](https://www.npmjs.com/package/@uiw/codemirror-extensions-mentions) [](https://www.npmjs.com/package/@uiw/codemirror-extensions-mentions) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/extensions/mentions) |
|
|
53
|
+
| `@uiw/codemirror-extensions-zebra-stripes` | [](https://www.npmjs.com/package/@uiw/codemirror-extensions-zebra-stripes) [](https://www.npmjs.com/package/@uiw/codemirror-extensions-zebra-stripes) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/extensions/zebra-stripes) |
|
|
53
54
|
| `@uiw/codemirror-themes` | [](https://www.npmjs.com/package/@uiw/codemirror-themes) [](https://www.npmjs.com/package/@uiw/codemirror-themes) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/doc) |
|
|
54
55
|
| `@uiw/codemirror-themes-all` | [](https://www.npmjs.com/package/@uiw/codemirror-themes-all) [](https://www.npmjs.com/package/@uiw/codemirror-themes-all) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/all) |
|
|
55
56
|
| `@uiw/codemirror-theme-abcdef` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-abcdef) [](https://www.npmjs.com/package/@uiw/codemirror-theme-abcdef) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/abcdef) |
|
|
@@ -63,6 +64,7 @@ npm install @uiw/react-codemirror --save
|
|
|
63
64
|
| `@uiw/codemirror-theme-eclipse` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-eclipse) [](https://www.npmjs.com/package/@uiw/codemirror-theme-eclipse) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/eclipse) |
|
|
64
65
|
| `@uiw/codemirror-theme-github` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-github) [](https://www.npmjs.com/package/@uiw/codemirror-theme-github) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/github) |
|
|
65
66
|
| `@uiw/codemirror-theme-gruvbox-dark` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-gruvbox-dark) [](https://www.npmjs.com/package/@uiw/codemirror-theme-gruvbox-dark) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/gruvbox/dark) |
|
|
67
|
+
| `@uiw/codemirror-theme-nord` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-nord) [](https://www.npmjs.com/package/@uiw/codemirror-theme-nord) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/nord) |
|
|
66
68
|
| `@uiw/codemirror-theme-okaidia` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-okaidia) [](https://www.npmjs.com/package/@uiw/codemirror-theme-okaidia) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/okaidia) |
|
|
67
69
|
| `@uiw/codemirror-theme-sublime` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-sublime) [](https://www.npmjs.com/package/@uiw/codemirror-theme-sublime) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/sublime) |
|
|
68
70
|
| `@uiw/codemirror-theme-vscode` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-vscode) [](https://www.npmjs.com/package/@uiw/codemirror-theme-vscode) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/vscode) |
|
package/dist/mdeditor.js
CHANGED
|
@@ -142,8 +142,39 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
142
142
|
"useCodeMirror": () => (/* reexport */ useCodeMirror)
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
146
|
+
function _typeof(obj) {
|
|
147
|
+
"@babel/helpers - typeof";
|
|
148
|
+
|
|
149
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
150
|
+
return typeof obj;
|
|
151
|
+
} : function (obj) {
|
|
152
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
153
|
+
}, _typeof(obj);
|
|
154
|
+
}
|
|
155
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
156
|
+
|
|
157
|
+
function _toPrimitive(input, hint) {
|
|
158
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
159
|
+
var prim = input[Symbol.toPrimitive];
|
|
160
|
+
if (prim !== undefined) {
|
|
161
|
+
var res = prim.call(input, hint || "default");
|
|
162
|
+
if (_typeof(res) !== "object") return res;
|
|
163
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
164
|
+
}
|
|
165
|
+
return (hint === "string" ? String : Number)(input);
|
|
166
|
+
}
|
|
167
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
function _toPropertyKey(arg) {
|
|
171
|
+
var key = _toPrimitive(arg, "string");
|
|
172
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
173
|
+
}
|
|
145
174
|
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
175
|
+
|
|
146
176
|
function _defineProperty(obj, key, value) {
|
|
177
|
+
key = _toPropertyKey(key);
|
|
147
178
|
if (key in obj) {
|
|
148
179
|
Object.defineProperty(obj, key, {
|
|
149
180
|
value: value,
|
|
@@ -217,28 +248,33 @@ function _arrayWithHoles(arr) {
|
|
|
217
248
|
}
|
|
218
249
|
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
|
|
219
250
|
function _iterableToArrayLimit(arr, i) {
|
|
220
|
-
var _i =
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (i && _arr.length === i) break;
|
|
230
|
-
}
|
|
231
|
-
} catch (err) {
|
|
232
|
-
_d = true;
|
|
233
|
-
_e = err;
|
|
234
|
-
} finally {
|
|
251
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
252
|
+
if (null != _i) {
|
|
253
|
+
var _s,
|
|
254
|
+
_e,
|
|
255
|
+
_x,
|
|
256
|
+
_r,
|
|
257
|
+
_arr = [],
|
|
258
|
+
_n = !0,
|
|
259
|
+
_d = !1;
|
|
235
260
|
try {
|
|
236
|
-
if (
|
|
261
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
262
|
+
if (Object(_i) !== _i) return;
|
|
263
|
+
_n = !1;
|
|
264
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) {
|
|
265
|
+
;
|
|
266
|
+
}
|
|
267
|
+
} catch (err) {
|
|
268
|
+
_d = !0, _e = err;
|
|
237
269
|
} finally {
|
|
238
|
-
|
|
270
|
+
try {
|
|
271
|
+
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
|
|
272
|
+
} finally {
|
|
273
|
+
if (_d) throw _e;
|
|
274
|
+
}
|
|
239
275
|
}
|
|
276
|
+
return _arr;
|
|
240
277
|
}
|
|
241
|
-
return _arr;
|
|
242
278
|
}
|
|
243
279
|
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
|
|
244
280
|
function _arrayLikeToArray(arr, len) {
|
|
@@ -389,8 +425,8 @@ class dist_NodeType {
|
|
|
389
425
|
/// Define a node type.
|
|
390
426
|
static define(spec) {
|
|
391
427
|
let props = spec.props && spec.props.length ? Object.create(null) : noProps;
|
|
392
|
-
let flags = (spec.top ? 1 /* Top */ : 0) | (spec.skipped ? 2 /* Skipped */ : 0) |
|
|
393
|
-
(spec.error ? 4 /* Error */ : 0) | (spec.name == null ? 8 /* Anonymous */ : 0);
|
|
428
|
+
let flags = (spec.top ? 1 /* NodeFlag.Top */ : 0) | (spec.skipped ? 2 /* NodeFlag.Skipped */ : 0) |
|
|
429
|
+
(spec.error ? 4 /* NodeFlag.Error */ : 0) | (spec.name == null ? 8 /* NodeFlag.Anonymous */ : 0);
|
|
394
430
|
let type = new dist_NodeType(spec.name || "", props, spec.id, flags);
|
|
395
431
|
if (spec.props)
|
|
396
432
|
for (let src of spec.props) {
|
|
@@ -408,14 +444,14 @@ class dist_NodeType {
|
|
|
408
444
|
/// the prop isn't present on this node.
|
|
409
445
|
prop(prop) { return this.props[prop.id]; }
|
|
410
446
|
/// True when this is the top node of a grammar.
|
|
411
|
-
get isTop() { return (this.flags & 1 /* Top */) > 0; }
|
|
447
|
+
get isTop() { return (this.flags & 1 /* NodeFlag.Top */) > 0; }
|
|
412
448
|
/// True when this node is produced by a skip rule.
|
|
413
|
-
get isSkipped() { return (this.flags & 2 /* Skipped */) > 0; }
|
|
449
|
+
get isSkipped() { return (this.flags & 2 /* NodeFlag.Skipped */) > 0; }
|
|
414
450
|
/// Indicates whether this is an error node.
|
|
415
|
-
get isError() { return (this.flags & 4 /* Error */) > 0; }
|
|
451
|
+
get isError() { return (this.flags & 4 /* NodeFlag.Error */) > 0; }
|
|
416
452
|
/// When true, this node type doesn't correspond to a user-declared
|
|
417
453
|
/// named node, for example because it is used to cache repetition.
|
|
418
|
-
get isAnonymous() { return (this.flags & 8 /* Anonymous */) > 0; }
|
|
454
|
+
get isAnonymous() { return (this.flags & 8 /* NodeFlag.Anonymous */) > 0; }
|
|
419
455
|
/// Returns true when this node's name or one of its
|
|
420
456
|
/// [groups](#common.NodeProp^group) matches the given string.
|
|
421
457
|
is(name) {
|
|
@@ -448,7 +484,7 @@ class dist_NodeType {
|
|
|
448
484
|
}
|
|
449
485
|
}
|
|
450
486
|
/// An empty dummy node type to use when no actual type is available.
|
|
451
|
-
dist_NodeType.none = new dist_NodeType("", Object.create(null), 0, 8 /* Anonymous */);
|
|
487
|
+
dist_NodeType.none = new dist_NodeType("", Object.create(null), 0, 8 /* NodeFlag.Anonymous */);
|
|
452
488
|
/// A node set holds a collection of node types. It is used to
|
|
453
489
|
/// compactly represent trees by storing their type ids, rather than a
|
|
454
490
|
/// full pointer to the type object, in a numeric array. Each parser
|
|
@@ -657,7 +693,7 @@ class dist_Tree {
|
|
|
657
693
|
/// which may have children grouped into subtrees with type
|
|
658
694
|
/// [`NodeType.none`](#common.NodeType^none).
|
|
659
695
|
balance(config = {}) {
|
|
660
|
-
return this.children.length <= 8 /* BranchFactor */ ? this :
|
|
696
|
+
return this.children.length <= 8 /* Balance.BranchFactor */ ? this :
|
|
661
697
|
balanceRange(dist_NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new dist_Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new dist_Tree(dist_NodeType.none, children, positions, length)));
|
|
662
698
|
}
|
|
663
699
|
/// Build a tree from a postfix-ordered buffer of node information,
|
|
@@ -736,26 +772,27 @@ class TreeBuffer {
|
|
|
736
772
|
return pick;
|
|
737
773
|
}
|
|
738
774
|
/// @internal
|
|
739
|
-
slice(startI, endI, from
|
|
775
|
+
slice(startI, endI, from) {
|
|
740
776
|
let b = this.buffer;
|
|
741
|
-
let copy = new Uint16Array(endI - startI);
|
|
777
|
+
let copy = new Uint16Array(endI - startI), len = 0;
|
|
742
778
|
for (let i = startI, j = 0; i < endI;) {
|
|
743
779
|
copy[j++] = b[i++];
|
|
744
780
|
copy[j++] = b[i++] - from;
|
|
745
|
-
copy[j++] = b[i++] - from;
|
|
781
|
+
let to = copy[j++] = b[i++] - from;
|
|
746
782
|
copy[j++] = b[i++] - startI;
|
|
783
|
+
len = Math.max(len, to);
|
|
747
784
|
}
|
|
748
|
-
return new TreeBuffer(copy,
|
|
785
|
+
return new TreeBuffer(copy, len, this.set);
|
|
749
786
|
}
|
|
750
787
|
}
|
|
751
788
|
function checkSide(side, pos, from, to) {
|
|
752
789
|
switch (side) {
|
|
753
|
-
case -2 /* Before */: return from < pos;
|
|
754
|
-
case -1 /* AtOrBefore */: return to >= pos && from < pos;
|
|
755
|
-
case 0 /* Around */: return from < pos && to > pos;
|
|
756
|
-
case 1 /* AtOrAfter */: return from <= pos && to > pos;
|
|
757
|
-
case 2 /* After */: return to > pos;
|
|
758
|
-
case 4 /* DontCare */: return true;
|
|
790
|
+
case -2 /* Side.Before */: return from < pos;
|
|
791
|
+
case -1 /* Side.AtOrBefore */: return to >= pos && from < pos;
|
|
792
|
+
case 0 /* Side.Around */: return from < pos && to > pos;
|
|
793
|
+
case 1 /* Side.AtOrAfter */: return from <= pos && to > pos;
|
|
794
|
+
case 2 /* Side.After */: return to > pos;
|
|
795
|
+
case 4 /* Side.DontCare */: return true;
|
|
759
796
|
}
|
|
760
797
|
}
|
|
761
798
|
function enterUnfinishedNodesBefore(node, pos) {
|
|
@@ -845,10 +882,10 @@ class TreeNode {
|
|
|
845
882
|
return null;
|
|
846
883
|
}
|
|
847
884
|
}
|
|
848
|
-
get firstChild() { return this.nextChild(0, 1, 0, 4 /* DontCare */); }
|
|
849
|
-
get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* DontCare */); }
|
|
850
|
-
childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* After */); }
|
|
851
|
-
childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Before */); }
|
|
885
|
+
get firstChild() { return this.nextChild(0, 1, 0, 4 /* Side.DontCare */); }
|
|
886
|
+
get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* Side.DontCare */); }
|
|
887
|
+
childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* Side.After */); }
|
|
888
|
+
childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Side.Before */); }
|
|
852
889
|
enter(pos, side, mode = 0) {
|
|
853
890
|
let mounted;
|
|
854
891
|
if (!(mode & IterMode.IgnoreOverlays) && (mounted = this._tree.prop(dist_NodeProp.mounted)) && mounted.overlay) {
|
|
@@ -871,10 +908,10 @@ class TreeNode {
|
|
|
871
908
|
return this._parent ? this._parent.nextSignificantParent() : null;
|
|
872
909
|
}
|
|
873
910
|
get nextSibling() {
|
|
874
|
-
return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* DontCare */) : null;
|
|
911
|
+
return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* Side.DontCare */) : null;
|
|
875
912
|
}
|
|
876
913
|
get prevSibling() {
|
|
877
|
-
return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* DontCare */) : null;
|
|
914
|
+
return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* Side.DontCare */) : null;
|
|
878
915
|
}
|
|
879
916
|
cursor(mode = 0) { return new TreeCursor(this, mode); }
|
|
880
917
|
get tree() { return this._tree; }
|
|
@@ -936,24 +973,24 @@ class BufferContext {
|
|
|
936
973
|
}
|
|
937
974
|
}
|
|
938
975
|
class BufferNode {
|
|
976
|
+
get name() { return this.type.name; }
|
|
977
|
+
get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }
|
|
978
|
+
get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }
|
|
939
979
|
constructor(context, _parent, index) {
|
|
940
980
|
this.context = context;
|
|
941
981
|
this._parent = _parent;
|
|
942
982
|
this.index = index;
|
|
943
983
|
this.type = context.buffer.set.types[context.buffer.buffer[index]];
|
|
944
984
|
}
|
|
945
|
-
get name() { return this.type.name; }
|
|
946
|
-
get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }
|
|
947
|
-
get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }
|
|
948
985
|
child(dir, pos, side) {
|
|
949
986
|
let { buffer } = this.context;
|
|
950
987
|
let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
|
|
951
988
|
return index < 0 ? null : new BufferNode(this.context, this, index);
|
|
952
989
|
}
|
|
953
|
-
get firstChild() { return this.child(1, 0, 4 /* DontCare */); }
|
|
954
|
-
get lastChild() { return this.child(-1, 0, 4 /* DontCare */); }
|
|
955
|
-
childAfter(pos) { return this.child(1, pos, 2 /* After */); }
|
|
956
|
-
childBefore(pos) { return this.child(-1, pos, -2 /* Before */); }
|
|
990
|
+
get firstChild() { return this.child(1, 0, 4 /* Side.DontCare */); }
|
|
991
|
+
get lastChild() { return this.child(-1, 0, 4 /* Side.DontCare */); }
|
|
992
|
+
childAfter(pos) { return this.child(1, pos, 2 /* Side.After */); }
|
|
993
|
+
childBefore(pos) { return this.child(-1, pos, -2 /* Side.Before */); }
|
|
957
994
|
enter(pos, side, mode = 0) {
|
|
958
995
|
if (mode & IterMode.ExcludeBuffers)
|
|
959
996
|
return null;
|
|
@@ -965,7 +1002,7 @@ class BufferNode {
|
|
|
965
1002
|
return this._parent || this.context.parent.nextSignificantParent();
|
|
966
1003
|
}
|
|
967
1004
|
externalSibling(dir) {
|
|
968
|
-
return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* DontCare */);
|
|
1005
|
+
return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* Side.DontCare */);
|
|
969
1006
|
}
|
|
970
1007
|
get nextSibling() {
|
|
971
1008
|
let { buffer } = this.context;
|
|
@@ -979,7 +1016,7 @@ class BufferNode {
|
|
|
979
1016
|
let parentStart = this._parent ? this._parent.index + 4 : 0;
|
|
980
1017
|
if (this.index == parentStart)
|
|
981
1018
|
return this.externalSibling(-1);
|
|
982
|
-
return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */));
|
|
1019
|
+
return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));
|
|
983
1020
|
}
|
|
984
1021
|
cursor(mode = 0) { return new TreeCursor(this, mode); }
|
|
985
1022
|
get tree() { return null; }
|
|
@@ -988,8 +1025,8 @@ class BufferNode {
|
|
|
988
1025
|
let { buffer } = this.context;
|
|
989
1026
|
let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
|
|
990
1027
|
if (endI > startI) {
|
|
991
|
-
let from = buffer.buffer[this.index + 1]
|
|
992
|
-
children.push(buffer.slice(startI, endI, from
|
|
1028
|
+
let from = buffer.buffer[this.index + 1];
|
|
1029
|
+
children.push(buffer.slice(startI, endI, from));
|
|
993
1030
|
positions.push(0);
|
|
994
1031
|
}
|
|
995
1032
|
return new dist_Tree(this.type, children, positions, this.to - this.from);
|
|
@@ -1016,6 +1053,8 @@ class BufferNode {
|
|
|
1016
1053
|
/// A tree cursor object focuses on a given node in a syntax tree, and
|
|
1017
1054
|
/// allows you to move to adjacent nodes.
|
|
1018
1055
|
class TreeCursor {
|
|
1056
|
+
/// Shorthand for `.type.name`.
|
|
1057
|
+
get name() { return this.type.name; }
|
|
1019
1058
|
/// @internal
|
|
1020
1059
|
constructor(node,
|
|
1021
1060
|
/// @internal
|
|
@@ -1039,8 +1078,6 @@ class TreeCursor {
|
|
|
1039
1078
|
this.yieldBuf(node.index);
|
|
1040
1079
|
}
|
|
1041
1080
|
}
|
|
1042
|
-
/// Shorthand for `.type.name`.
|
|
1043
|
-
get name() { return this.type.name; }
|
|
1044
1081
|
yieldNode(node) {
|
|
1045
1082
|
if (!node)
|
|
1046
1083
|
return false;
|
|
@@ -1085,13 +1122,13 @@ class TreeCursor {
|
|
|
1085
1122
|
}
|
|
1086
1123
|
/// Move the cursor to this node's first child. When this returns
|
|
1087
1124
|
/// false, the node has no child, and the cursor has not been moved.
|
|
1088
|
-
firstChild() { return this.enterChild(1, 0, 4 /* DontCare */); }
|
|
1125
|
+
firstChild() { return this.enterChild(1, 0, 4 /* Side.DontCare */); }
|
|
1089
1126
|
/// Move the cursor to this node's last child.
|
|
1090
|
-
lastChild() { return this.enterChild(-1, 0, 4 /* DontCare */); }
|
|
1127
|
+
lastChild() { return this.enterChild(-1, 0, 4 /* Side.DontCare */); }
|
|
1091
1128
|
/// Move the cursor to the first child that ends after `pos`.
|
|
1092
|
-
childAfter(pos) { return this.enterChild(1, pos, 2 /* After */); }
|
|
1129
|
+
childAfter(pos) { return this.enterChild(1, pos, 2 /* Side.After */); }
|
|
1093
1130
|
/// Move to the last child that starts before `pos`.
|
|
1094
|
-
childBefore(pos) { return this.enterChild(-1, pos, -2 /* Before */); }
|
|
1131
|
+
childBefore(pos) { return this.enterChild(-1, pos, -2 /* Side.Before */); }
|
|
1095
1132
|
/// Move the cursor to the child around `pos`. If side is -1 the
|
|
1096
1133
|
/// child may end at that position, when 1 it may start there. This
|
|
1097
1134
|
/// will also enter [overlaid](#common.MountedTree.overlay)
|
|
@@ -1117,19 +1154,19 @@ class TreeCursor {
|
|
|
1117
1154
|
if (!this.buffer)
|
|
1118
1155
|
return !this._tree._parent ? false
|
|
1119
1156
|
: this.yield(this._tree.index < 0 ? null
|
|
1120
|
-
: this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* DontCare */, this.mode));
|
|
1157
|
+
: this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode));
|
|
1121
1158
|
let { buffer } = this.buffer, d = this.stack.length - 1;
|
|
1122
1159
|
if (dir < 0) {
|
|
1123
1160
|
let parentStart = d < 0 ? 0 : this.stack[d] + 4;
|
|
1124
1161
|
if (this.index != parentStart)
|
|
1125
|
-
return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */));
|
|
1162
|
+
return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));
|
|
1126
1163
|
}
|
|
1127
1164
|
else {
|
|
1128
1165
|
let after = buffer.buffer[this.index + 3];
|
|
1129
1166
|
if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
|
|
1130
1167
|
return this.yieldBuf(after);
|
|
1131
1168
|
}
|
|
1132
|
-
return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* DontCare */, this.mode)) : false;
|
|
1169
|
+
return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode)) : false;
|
|
1133
1170
|
}
|
|
1134
1171
|
/// Move to this node's next sibling, if any.
|
|
1135
1172
|
nextSibling() { return this.sibling(1); }
|
|
@@ -1166,7 +1203,7 @@ class TreeCursor {
|
|
|
1166
1203
|
return true;
|
|
1167
1204
|
}
|
|
1168
1205
|
move(dir, enter) {
|
|
1169
|
-
if (enter && this.enterChild(dir, 0, 4 /* DontCare */))
|
|
1206
|
+
if (enter && this.enterChild(dir, 0, 4 /* Side.DontCare */))
|
|
1170
1207
|
return true;
|
|
1171
1208
|
for (;;) {
|
|
1172
1209
|
if (this.sibling(dir))
|
|
@@ -1176,7 +1213,7 @@ class TreeCursor {
|
|
|
1176
1213
|
}
|
|
1177
1214
|
}
|
|
1178
1215
|
/// Move to the next node in a
|
|
1179
|
-
/// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-
|
|
1216
|
+
/// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
|
|
1180
1217
|
/// traversal, going from a node to its first child or, if the
|
|
1181
1218
|
/// current node is empty or `enter` is false, its next sibling or
|
|
1182
1219
|
/// the next sibling of the first parent node that has one.
|
|
@@ -1292,17 +1329,17 @@ function buildTree(data) {
|
|
|
1292
1329
|
let lookAheadAtStart = lookAhead;
|
|
1293
1330
|
while (size < 0) {
|
|
1294
1331
|
cursor.next();
|
|
1295
|
-
if (size == -1 /* Reuse */) {
|
|
1332
|
+
if (size == -1 /* SpecialRecord.Reuse */) {
|
|
1296
1333
|
let node = reused[id];
|
|
1297
1334
|
children.push(node);
|
|
1298
1335
|
positions.push(start - parentStart);
|
|
1299
1336
|
return;
|
|
1300
1337
|
}
|
|
1301
|
-
else if (size == -3 /* ContextChange */) { // Context change
|
|
1338
|
+
else if (size == -3 /* SpecialRecord.ContextChange */) { // Context change
|
|
1302
1339
|
contextHash = id;
|
|
1303
1340
|
return;
|
|
1304
1341
|
}
|
|
1305
|
-
else if (size == -4 /* LookAhead */) {
|
|
1342
|
+
else if (size == -4 /* SpecialRecord.LookAhead */) {
|
|
1306
1343
|
lookAhead = id;
|
|
1307
1344
|
return;
|
|
1308
1345
|
}
|
|
@@ -1419,7 +1456,7 @@ function buildTree(data) {
|
|
|
1419
1456
|
fork.next();
|
|
1420
1457
|
while (fork.pos > startPos) {
|
|
1421
1458
|
if (fork.size < 0) {
|
|
1422
|
-
if (fork.size == -3 /* ContextChange */)
|
|
1459
|
+
if (fork.size == -3 /* SpecialRecord.ContextChange */)
|
|
1423
1460
|
localSkipped += 4;
|
|
1424
1461
|
else
|
|
1425
1462
|
break scan;
|
|
@@ -1455,10 +1492,10 @@ function buildTree(data) {
|
|
|
1455
1492
|
buffer[--index] = start - bufferStart;
|
|
1456
1493
|
buffer[--index] = id;
|
|
1457
1494
|
}
|
|
1458
|
-
else if (size == -3 /* ContextChange */) {
|
|
1495
|
+
else if (size == -3 /* SpecialRecord.ContextChange */) {
|
|
1459
1496
|
contextHash = id;
|
|
1460
1497
|
}
|
|
1461
|
-
else if (size == -4 /* LookAhead */) {
|
|
1498
|
+
else if (size == -4 /* SpecialRecord.LookAhead */) {
|
|
1462
1499
|
lookAhead = id;
|
|
1463
1500
|
}
|
|
1464
1501
|
return index;
|
|
@@ -1505,7 +1542,7 @@ mkTree) {
|
|
|
1505
1542
|
let total = 0;
|
|
1506
1543
|
for (let i = from; i < to; i++)
|
|
1507
1544
|
total += nodeSize(balanceType, children[i]);
|
|
1508
|
-
let maxChild = Math.ceil((total * 1.5) / 8 /* BranchFactor */);
|
|
1545
|
+
let maxChild = Math.ceil((total * 1.5) / 8 /* Balance.BranchFactor */);
|
|
1509
1546
|
let localChildren = [], localPositions = [];
|
|
1510
1547
|
function divide(children, positions, from, to, offset) {
|
|
1511
1548
|
for (let i = from; i < to;) {
|
|
@@ -1608,16 +1645,16 @@ class TreeFragment {
|
|
|
1608
1645
|
this.to = to;
|
|
1609
1646
|
this.tree = tree;
|
|
1610
1647
|
this.offset = offset;
|
|
1611
|
-
this.open = (openStart ? 1 /* Start */ : 0) | (openEnd ? 2 /* End */ : 0);
|
|
1648
|
+
this.open = (openStart ? 1 /* Open.Start */ : 0) | (openEnd ? 2 /* Open.End */ : 0);
|
|
1612
1649
|
}
|
|
1613
1650
|
/// Whether the start of the fragment represents the start of a
|
|
1614
1651
|
/// parse, or the end of a change. (In the second case, it may not
|
|
1615
1652
|
/// be safe to reuse some nodes at the start, depending on the
|
|
1616
1653
|
/// parsing algorithm.)
|
|
1617
|
-
get openStart() { return (this.open & 1 /* Start */) > 0; }
|
|
1654
|
+
get openStart() { return (this.open & 1 /* Open.Start */) > 0; }
|
|
1618
1655
|
/// Whether the end of the fragment represents the end of a
|
|
1619
1656
|
/// full-document parse, or the start of a change.
|
|
1620
|
-
get openEnd() { return (this.open & 2 /* End */) > 0; }
|
|
1657
|
+
get openEnd() { return (this.open & 2 /* Open.End */) > 0; }
|
|
1621
1658
|
/// Create a set of fragments from a freshly parsed tree, or update
|
|
1622
1659
|
/// an existing set of fragments by replacing the ones that overlap
|
|
1623
1660
|
/// with a tree with content from the new tree. When `partial` is
|
|
@@ -1811,7 +1848,7 @@ class MixedParse {
|
|
|
1811
1848
|
enter = false;
|
|
1812
1849
|
}
|
|
1813
1850
|
else if (covered && (isCovered = checkCover(covered.ranges, cursor.from, cursor.to))) {
|
|
1814
|
-
enter = isCovered != 2 /* Full */;
|
|
1851
|
+
enter = isCovered != 2 /* Cover.Full */;
|
|
1815
1852
|
}
|
|
1816
1853
|
else if (!cursor.type.isAnonymous && cursor.from < cursor.to && (nest = this.nest(cursor, this.input))) {
|
|
1817
1854
|
if (!cursor.tree)
|
|
@@ -1866,16 +1903,16 @@ function checkCover(covered, from, to) {
|
|
|
1866
1903
|
if (range.from >= to)
|
|
1867
1904
|
break;
|
|
1868
1905
|
if (range.to > from)
|
|
1869
|
-
return range.from <= from && range.to >= to ? 2 /* Full */ : 1 /* Partial */;
|
|
1906
|
+
return range.from <= from && range.to >= to ? 2 /* Cover.Full */ : 1 /* Cover.Partial */;
|
|
1870
1907
|
}
|
|
1871
|
-
return 0 /* None */;
|
|
1908
|
+
return 0 /* Cover.None */;
|
|
1872
1909
|
}
|
|
1873
1910
|
// Take a piece of buffer and convert it into a stand-alone
|
|
1874
1911
|
// TreeBuffer.
|
|
1875
1912
|
function sliceBuf(buf, startI, endI, nodes, positions, off) {
|
|
1876
1913
|
if (startI < endI) {
|
|
1877
|
-
let from = buf.buffer[startI + 1]
|
|
1878
|
-
nodes.push(buf.slice(startI, endI, from
|
|
1914
|
+
let from = buf.buffer[startI + 1];
|
|
1915
|
+
nodes.push(buf.slice(startI, endI, from));
|
|
1879
1916
|
positions.push(from - off);
|
|
1880
1917
|
}
|
|
1881
1918
|
}
|
|
@@ -2259,10 +2296,10 @@ function styleTags(spec) {
|
|
|
2259
2296
|
tags = [tags];
|
|
2260
2297
|
for (let part of prop.split(" "))
|
|
2261
2298
|
if (part) {
|
|
2262
|
-
let pieces = [], mode = 2 /* Normal */, rest = part;
|
|
2299
|
+
let pieces = [], mode = 2 /* Mode.Normal */, rest = part;
|
|
2263
2300
|
for (let pos = 0;;) {
|
|
2264
2301
|
if (rest == "..." && pos > 0 && pos + 3 == part.length) {
|
|
2265
|
-
mode = 1 /* Inherit */;
|
|
2302
|
+
mode = 1 /* Mode.Inherit */;
|
|
2266
2303
|
break;
|
|
2267
2304
|
}
|
|
2268
2305
|
let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
|
|
@@ -2274,7 +2311,7 @@ function styleTags(spec) {
|
|
|
2274
2311
|
break;
|
|
2275
2312
|
let next = part[pos++];
|
|
2276
2313
|
if (pos == part.length && next == "!") {
|
|
2277
|
-
mode = 0 /* Opaque */;
|
|
2314
|
+
mode = 0 /* Mode.Opaque */;
|
|
2278
2315
|
break;
|
|
2279
2316
|
}
|
|
2280
2317
|
if (next != "/")
|
|
@@ -2298,8 +2335,8 @@ class Rule {
|
|
|
2298
2335
|
this.context = context;
|
|
2299
2336
|
this.next = next;
|
|
2300
2337
|
}
|
|
2301
|
-
get opaque() { return this.mode == 0 /* Opaque */; }
|
|
2302
|
-
get inherit() { return this.mode == 1 /* Inherit */; }
|
|
2338
|
+
get opaque() { return this.mode == 0 /* Mode.Opaque */; }
|
|
2339
|
+
get inherit() { return this.mode == 1 /* Mode.Inherit */; }
|
|
2303
2340
|
sort(other) {
|
|
2304
2341
|
if (!other || other.depth < this.depth) {
|
|
2305
2342
|
this.next = other;
|
|
@@ -2310,7 +2347,7 @@ class Rule {
|
|
|
2310
2347
|
}
|
|
2311
2348
|
get depth() { return this.context ? this.context.length : 0; }
|
|
2312
2349
|
}
|
|
2313
|
-
Rule.empty = new Rule([], 2 /* Normal */, null);
|
|
2350
|
+
Rule.empty = new Rule([], 2 /* Mode.Normal */, null);
|
|
2314
2351
|
/// Define a [highlighter](#highlight.Highlighter) from an array of
|
|
2315
2352
|
/// tag/class pairs. Classes associated with more specific tags will
|
|
2316
2353
|
/// take precedence.
|
|
@@ -2397,7 +2434,7 @@ class HighlightBuilder {
|
|
|
2397
2434
|
if (cls)
|
|
2398
2435
|
cls += " ";
|
|
2399
2436
|
cls += tagCls;
|
|
2400
|
-
if (rule.mode == 1 /* Inherit */)
|
|
2437
|
+
if (rule.mode == 1 /* Mode.Inherit */)
|
|
2401
2438
|
inheritedClass += (inheritedClass ? " " : "") + tagCls;
|
|
2402
2439
|
}
|
|
2403
2440
|
this.startSpan(cursor.from, cls);
|
|
@@ -2415,7 +2452,7 @@ class HighlightBuilder {
|
|
|
2415
2452
|
if (rangeFrom < rangeTo && hasChild) {
|
|
2416
2453
|
while (cursor.from < rangeTo) {
|
|
2417
2454
|
this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
|
|
2418
|
-
this.startSpan(Math.min(
|
|
2455
|
+
this.startSpan(Math.min(rangeTo, cursor.to), cls);
|
|
2419
2456
|
if (cursor.to >= nextPos || !cursor.nextSibling())
|
|
2420
2457
|
break;
|
|
2421
2458
|
}
|
|
@@ -9177,6 +9214,7 @@ const autocomplete_dist_baseTheme = /*@__PURE__*/view_.EditorView.baseTheme({
|
|
|
9177
9214
|
maxWidth: "min(700px, 95vw)",
|
|
9178
9215
|
minWidth: "250px",
|
|
9179
9216
|
maxHeight: "10em",
|
|
9217
|
+
height: "100%",
|
|
9180
9218
|
listStyle: "none",
|
|
9181
9219
|
margin: 0,
|
|
9182
9220
|
padding: 0,
|
|
@@ -9243,7 +9281,8 @@ const autocomplete_dist_baseTheme = /*@__PURE__*/view_.EditorView.baseTheme({
|
|
|
9243
9281
|
display: "inline-block",
|
|
9244
9282
|
textAlign: "center",
|
|
9245
9283
|
paddingRight: ".6em",
|
|
9246
|
-
opacity: "0.6"
|
|
9284
|
+
opacity: "0.6",
|
|
9285
|
+
boxSizing: "content-box"
|
|
9247
9286
|
},
|
|
9248
9287
|
".cm-completionIcon-function, .cm-completionIcon-method": {
|
|
9249
9288
|
"&:after": { content: "'ƒ'" }
|
|
@@ -9345,8 +9384,8 @@ class Snippet {
|
|
|
9345
9384
|
positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
|
|
9346
9385
|
line = line.slice(0, m.index) + name + line.slice(m.index + m[0].length);
|
|
9347
9386
|
}
|
|
9348
|
-
for (let esc; esc =
|
|
9349
|
-
line = line.slice(0, esc.index) + esc[1] +
|
|
9387
|
+
for (let esc; esc = /\\([{}])/.exec(line);) {
|
|
9388
|
+
line = line.slice(0, esc.index) + esc[1] + line.slice(esc.index + esc[0].length);
|
|
9350
9389
|
for (let pos of positions)
|
|
9351
9390
|
if (pos.line == lines.length && pos.from > esc.index) {
|
|
9352
9391
|
pos.from--;
|
|
@@ -9437,10 +9476,9 @@ The order of fields defaults to textual order, but you can add
|
|
|
9437
9476
|
numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
|
|
9438
9477
|
a custom order.
|
|
9439
9478
|
|
|
9440
|
-
To include a literal
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
placeholder.
|
|
9479
|
+
To include a literal `{` or `}` in your template, put a backslash
|
|
9480
|
+
in front of it. This will be removed and the brace will not be
|
|
9481
|
+
interpreted as indicating a placeholder.
|
|
9444
9482
|
*/
|
|
9445
9483
|
function snippet(template) {
|
|
9446
9484
|
let snippet = Snippet.parse(template);
|