@lstsystems/ckeditor5-source-editing-codemirror 47.5.1 → 48.1.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/dist/sourceediting-codemirror.css +2 -1
- package/dist/sourceediting-codemirror.js +1019 -255
- package/package.json +24 -13
- package/tsconfig.json +9 -3
- package/vite.config.js +2 -5
- package/tsconfig.build.json +0 -17
|
@@ -1,261 +1,1025 @@
|
|
|
1
|
-
import { Plugin as
|
|
2
|
-
import {
|
|
3
|
-
import { EditorSelection as
|
|
4
|
-
import { html as
|
|
5
|
-
import { IndentContext as
|
|
6
|
-
import
|
|
7
|
-
import * as
|
|
8
|
-
import * as
|
|
9
|
-
import * as
|
|
10
|
-
import * as
|
|
11
|
-
import * as
|
|
12
|
-
|
|
13
|
-
class
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
import { Plugin as e } from "ckeditor5";
|
|
2
|
+
import { EditorView as t, highlightActiveLine as n, highlightActiveLineGutter as r, lineNumbers as i } from "@codemirror/view";
|
|
3
|
+
import { Annotation as a, ChangeDesc as o, ChangeSet as s, EditorSelection as c, EditorState as l, Facet as u, StateEffect as d } from "@codemirror/state";
|
|
4
|
+
import { html as f } from "@codemirror/lang-html";
|
|
5
|
+
import { IndentContext as p, defaultHighlightStyle as m, getIndentation as h, indentOnInput as g, indentString as _, indentUnit as v, syntaxHighlighting as y } from "@codemirror/language";
|
|
6
|
+
import b from "prettier/standalone";
|
|
7
|
+
import * as x from "prettier/plugins/html";
|
|
8
|
+
import * as S from "prettier/plugins/postcss";
|
|
9
|
+
import * as C from "prettier/plugins/typescript";
|
|
10
|
+
import * as w from "prettier/plugins/markdown";
|
|
11
|
+
import * as T from "prettier/plugins/yaml";
|
|
12
|
+
//#region node_modules/@lezer/common/dist/index.js
|
|
13
|
+
var E = 1024, D = 0, O = class {
|
|
14
|
+
constructor(e = {}) {
|
|
15
|
+
this.id = D++, this.perNode = !!e.perNode, this.deserialize = e.deserialize || (() => {
|
|
16
|
+
throw Error("This node type doesn't define a deserialize function");
|
|
17
|
+
}), this.combine = e.combine || null;
|
|
18
|
+
}
|
|
19
|
+
add(e) {
|
|
20
|
+
if (this.perNode) throw RangeError("Can't add per-node props to node types");
|
|
21
|
+
return typeof e != "function" && (e = j.match(e)), (t) => {
|
|
22
|
+
let n = e(t);
|
|
23
|
+
return n === void 0 ? null : [this, n];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
O.closedBy = new O({ deserialize: (e) => e.split(" ") }), O.openedBy = new O({ deserialize: (e) => e.split(" ") }), O.group = new O({ deserialize: (e) => e.split(" ") }), O.isolate = new O({ deserialize: (e) => {
|
|
28
|
+
if (e && e != "rtl" && e != "ltr" && e != "auto") throw RangeError("Invalid value for isolate: " + e);
|
|
29
|
+
return e || "auto";
|
|
30
|
+
} }), O.contextHash = new O({ perNode: !0 }), O.lookAhead = new O({ perNode: !0 }), O.mounted = new O({ perNode: !0 });
|
|
31
|
+
var k = class {
|
|
32
|
+
constructor(e, t, n, r = !1) {
|
|
33
|
+
this.tree = e, this.overlay = t, this.parser = n, this.bracketed = r;
|
|
34
|
+
}
|
|
35
|
+
static get(e) {
|
|
36
|
+
return e && e.props && e.props[O.mounted.id];
|
|
37
|
+
}
|
|
38
|
+
}, A = Object.create(null), j = class e {
|
|
39
|
+
constructor(e, t, n, r = 0) {
|
|
40
|
+
this.name = e, this.props = t, this.id = n, this.flags = r;
|
|
41
|
+
}
|
|
42
|
+
static define(t) {
|
|
43
|
+
let n = t.props && t.props.length ? Object.create(null) : A, r = !!t.top | (t.skipped ? 2 : 0) | (t.error ? 4 : 0) | (t.name == null ? 8 : 0), i = new e(t.name || "", n, t.id, r);
|
|
44
|
+
if (t.props) {
|
|
45
|
+
for (let e of t.props) if (Array.isArray(e) || (e = e(i)), e) {
|
|
46
|
+
if (e[0].perNode) throw RangeError("Can't store a per-node prop on a node type");
|
|
47
|
+
n[e[0].id] = e[1];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return i;
|
|
51
|
+
}
|
|
52
|
+
prop(e) {
|
|
53
|
+
return this.props[e.id];
|
|
54
|
+
}
|
|
55
|
+
get isTop() {
|
|
56
|
+
return (this.flags & 1) > 0;
|
|
57
|
+
}
|
|
58
|
+
get isSkipped() {
|
|
59
|
+
return (this.flags & 2) > 0;
|
|
60
|
+
}
|
|
61
|
+
get isError() {
|
|
62
|
+
return (this.flags & 4) > 0;
|
|
63
|
+
}
|
|
64
|
+
get isAnonymous() {
|
|
65
|
+
return (this.flags & 8) > 0;
|
|
66
|
+
}
|
|
67
|
+
is(e) {
|
|
68
|
+
if (typeof e == "string") {
|
|
69
|
+
if (this.name == e) return !0;
|
|
70
|
+
let t = this.prop(O.group);
|
|
71
|
+
return t ? t.indexOf(e) > -1 : !1;
|
|
72
|
+
}
|
|
73
|
+
return this.id == e;
|
|
74
|
+
}
|
|
75
|
+
static match(e) {
|
|
76
|
+
let t = Object.create(null);
|
|
77
|
+
for (let n in e) for (let r of n.split(" ")) t[r] = e[n];
|
|
78
|
+
return (e) => {
|
|
79
|
+
for (let n = e.prop(O.group), r = -1; r < (n ? n.length : 0); r++) {
|
|
80
|
+
let i = t[r < 0 ? e.name : n[r]];
|
|
81
|
+
if (i) return i;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
j.none = new j("", Object.create(null), 0, 8);
|
|
87
|
+
var M = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap(), P;
|
|
88
|
+
(function(e) {
|
|
89
|
+
e[e.ExcludeBuffers = 1] = "ExcludeBuffers", e[e.IncludeAnonymous = 2] = "IncludeAnonymous", e[e.IgnoreMounts = 4] = "IgnoreMounts", e[e.IgnoreOverlays = 8] = "IgnoreOverlays", e[e.EnterBracketed = 16] = "EnterBracketed";
|
|
90
|
+
})(P ||= {});
|
|
91
|
+
var F = class e {
|
|
92
|
+
constructor(e, t, n, r, i) {
|
|
93
|
+
if (this.type = e, this.children = t, this.positions = n, this.length = r, this.props = null, i && i.length) {
|
|
94
|
+
this.props = Object.create(null);
|
|
95
|
+
for (let [e, t] of i) this.props[typeof e == "number" ? e : e.id] = t;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
toString() {
|
|
99
|
+
let e = k.get(this);
|
|
100
|
+
if (e && !e.overlay) return e.tree.toString();
|
|
101
|
+
let t = "";
|
|
102
|
+
for (let e of this.children) {
|
|
103
|
+
let n = e.toString();
|
|
104
|
+
n && (t && (t += ","), t += n);
|
|
105
|
+
}
|
|
106
|
+
return this.type.name ? (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (t.length ? "(" + t + ")" : "") : t;
|
|
107
|
+
}
|
|
108
|
+
cursor(e = 0) {
|
|
109
|
+
return new W(this.topNode, e);
|
|
110
|
+
}
|
|
111
|
+
cursorAt(e, t = 0, n = 0) {
|
|
112
|
+
let r = new W(M.get(this) || this.topNode);
|
|
113
|
+
return r.moveTo(e, t), M.set(this, r._tree), r;
|
|
114
|
+
}
|
|
115
|
+
get topNode() {
|
|
116
|
+
return new B(this, 0, 0, null);
|
|
117
|
+
}
|
|
118
|
+
resolve(e, t = 0) {
|
|
119
|
+
let n = R(M.get(this) || this.topNode, e, t, !1);
|
|
120
|
+
return M.set(this, n), n;
|
|
121
|
+
}
|
|
122
|
+
resolveInner(e, t = 0) {
|
|
123
|
+
let n = R(N.get(this) || this.topNode, e, t, !0);
|
|
124
|
+
return N.set(this, n), n;
|
|
125
|
+
}
|
|
126
|
+
resolveStack(e, t = 0) {
|
|
127
|
+
return ie(this, e, t);
|
|
128
|
+
}
|
|
129
|
+
iterate(e) {
|
|
130
|
+
let { enter: t, leave: n, from: r = 0, to: i = this.length } = e, a = e.mode || 0, o = (a & P.IncludeAnonymous) > 0;
|
|
131
|
+
for (let e = this.cursor(a | P.IncludeAnonymous);;) {
|
|
132
|
+
let a = !1;
|
|
133
|
+
if (e.from <= i && e.to >= r && (!o && e.type.isAnonymous || t(e) !== !1)) {
|
|
134
|
+
if (e.firstChild()) continue;
|
|
135
|
+
a = !0;
|
|
136
|
+
}
|
|
137
|
+
for (; a && n && (o || !e.type.isAnonymous) && n(e), !e.nextSibling();) {
|
|
138
|
+
if (!e.parent()) return;
|
|
139
|
+
a = !0;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
prop(e) {
|
|
144
|
+
return e.perNode ? this.props ? this.props[e.id] : void 0 : this.type.prop(e);
|
|
145
|
+
}
|
|
146
|
+
get propValues() {
|
|
147
|
+
let e = [];
|
|
148
|
+
if (this.props) for (let t in this.props) e.push([+t, this.props[t]]);
|
|
149
|
+
return e;
|
|
150
|
+
}
|
|
151
|
+
balance(t = {}) {
|
|
152
|
+
return this.children.length <= 8 ? this : J(j.none, this.children, this.positions, 0, this.children.length, 0, this.length, (t, n, r) => new e(this.type, t, n, r, this.propValues), t.makeTree || ((t, n, r) => new e(j.none, t, n, r)));
|
|
153
|
+
}
|
|
154
|
+
static build(e) {
|
|
155
|
+
return ae(e);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
F.empty = new F(j.none, [], [], 0);
|
|
159
|
+
var ee = class e {
|
|
160
|
+
constructor(e, t) {
|
|
161
|
+
this.buffer = e, this.index = t;
|
|
162
|
+
}
|
|
163
|
+
get id() {
|
|
164
|
+
return this.buffer[this.index - 4];
|
|
165
|
+
}
|
|
166
|
+
get start() {
|
|
167
|
+
return this.buffer[this.index - 3];
|
|
168
|
+
}
|
|
169
|
+
get end() {
|
|
170
|
+
return this.buffer[this.index - 2];
|
|
171
|
+
}
|
|
172
|
+
get size() {
|
|
173
|
+
return this.buffer[this.index - 1];
|
|
174
|
+
}
|
|
175
|
+
get pos() {
|
|
176
|
+
return this.index;
|
|
177
|
+
}
|
|
178
|
+
next() {
|
|
179
|
+
this.index -= 4;
|
|
180
|
+
}
|
|
181
|
+
fork() {
|
|
182
|
+
return new e(this.buffer, this.index);
|
|
183
|
+
}
|
|
184
|
+
}, I = class e {
|
|
185
|
+
constructor(e, t, n) {
|
|
186
|
+
this.buffer = e, this.length = t, this.set = n;
|
|
187
|
+
}
|
|
188
|
+
get type() {
|
|
189
|
+
return j.none;
|
|
190
|
+
}
|
|
191
|
+
toString() {
|
|
192
|
+
let e = [];
|
|
193
|
+
for (let t = 0; t < this.buffer.length;) e.push(this.childString(t)), t = this.buffer[t + 3];
|
|
194
|
+
return e.join(",");
|
|
195
|
+
}
|
|
196
|
+
childString(e) {
|
|
197
|
+
let t = this.buffer[e], n = this.buffer[e + 3], r = this.set.types[t], i = r.name;
|
|
198
|
+
if (/\W/.test(i) && !r.isError && (i = JSON.stringify(i)), e += 4, n == e) return i;
|
|
199
|
+
let a = [];
|
|
200
|
+
for (; e < n;) a.push(this.childString(e)), e = this.buffer[e + 3];
|
|
201
|
+
return i + "(" + a.join(",") + ")";
|
|
202
|
+
}
|
|
203
|
+
findChild(e, t, n, r, i) {
|
|
204
|
+
let { buffer: a } = this, o = -1;
|
|
205
|
+
for (let s = e; s != t && !(L(i, r, a[s + 1], a[s + 2]) && (o = s, n > 0)); s = a[s + 3]);
|
|
206
|
+
return o;
|
|
207
|
+
}
|
|
208
|
+
slice(t, n, r) {
|
|
209
|
+
let i = this.buffer, a = new Uint16Array(n - t), o = 0;
|
|
210
|
+
for (let e = t, s = 0; e < n;) {
|
|
211
|
+
a[s++] = i[e++], a[s++] = i[e++] - r;
|
|
212
|
+
let n = a[s++] = i[e++] - r;
|
|
213
|
+
a[s++] = i[e++] - t, o = Math.max(o, n);
|
|
214
|
+
}
|
|
215
|
+
return new e(a, o, this.set);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
function L(e, t, n, r) {
|
|
219
|
+
switch (e) {
|
|
220
|
+
case -2: return n < t;
|
|
221
|
+
case -1: return r >= t && n < t;
|
|
222
|
+
case 0: return n < t && r > t;
|
|
223
|
+
case 1: return n <= t && r > t;
|
|
224
|
+
case 2: return r > t;
|
|
225
|
+
case 4: return !0;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function R(e, t, n, r) {
|
|
229
|
+
for (; e.from == e.to || (n < 1 ? e.from >= t : e.from > t) || (n > -1 ? e.to <= t : e.to < t);) {
|
|
230
|
+
let t = !r && e instanceof B && e.index < 0 ? null : e.parent;
|
|
231
|
+
if (!t) return e;
|
|
232
|
+
e = t;
|
|
233
|
+
}
|
|
234
|
+
let i = r ? 0 : P.IgnoreOverlays;
|
|
235
|
+
if (r) for (let r = e, a = r.parent; a; r = a, a = r.parent) r instanceof B && r.index < 0 && a.enter(t, n, i)?.from != r.from && (e = a);
|
|
236
|
+
for (;;) {
|
|
237
|
+
let r = e.enter(t, n, i);
|
|
238
|
+
if (!r) return e;
|
|
239
|
+
e = r;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
var z = class {
|
|
243
|
+
cursor(e = 0) {
|
|
244
|
+
return new W(this, e);
|
|
245
|
+
}
|
|
246
|
+
getChild(e, t = null, n = null) {
|
|
247
|
+
let r = V(this, e, t, n);
|
|
248
|
+
return r.length ? r[0] : null;
|
|
249
|
+
}
|
|
250
|
+
getChildren(e, t = null, n = null) {
|
|
251
|
+
return V(this, e, t, n);
|
|
252
|
+
}
|
|
253
|
+
resolve(e, t = 0) {
|
|
254
|
+
return R(this, e, t, !1);
|
|
255
|
+
}
|
|
256
|
+
resolveInner(e, t = 0) {
|
|
257
|
+
return R(this, e, t, !0);
|
|
258
|
+
}
|
|
259
|
+
matchContext(e) {
|
|
260
|
+
return H(this.parent, e);
|
|
261
|
+
}
|
|
262
|
+
enterUnfinishedNodesBefore(e) {
|
|
263
|
+
let t = this.childBefore(e), n = this;
|
|
264
|
+
for (; t;) {
|
|
265
|
+
let e = t.lastChild;
|
|
266
|
+
if (!e || e.to != t.to) break;
|
|
267
|
+
e.type.isError && e.from == e.to ? (n = t, t = e.prevSibling) : t = e;
|
|
268
|
+
}
|
|
269
|
+
return n;
|
|
270
|
+
}
|
|
271
|
+
get node() {
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
get next() {
|
|
275
|
+
return this.parent;
|
|
276
|
+
}
|
|
277
|
+
}, B = class e extends z {
|
|
278
|
+
constructor(e, t, n, r) {
|
|
279
|
+
super(), this._tree = e, this.from = t, this.index = n, this._parent = r;
|
|
280
|
+
}
|
|
281
|
+
get type() {
|
|
282
|
+
return this._tree.type;
|
|
283
|
+
}
|
|
284
|
+
get name() {
|
|
285
|
+
return this._tree.type.name;
|
|
286
|
+
}
|
|
287
|
+
get to() {
|
|
288
|
+
return this.from + this._tree.length;
|
|
289
|
+
}
|
|
290
|
+
nextChild(t, n, r, i, a = 0) {
|
|
291
|
+
for (let o = this;;) {
|
|
292
|
+
for (let { children: s, positions: c } = o._tree, l = n > 0 ? s.length : -1; t != l; t += n) {
|
|
293
|
+
let l = s[t], u = c[t] + o.from, d;
|
|
294
|
+
if (!(!(a & P.EnterBracketed && l instanceof F && (d = k.get(l)) && !d.overlay && d.bracketed && r >= u && r <= u + l.length) && !L(i, r, u, u + l.length))) {
|
|
295
|
+
if (l instanceof I) {
|
|
296
|
+
if (a & P.ExcludeBuffers) continue;
|
|
297
|
+
let e = l.findChild(0, l.buffer.length, n, r - u, i);
|
|
298
|
+
if (e > -1) return new U(new te(o, l, t, u), null, e);
|
|
299
|
+
} else if (a & P.IncludeAnonymous || !l.type.isAnonymous || G(l)) {
|
|
300
|
+
let s;
|
|
301
|
+
if (!(a & P.IgnoreMounts) && (s = k.get(l)) && !s.overlay) return new e(s.tree, u, t, o);
|
|
302
|
+
let c = new e(l, u, t, o);
|
|
303
|
+
return a & P.IncludeAnonymous || !c.type.isAnonymous ? c : c.nextChild(n < 0 ? l.children.length - 1 : 0, n, r, i, a);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (a & P.IncludeAnonymous || !o.type.isAnonymous || (t = o.index >= 0 ? o.index + n : n < 0 ? -1 : o._parent._tree.children.length, o = o._parent, !o)) return null;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
get firstChild() {
|
|
311
|
+
return this.nextChild(0, 1, 0, 4);
|
|
312
|
+
}
|
|
313
|
+
get lastChild() {
|
|
314
|
+
return this.nextChild(this._tree.children.length - 1, -1, 0, 4);
|
|
315
|
+
}
|
|
316
|
+
childAfter(e) {
|
|
317
|
+
return this.nextChild(0, 1, e, 2);
|
|
318
|
+
}
|
|
319
|
+
childBefore(e) {
|
|
320
|
+
return this.nextChild(this._tree.children.length - 1, -1, e, -2);
|
|
321
|
+
}
|
|
322
|
+
prop(e) {
|
|
323
|
+
return this._tree.prop(e);
|
|
324
|
+
}
|
|
325
|
+
enter(t, n, r = 0) {
|
|
326
|
+
let i;
|
|
327
|
+
if (!(r & P.IgnoreOverlays) && (i = k.get(this._tree)) && i.overlay) {
|
|
328
|
+
let a = t - this.from, o = r & P.EnterBracketed && i.bracketed;
|
|
329
|
+
for (let { from: t, to: r } of i.overlay) if ((n > 0 || o ? t <= a : t < a) && (n < 0 || o ? r >= a : r > a)) return new e(i.tree, i.overlay[0].from + this.from, -1, this);
|
|
330
|
+
}
|
|
331
|
+
return this.nextChild(0, 1, t, n, r);
|
|
332
|
+
}
|
|
333
|
+
nextSignificantParent() {
|
|
334
|
+
let e = this;
|
|
335
|
+
for (; e.type.isAnonymous && e._parent;) e = e._parent;
|
|
336
|
+
return e;
|
|
337
|
+
}
|
|
338
|
+
get parent() {
|
|
339
|
+
return this._parent ? this._parent.nextSignificantParent() : null;
|
|
340
|
+
}
|
|
341
|
+
get nextSibling() {
|
|
342
|
+
return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4) : null;
|
|
343
|
+
}
|
|
344
|
+
get prevSibling() {
|
|
345
|
+
return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4) : null;
|
|
346
|
+
}
|
|
347
|
+
get tree() {
|
|
348
|
+
return this._tree;
|
|
349
|
+
}
|
|
350
|
+
toTree() {
|
|
351
|
+
return this._tree;
|
|
352
|
+
}
|
|
353
|
+
toString() {
|
|
354
|
+
return this._tree.toString();
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
function V(e, t, n, r) {
|
|
358
|
+
let i = e.cursor(), a = [];
|
|
359
|
+
if (!i.firstChild()) return a;
|
|
360
|
+
if (n != null) {
|
|
361
|
+
for (let e = !1; !e;) if (e = i.type.is(n), !i.nextSibling()) return a;
|
|
362
|
+
}
|
|
363
|
+
for (;;) {
|
|
364
|
+
if (r != null && i.type.is(r)) return a;
|
|
365
|
+
if (i.type.is(t) && a.push(i.node), !i.nextSibling()) return r == null ? a : [];
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function H(e, t, n = t.length - 1) {
|
|
369
|
+
for (let r = e; n >= 0; r = r.parent) {
|
|
370
|
+
if (!r) return !1;
|
|
371
|
+
if (!r.type.isAnonymous) {
|
|
372
|
+
if (t[n] && t[n] != r.name) return !1;
|
|
373
|
+
n--;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return !0;
|
|
377
|
+
}
|
|
378
|
+
var te = class {
|
|
379
|
+
constructor(e, t, n, r) {
|
|
380
|
+
this.parent = e, this.buffer = t, this.index = n, this.start = r;
|
|
381
|
+
}
|
|
382
|
+
}, U = class e extends z {
|
|
383
|
+
get name() {
|
|
384
|
+
return this.type.name;
|
|
385
|
+
}
|
|
386
|
+
get from() {
|
|
387
|
+
return this.context.start + this.context.buffer.buffer[this.index + 1];
|
|
388
|
+
}
|
|
389
|
+
get to() {
|
|
390
|
+
return this.context.start + this.context.buffer.buffer[this.index + 2];
|
|
391
|
+
}
|
|
392
|
+
constructor(e, t, n) {
|
|
393
|
+
super(), this.context = e, this._parent = t, this.index = n, this.type = e.buffer.set.types[e.buffer.buffer[n]];
|
|
394
|
+
}
|
|
395
|
+
child(t, n, r) {
|
|
396
|
+
let { buffer: i } = this.context, a = i.findChild(this.index + 4, i.buffer[this.index + 3], t, n - this.context.start, r);
|
|
397
|
+
return a < 0 ? null : new e(this.context, this, a);
|
|
398
|
+
}
|
|
399
|
+
get firstChild() {
|
|
400
|
+
return this.child(1, 0, 4);
|
|
401
|
+
}
|
|
402
|
+
get lastChild() {
|
|
403
|
+
return this.child(-1, 0, 4);
|
|
404
|
+
}
|
|
405
|
+
childAfter(e) {
|
|
406
|
+
return this.child(1, e, 2);
|
|
407
|
+
}
|
|
408
|
+
childBefore(e) {
|
|
409
|
+
return this.child(-1, e, -2);
|
|
410
|
+
}
|
|
411
|
+
prop(e) {
|
|
412
|
+
return this.type.prop(e);
|
|
413
|
+
}
|
|
414
|
+
enter(t, n, r = 0) {
|
|
415
|
+
if (r & P.ExcludeBuffers) return null;
|
|
416
|
+
let { buffer: i } = this.context, a = i.findChild(this.index + 4, i.buffer[this.index + 3], n > 0 ? 1 : -1, t - this.context.start, n);
|
|
417
|
+
return a < 0 ? null : new e(this.context, this, a);
|
|
418
|
+
}
|
|
419
|
+
get parent() {
|
|
420
|
+
return this._parent || this.context.parent.nextSignificantParent();
|
|
421
|
+
}
|
|
422
|
+
externalSibling(e) {
|
|
423
|
+
return this._parent ? null : this.context.parent.nextChild(this.context.index + e, e, 0, 4);
|
|
424
|
+
}
|
|
425
|
+
get nextSibling() {
|
|
426
|
+
let { buffer: t } = this.context, n = t.buffer[this.index + 3];
|
|
427
|
+
return n < (this._parent ? t.buffer[this._parent.index + 3] : t.buffer.length) ? new e(this.context, this._parent, n) : this.externalSibling(1);
|
|
428
|
+
}
|
|
429
|
+
get prevSibling() {
|
|
430
|
+
let { buffer: t } = this.context, n = this._parent ? this._parent.index + 4 : 0;
|
|
431
|
+
return this.index == n ? this.externalSibling(-1) : new e(this.context, this._parent, t.findChild(n, this.index, -1, 0, 4));
|
|
432
|
+
}
|
|
433
|
+
get tree() {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
toTree() {
|
|
437
|
+
let e = [], t = [], { buffer: n } = this.context, r = this.index + 4, i = n.buffer[this.index + 3];
|
|
438
|
+
if (i > r) {
|
|
439
|
+
let a = n.buffer[this.index + 1];
|
|
440
|
+
e.push(n.slice(r, i, a)), t.push(0);
|
|
441
|
+
}
|
|
442
|
+
return new F(this.type, e, t, this.to - this.from);
|
|
443
|
+
}
|
|
444
|
+
toString() {
|
|
445
|
+
return this.context.buffer.childString(this.index);
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
function ne(e) {
|
|
449
|
+
if (!e.length) return null;
|
|
450
|
+
let t = 0, n = e[0];
|
|
451
|
+
for (let r = 1; r < e.length; r++) {
|
|
452
|
+
let i = e[r];
|
|
453
|
+
(i.from > n.from || i.to < n.to) && (n = i, t = r);
|
|
454
|
+
}
|
|
455
|
+
let r = n instanceof B && n.index < 0 ? null : n.parent, i = e.slice();
|
|
456
|
+
return r ? i[t] = r : i.splice(t, 1), new re(i, n);
|
|
457
|
+
}
|
|
458
|
+
var re = class {
|
|
459
|
+
constructor(e, t) {
|
|
460
|
+
this.heads = e, this.node = t;
|
|
461
|
+
}
|
|
462
|
+
get next() {
|
|
463
|
+
return ne(this.heads);
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
function ie(e, t, n) {
|
|
467
|
+
let r = e.resolveInner(t, n), i = null;
|
|
468
|
+
for (let e = r instanceof B ? r : r.context.parent; e; e = e.parent) if (e.index < 0) {
|
|
469
|
+
let a = e.parent;
|
|
470
|
+
(i ||= [r]).push(a.resolve(t, n)), e = a;
|
|
471
|
+
} else {
|
|
472
|
+
let a = k.get(e.tree);
|
|
473
|
+
if (a && a.overlay && a.overlay[0].from <= t && a.overlay[a.overlay.length - 1].to >= t) {
|
|
474
|
+
let o = new B(a.tree, a.overlay[0].from + e.from, -1, e);
|
|
475
|
+
(i ||= [r]).push(R(o, t, n, !1));
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return i ? ne(i) : r;
|
|
479
|
+
}
|
|
480
|
+
var W = class {
|
|
481
|
+
get name() {
|
|
482
|
+
return this.type.name;
|
|
483
|
+
}
|
|
484
|
+
constructor(e, t = 0) {
|
|
485
|
+
if (this.buffer = null, this.stack = [], this.index = 0, this.bufferNode = null, this.mode = t & ~P.EnterBracketed, e instanceof B) this.yieldNode(e);
|
|
486
|
+
else {
|
|
487
|
+
this._tree = e.context.parent, this.buffer = e.context;
|
|
488
|
+
for (let t = e._parent; t; t = t._parent) this.stack.unshift(t.index);
|
|
489
|
+
this.bufferNode = e, this.yieldBuf(e.index);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
yieldNode(e) {
|
|
493
|
+
return e ? (this._tree = e, this.type = e.type, this.from = e.from, this.to = e.to, !0) : !1;
|
|
494
|
+
}
|
|
495
|
+
yieldBuf(e, t) {
|
|
496
|
+
this.index = e;
|
|
497
|
+
let { start: n, buffer: r } = this.buffer;
|
|
498
|
+
return this.type = t || r.set.types[r.buffer[e]], this.from = n + r.buffer[e + 1], this.to = n + r.buffer[e + 2], !0;
|
|
499
|
+
}
|
|
500
|
+
yield(e) {
|
|
501
|
+
return e ? e instanceof B ? (this.buffer = null, this.yieldNode(e)) : (this.buffer = e.context, this.yieldBuf(e.index, e.type)) : !1;
|
|
502
|
+
}
|
|
503
|
+
toString() {
|
|
504
|
+
return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
|
|
505
|
+
}
|
|
506
|
+
enterChild(e, t, n) {
|
|
507
|
+
if (!this.buffer) return this.yield(this._tree.nextChild(e < 0 ? this._tree._tree.children.length - 1 : 0, e, t, n, this.mode));
|
|
508
|
+
let { buffer: r } = this.buffer, i = r.findChild(this.index + 4, r.buffer[this.index + 3], e, t - this.buffer.start, n);
|
|
509
|
+
return i < 0 ? !1 : (this.stack.push(this.index), this.yieldBuf(i));
|
|
510
|
+
}
|
|
511
|
+
firstChild() {
|
|
512
|
+
return this.enterChild(1, 0, 4);
|
|
513
|
+
}
|
|
514
|
+
lastChild() {
|
|
515
|
+
return this.enterChild(-1, 0, 4);
|
|
516
|
+
}
|
|
517
|
+
childAfter(e) {
|
|
518
|
+
return this.enterChild(1, e, 2);
|
|
519
|
+
}
|
|
520
|
+
childBefore(e) {
|
|
521
|
+
return this.enterChild(-1, e, -2);
|
|
522
|
+
}
|
|
523
|
+
enter(e, t, n = this.mode) {
|
|
524
|
+
return this.buffer ? n & P.ExcludeBuffers ? !1 : this.enterChild(1, e, t) : this.yield(this._tree.enter(e, t, n));
|
|
525
|
+
}
|
|
526
|
+
parent() {
|
|
527
|
+
if (!this.buffer) return this.yieldNode(this.mode & P.IncludeAnonymous ? this._tree._parent : this._tree.parent);
|
|
528
|
+
if (this.stack.length) return this.yieldBuf(this.stack.pop());
|
|
529
|
+
let e = this.mode & P.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
|
|
530
|
+
return this.buffer = null, this.yieldNode(e);
|
|
531
|
+
}
|
|
532
|
+
sibling(e) {
|
|
533
|
+
if (!this.buffer) return this._tree._parent ? this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + e, e, 0, 4, this.mode)) : !1;
|
|
534
|
+
let { buffer: t } = this.buffer, n = this.stack.length - 1;
|
|
535
|
+
if (e < 0) {
|
|
536
|
+
let e = n < 0 ? 0 : this.stack[n] + 4;
|
|
537
|
+
if (this.index != e) return this.yieldBuf(t.findChild(e, this.index, -1, 0, 4));
|
|
538
|
+
} else {
|
|
539
|
+
let e = t.buffer[this.index + 3];
|
|
540
|
+
if (e < (n < 0 ? t.buffer.length : t.buffer[this.stack[n] + 3])) return this.yieldBuf(e);
|
|
541
|
+
}
|
|
542
|
+
return n < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + e, e, 0, 4, this.mode)) : !1;
|
|
543
|
+
}
|
|
544
|
+
nextSibling() {
|
|
545
|
+
return this.sibling(1);
|
|
546
|
+
}
|
|
547
|
+
prevSibling() {
|
|
548
|
+
return this.sibling(-1);
|
|
549
|
+
}
|
|
550
|
+
atLastNode(e) {
|
|
551
|
+
let t, n, { buffer: r } = this;
|
|
552
|
+
if (r) {
|
|
553
|
+
if (e > 0) {
|
|
554
|
+
if (this.index < r.buffer.buffer.length) return !1;
|
|
555
|
+
} else for (let e = 0; e < this.index; e++) if (r.buffer.buffer[e + 3] < this.index) return !1;
|
|
556
|
+
({index: t, parent: n} = r);
|
|
557
|
+
} else ({index: t, _parent: n} = this._tree);
|
|
558
|
+
for (; n; {index: t, _parent: n} = n) if (t > -1) for (let r = t + e, i = e < 0 ? -1 : n._tree.children.length; r != i; r += e) {
|
|
559
|
+
let e = n._tree.children[r];
|
|
560
|
+
if (this.mode & P.IncludeAnonymous || e instanceof I || !e.type.isAnonymous || G(e)) return !1;
|
|
561
|
+
}
|
|
562
|
+
return !0;
|
|
563
|
+
}
|
|
564
|
+
move(e, t) {
|
|
565
|
+
if (t && this.enterChild(e, 0, 4)) return !0;
|
|
566
|
+
for (;;) {
|
|
567
|
+
if (this.sibling(e)) return !0;
|
|
568
|
+
if (this.atLastNode(e) || !this.parent()) return !1;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
next(e = !0) {
|
|
572
|
+
return this.move(1, e);
|
|
573
|
+
}
|
|
574
|
+
prev(e = !0) {
|
|
575
|
+
return this.move(-1, e);
|
|
576
|
+
}
|
|
577
|
+
moveTo(e, t = 0) {
|
|
578
|
+
for (; (this.from == this.to || (t < 1 ? this.from >= e : this.from > e) || (t > -1 ? this.to <= e : this.to < e)) && this.parent(););
|
|
579
|
+
for (; this.enterChild(1, e, t););
|
|
580
|
+
return this;
|
|
581
|
+
}
|
|
582
|
+
get node() {
|
|
583
|
+
if (!this.buffer) return this._tree;
|
|
584
|
+
let e = this.bufferNode, t = null, n = 0;
|
|
585
|
+
if (e && e.context == this.buffer) scan: for (let r = this.index, i = this.stack.length; i >= 0;) {
|
|
586
|
+
for (let a = e; a; a = a._parent) if (a.index == r) {
|
|
587
|
+
if (r == this.index) return a;
|
|
588
|
+
t = a, n = i + 1;
|
|
589
|
+
break scan;
|
|
590
|
+
}
|
|
591
|
+
r = this.stack[--i];
|
|
592
|
+
}
|
|
593
|
+
for (let e = n; e < this.stack.length; e++) t = new U(this.buffer, t, this.stack[e]);
|
|
594
|
+
return this.bufferNode = new U(this.buffer, t, this.index);
|
|
595
|
+
}
|
|
596
|
+
get tree() {
|
|
597
|
+
return this.buffer ? null : this._tree._tree;
|
|
598
|
+
}
|
|
599
|
+
iterate(e, t) {
|
|
600
|
+
for (let n = 0;;) {
|
|
601
|
+
let r = !1;
|
|
602
|
+
if (this.type.isAnonymous || e(this) !== !1) {
|
|
603
|
+
if (this.firstChild()) {
|
|
604
|
+
n++;
|
|
605
|
+
continue;
|
|
606
|
+
}
|
|
607
|
+
this.type.isAnonymous || (r = !0);
|
|
608
|
+
}
|
|
609
|
+
for (;;) {
|
|
610
|
+
if (r && t && t(this), r = this.type.isAnonymous, !n) return;
|
|
611
|
+
if (this.nextSibling()) break;
|
|
612
|
+
this.parent(), n--, r = !0;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
matchContext(e) {
|
|
617
|
+
if (!this.buffer) return H(this.node.parent, e);
|
|
618
|
+
let { buffer: t } = this.buffer, { types: n } = t.set;
|
|
619
|
+
for (let r = e.length - 1, i = this.stack.length - 1; r >= 0; i--) {
|
|
620
|
+
if (i < 0) return H(this._tree, e, r);
|
|
621
|
+
let a = n[t.buffer[this.stack[i]]];
|
|
622
|
+
if (!a.isAnonymous) {
|
|
623
|
+
if (e[r] && e[r] != a.name) return !1;
|
|
624
|
+
r--;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return !0;
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
function G(e) {
|
|
631
|
+
return e.children.some((e) => e instanceof I || !e.type.isAnonymous || G(e));
|
|
632
|
+
}
|
|
633
|
+
function ae(e) {
|
|
634
|
+
let { buffer: t, nodeSet: n, maxBufferLength: r = E, reused: i = [], minRepeatType: a = n.types.length } = e, o = Array.isArray(t) ? new ee(t, t.length) : t, s = n.types, c = 0, l = 0;
|
|
635
|
+
function u(e, t, _, v, y, b) {
|
|
636
|
+
let { id: x, start: S, end: C, size: w } = o, T = l, E = c;
|
|
637
|
+
if (w < 0) if (o.next(), w == -1) {
|
|
638
|
+
let t = i[x];
|
|
639
|
+
_.push(t), v.push(S - e);
|
|
640
|
+
return;
|
|
641
|
+
} else if (w == -3) {
|
|
642
|
+
c = x;
|
|
643
|
+
return;
|
|
644
|
+
} else if (w == -4) {
|
|
645
|
+
l = x;
|
|
646
|
+
return;
|
|
647
|
+
} else throw RangeError(`Unrecognized record size: ${w}`);
|
|
648
|
+
let D = s[x], O, k, A = S - e;
|
|
649
|
+
if (C - S <= r && (k = h(o.pos - t, y))) {
|
|
650
|
+
let t = new Uint16Array(k.size - k.skip), r = o.pos - k.size, i = t.length;
|
|
651
|
+
for (; o.pos > r;) i = g(k.start, t, i);
|
|
652
|
+
O = new I(t, C - k.start, n), A = k.start - e;
|
|
653
|
+
} else {
|
|
654
|
+
let e = o.pos - w;
|
|
655
|
+
o.next();
|
|
656
|
+
let t = [], n = [], i = x >= a ? x : -1, s = 0, c = C;
|
|
657
|
+
for (; o.pos > e;) i >= 0 && o.id == i && o.size >= 0 ? (o.end <= c - r && (p(t, n, S, s, o.end, c, i, T, E), s = t.length, c = o.end), o.next()) : b > 2500 ? d(S, e, t, n) : u(S, e, t, n, i, b + 1);
|
|
658
|
+
if (i >= 0 && s > 0 && s < t.length && p(t, n, S, s, S, c, i, T, E), t.reverse(), n.reverse(), i > -1 && s > 0) {
|
|
659
|
+
let e = f(D, E);
|
|
660
|
+
O = J(D, t, n, 0, t.length, 0, C - S, e, e);
|
|
661
|
+
} else O = m(D, t, n, C - S, T - C, E);
|
|
662
|
+
}
|
|
663
|
+
_.push(O), v.push(A);
|
|
664
|
+
}
|
|
665
|
+
function d(e, t, i, a) {
|
|
666
|
+
let s = [], c = 0, l = -1;
|
|
667
|
+
for (; o.pos > t;) {
|
|
668
|
+
let { id: e, start: t, end: n, size: i } = o;
|
|
669
|
+
if (i > 4) o.next();
|
|
670
|
+
else if (l > -1 && t < l) break;
|
|
671
|
+
else l < 0 && (l = n - r), s.push(e, t, n), c++, o.next();
|
|
672
|
+
}
|
|
673
|
+
if (c) {
|
|
674
|
+
let t = new Uint16Array(c * 4), r = s[s.length - 2];
|
|
675
|
+
for (let e = s.length - 3, n = 0; e >= 0; e -= 3) t[n++] = s[e], t[n++] = s[e + 1] - r, t[n++] = s[e + 2] - r, t[n++] = n;
|
|
676
|
+
i.push(new I(t, s[2] - r, n)), a.push(r - e);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
function f(e, t) {
|
|
680
|
+
return (n, r, i) => {
|
|
681
|
+
let a = 0, o = n.length - 1, s, c;
|
|
682
|
+
if (o >= 0 && (s = n[o]) instanceof F) {
|
|
683
|
+
if (!o && s.type == e && s.length == i) return s;
|
|
684
|
+
(c = s.prop(O.lookAhead)) && (a = r[o] + s.length + c);
|
|
685
|
+
}
|
|
686
|
+
return m(e, n, r, i, a, t);
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
function p(e, t, r, i, a, o, s, c, l) {
|
|
690
|
+
let u = [], d = [];
|
|
691
|
+
for (; e.length > i;) u.push(e.pop()), d.push(t.pop() + r - a);
|
|
692
|
+
e.push(m(n.types[s], u, d, o - a, c - o, l)), t.push(a - r);
|
|
693
|
+
}
|
|
694
|
+
function m(e, t, n, r, i, a, o) {
|
|
695
|
+
if (a) {
|
|
696
|
+
let e = [O.contextHash, a];
|
|
697
|
+
o = o ? [e].concat(o) : [e];
|
|
698
|
+
}
|
|
699
|
+
if (i > 25) {
|
|
700
|
+
let e = [O.lookAhead, i];
|
|
701
|
+
o = o ? [e].concat(o) : [e];
|
|
702
|
+
}
|
|
703
|
+
return new F(e, t, n, r, o);
|
|
704
|
+
}
|
|
705
|
+
function h(e, t) {
|
|
706
|
+
let n = o.fork(), i = 0, s = 0, c = 0, l = n.end - r, u = {
|
|
707
|
+
size: 0,
|
|
708
|
+
start: 0,
|
|
709
|
+
skip: 0
|
|
710
|
+
};
|
|
711
|
+
scan: for (let r = n.pos - e; n.pos > r;) {
|
|
712
|
+
let e = n.size;
|
|
713
|
+
if (n.id == t && e >= 0) {
|
|
714
|
+
u.size = i, u.start = s, u.skip = c, c += 4, i += 4, n.next();
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
717
|
+
let o = n.pos - e;
|
|
718
|
+
if (e < 0 || o < r || n.start < l) break;
|
|
719
|
+
let d = n.id >= a ? 4 : 0, f = n.start;
|
|
720
|
+
for (n.next(); n.pos > o;) {
|
|
721
|
+
if (n.size < 0) if (n.size == -3 || n.size == -4) d += 4;
|
|
722
|
+
else break scan;
|
|
723
|
+
else n.id >= a && (d += 4);
|
|
724
|
+
n.next();
|
|
725
|
+
}
|
|
726
|
+
s = f, i += e, c += d;
|
|
727
|
+
}
|
|
728
|
+
return (t < 0 || i == e) && (u.size = i, u.start = s, u.skip = c), u.size > 4 ? u : void 0;
|
|
729
|
+
}
|
|
730
|
+
function g(e, t, n) {
|
|
731
|
+
let { id: r, start: i, end: s, size: u } = o;
|
|
732
|
+
if (o.next(), u >= 0 && r < a) {
|
|
733
|
+
let a = n;
|
|
734
|
+
if (u > 4) {
|
|
735
|
+
let r = o.pos - (u - 4);
|
|
736
|
+
for (; o.pos > r;) n = g(e, t, n);
|
|
737
|
+
}
|
|
738
|
+
t[--n] = a, t[--n] = s - e, t[--n] = i - e, t[--n] = r;
|
|
739
|
+
} else u == -3 ? c = r : u == -4 && (l = r);
|
|
740
|
+
return n;
|
|
741
|
+
}
|
|
742
|
+
let _ = [], v = [];
|
|
743
|
+
for (; o.pos > 0;) u(e.start || 0, e.bufferStart || 0, _, v, -1, 0);
|
|
744
|
+
let y = e.length ?? (_.length ? v[0] + _[0].length : 0);
|
|
745
|
+
return new F(s[e.topID], _.reverse(), v.reverse(), y);
|
|
746
|
+
}
|
|
747
|
+
var K = /* @__PURE__ */ new WeakMap();
|
|
748
|
+
function q(e, t) {
|
|
749
|
+
if (!e.isAnonymous || t instanceof I || t.type != e) return 1;
|
|
750
|
+
let n = K.get(t);
|
|
751
|
+
if (n == null) {
|
|
752
|
+
n = 1;
|
|
753
|
+
for (let r of t.children) {
|
|
754
|
+
if (r.type != e || !(r instanceof F)) {
|
|
755
|
+
n = 1;
|
|
756
|
+
break;
|
|
757
|
+
}
|
|
758
|
+
n += q(e, r);
|
|
759
|
+
}
|
|
760
|
+
K.set(t, n);
|
|
761
|
+
}
|
|
762
|
+
return n;
|
|
763
|
+
}
|
|
764
|
+
function J(e, t, n, r, i, a, o, s, c) {
|
|
765
|
+
let l = 0;
|
|
766
|
+
for (let n = r; n < i; n++) l += q(e, t[n]);
|
|
767
|
+
let u = Math.ceil(l * 1.5 / 8), d = [], f = [];
|
|
768
|
+
function p(t, n, r, i, o) {
|
|
769
|
+
for (let s = r; s < i;) {
|
|
770
|
+
let r = s, l = n[s], m = q(e, t[s]);
|
|
771
|
+
for (s++; s < i; s++) {
|
|
772
|
+
let n = q(e, t[s]);
|
|
773
|
+
if (m + n >= u) break;
|
|
774
|
+
m += n;
|
|
775
|
+
}
|
|
776
|
+
if (s == r + 1) {
|
|
777
|
+
if (m > u) {
|
|
778
|
+
let e = t[r];
|
|
779
|
+
p(e.children, e.positions, 0, e.children.length, n[r] + o);
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
d.push(t[r]);
|
|
783
|
+
} else {
|
|
784
|
+
let i = n[s - 1] + t[s - 1].length - l;
|
|
785
|
+
d.push(J(e, t, n, r, s, l, i, null, c));
|
|
786
|
+
}
|
|
787
|
+
f.push(l + o - a);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return p(t, n, r, i, 0), (s || c)(d, f, o);
|
|
791
|
+
}
|
|
792
|
+
new O({ perNode: !0 });
|
|
793
|
+
//#endregion
|
|
794
|
+
//#region node_modules/@codemirror/commands/dist/index.js
|
|
795
|
+
var Y = /* @__PURE__ */ a.define(), oe = /* @__PURE__ */ u.define(), X = class e {
|
|
796
|
+
constructor(e, t, n, r, i) {
|
|
797
|
+
this.changes = e, this.effects = t, this.mapped = n, this.startSelection = r, this.selectionsAfter = i;
|
|
798
|
+
}
|
|
799
|
+
setSelAfter(t) {
|
|
800
|
+
return new e(this.changes, this.effects, this.mapped, this.startSelection, t);
|
|
801
|
+
}
|
|
802
|
+
toJSON() {
|
|
803
|
+
return {
|
|
804
|
+
changes: this.changes?.toJSON(),
|
|
805
|
+
mapped: this.mapped?.toJSON(),
|
|
806
|
+
startSelection: this.startSelection?.toJSON(),
|
|
807
|
+
selectionsAfter: this.selectionsAfter.map((e) => e.toJSON())
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
static fromJSON(t) {
|
|
811
|
+
return new e(t.changes && s.fromJSON(t.changes), [], t.mapped && o.fromJSON(t.mapped), t.startSelection && c.fromJSON(t.startSelection), t.selectionsAfter.map(c.fromJSON));
|
|
812
|
+
}
|
|
813
|
+
static fromTransaction(t, n) {
|
|
814
|
+
let r = Q;
|
|
815
|
+
for (let e of t.startState.facet(oe)) {
|
|
816
|
+
let n = e(t);
|
|
817
|
+
n.length && (r = r.concat(n));
|
|
818
|
+
}
|
|
819
|
+
return !r.length && t.changes.empty ? null : new e(t.changes.invert(t.startState.doc), r, void 0, n || t.startState.selection, Q);
|
|
820
|
+
}
|
|
821
|
+
static selection(t) {
|
|
822
|
+
return new e(void 0, Q, void 0, void 0, t);
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
function Z(e, t, n, r) {
|
|
826
|
+
let i = t + 1 > n + 20 ? t - n - 1 : 0, a = e.slice(i, t);
|
|
827
|
+
return a.push(r), a;
|
|
828
|
+
}
|
|
829
|
+
function se(e, t) {
|
|
830
|
+
let n = [], r = !1;
|
|
831
|
+
return e.iterChangedRanges((e, t) => n.push(e, t)), t.iterChangedRanges((e, t, i, a) => {
|
|
832
|
+
for (let e = 0; e < n.length;) {
|
|
833
|
+
let t = n[e++], o = n[e++];
|
|
834
|
+
a >= t && i <= o && (r = !0);
|
|
835
|
+
}
|
|
836
|
+
}), r;
|
|
837
|
+
}
|
|
838
|
+
function ce(e, t) {
|
|
839
|
+
return e.ranges.length == t.ranges.length && e.ranges.filter((e, n) => e.empty != t.ranges[n].empty).length === 0;
|
|
840
|
+
}
|
|
841
|
+
function le(e, t) {
|
|
842
|
+
return e.length ? t.length ? e.concat(t) : e : t;
|
|
843
|
+
}
|
|
844
|
+
var Q = [], ue = 200;
|
|
845
|
+
function de(e, t) {
|
|
846
|
+
if (e.length) {
|
|
847
|
+
let n = e[e.length - 1], r = n.selectionsAfter.slice(Math.max(0, n.selectionsAfter.length - ue));
|
|
848
|
+
return r.length && r[r.length - 1].eq(t) ? e : (r.push(t), Z(e, e.length - 1, 1e9, n.setSelAfter(r)));
|
|
849
|
+
} else return [X.selection([t])];
|
|
850
|
+
}
|
|
851
|
+
function fe(e) {
|
|
852
|
+
let t = e[e.length - 1], n = e.slice();
|
|
853
|
+
return n[e.length - 1] = t.setSelAfter(t.selectionsAfter.slice(0, t.selectionsAfter.length - 1)), n;
|
|
39
854
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const T = /* @__PURE__ */ Object.create(null);
|
|
52
|
-
class p {
|
|
53
|
-
/**
|
|
54
|
-
@internal
|
|
55
|
-
*/
|
|
56
|
-
constructor(e, o, i, n = 0) {
|
|
57
|
-
this.name = e, this.props = o, this.id = i, this.flags = n;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
Define a node type.
|
|
61
|
-
*/
|
|
62
|
-
static define(e) {
|
|
63
|
-
let o = e.props && e.props.length ? /* @__PURE__ */ Object.create(null) : T, i = (e.top ? 1 : 0) | (e.skipped ? 2 : 0) | (e.error ? 4 : 0) | (e.name == null ? 8 : 0), n = new p(e.name || "", o, e.id, i);
|
|
64
|
-
if (e.props) {
|
|
65
|
-
for (let r of e.props)
|
|
66
|
-
if (Array.isArray(r) || (r = r(n)), r) {
|
|
67
|
-
if (r[0].perNode)
|
|
68
|
-
throw new RangeError("Can't store a per-node prop on a node type");
|
|
69
|
-
o[r[0].id] = r[1];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return n;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
Retrieves a node prop for this type. Will return `undefined` if
|
|
76
|
-
the prop isn't present on this node.
|
|
77
|
-
*/
|
|
78
|
-
prop(e) {
|
|
79
|
-
return this.props[e.id];
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
True when this is the top node of a grammar.
|
|
83
|
-
*/
|
|
84
|
-
get isTop() {
|
|
85
|
-
return (this.flags & 1) > 0;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
True when this node is produced by a skip rule.
|
|
89
|
-
*/
|
|
90
|
-
get isSkipped() {
|
|
91
|
-
return (this.flags & 2) > 0;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
Indicates whether this is an error node.
|
|
95
|
-
*/
|
|
96
|
-
get isError() {
|
|
97
|
-
return (this.flags & 4) > 0;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
When true, this node type doesn't correspond to a user-declared
|
|
101
|
-
named node, for example because it is used to cache repetition.
|
|
102
|
-
*/
|
|
103
|
-
get isAnonymous() {
|
|
104
|
-
return (this.flags & 8) > 0;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
Returns true when this node's name or one of its
|
|
108
|
-
[groups](#common.NodeProp^group) matches the given string.
|
|
109
|
-
*/
|
|
110
|
-
is(e) {
|
|
111
|
-
if (typeof e == "string") {
|
|
112
|
-
if (this.name == e)
|
|
113
|
-
return !0;
|
|
114
|
-
let o = this.prop(s.group);
|
|
115
|
-
return o ? o.indexOf(e) > -1 : !1;
|
|
116
|
-
}
|
|
117
|
-
return this.id == e;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
Create a function from node types to arbitrary values by
|
|
121
|
-
specifying an object whose property names are node or
|
|
122
|
-
[group](#common.NodeProp^group) names. Often useful with
|
|
123
|
-
[`NodeProp.add`](#common.NodeProp.add). You can put multiple
|
|
124
|
-
names, separated by spaces, in a single property name to map
|
|
125
|
-
multiple node names to a single value.
|
|
126
|
-
*/
|
|
127
|
-
static match(e) {
|
|
128
|
-
let o = /* @__PURE__ */ Object.create(null);
|
|
129
|
-
for (let i in e)
|
|
130
|
-
for (let n of i.split(" "))
|
|
131
|
-
o[n] = e[i];
|
|
132
|
-
return (i) => {
|
|
133
|
-
for (let n = i.prop(s.group), r = -1; r < (n ? n.length : 0); r++) {
|
|
134
|
-
let a = o[r < 0 ? i.name : n[r]];
|
|
135
|
-
if (a)
|
|
136
|
-
return a;
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}
|
|
855
|
+
function $(e, t) {
|
|
856
|
+
if (!e.length) return e;
|
|
857
|
+
let n = e.length, r = Q;
|
|
858
|
+
for (; n;) {
|
|
859
|
+
let i = pe(e[n - 1], t, r);
|
|
860
|
+
if (i.changes && !i.changes.empty || i.effects.length) {
|
|
861
|
+
let t = e.slice(0, n);
|
|
862
|
+
return t[n - 1] = i, t;
|
|
863
|
+
} else t = i.mapped, n--, r = i.selectionsAfter;
|
|
864
|
+
}
|
|
865
|
+
return r.length ? [X.selection(r)] : Q;
|
|
140
866
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
/* NodeFlag.Anonymous */
|
|
147
|
-
);
|
|
148
|
-
var h;
|
|
149
|
-
(function(t) {
|
|
150
|
-
t[t.ExcludeBuffers = 1] = "ExcludeBuffers", t[t.IncludeAnonymous = 2] = "IncludeAnonymous", t[t.IgnoreMounts = 4] = "IgnoreMounts", t[t.IgnoreOverlays = 8] = "IgnoreOverlays", t[t.EnterBracketed = 16] = "EnterBracketed";
|
|
151
|
-
})(h || (h = {}));
|
|
152
|
-
new s({ perNode: !0 });
|
|
153
|
-
function q(t, e) {
|
|
154
|
-
let o = -1;
|
|
155
|
-
return t.changeByRange((i) => {
|
|
156
|
-
let n = [];
|
|
157
|
-
for (let a = i.from; a <= i.to; ) {
|
|
158
|
-
let l = t.doc.lineAt(a);
|
|
159
|
-
l.number > o && (i.empty || i.to > l.from) && (e(l, n, i), o = l.number), a = l.to + 1;
|
|
160
|
-
}
|
|
161
|
-
let r = t.changes(n);
|
|
162
|
-
return {
|
|
163
|
-
changes: n,
|
|
164
|
-
range: E.range(r.mapPos(i.anchor, 1), r.mapPos(i.head, 1))
|
|
165
|
-
};
|
|
166
|
-
});
|
|
867
|
+
function pe(e, t, n) {
|
|
868
|
+
let r = le(e.selectionsAfter.length ? e.selectionsAfter.map((e) => e.map(t)) : Q, n);
|
|
869
|
+
if (!e.changes) return X.selection(r);
|
|
870
|
+
let i = e.changes.map(t), a = t.mapDesc(e.changes, !0), o = e.mapped ? e.mapped.composeDesc(a) : a;
|
|
871
|
+
return new X(i, d.mapEffects(e.effects, t), o, e.startSelection.map(a), r);
|
|
167
872
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
873
|
+
var me = /^(input\.type|delete)($|\.)/, he = class e {
|
|
874
|
+
constructor(e, t, n = 0, r = void 0) {
|
|
875
|
+
this.done = e, this.undone = t, this.prevTime = n, this.prevUserEvent = r;
|
|
876
|
+
}
|
|
877
|
+
isolate() {
|
|
878
|
+
return this.prevTime ? new e(this.done, this.undone) : this;
|
|
879
|
+
}
|
|
880
|
+
addChanges(t, n, r, i, a) {
|
|
881
|
+
let o = this.done, s = o[o.length - 1];
|
|
882
|
+
return o = s && s.changes && !s.changes.empty && t.changes && (!r || me.test(r)) && (!s.selectionsAfter.length && n - this.prevTime < i.newGroupDelay && i.joinToEvent(a, se(s.changes, t.changes)) || r == "input.type.compose") ? Z(o, o.length - 1, i.minDepth, new X(t.changes.compose(s.changes), le(d.mapEffects(t.effects, s.changes), s.effects), s.mapped, s.startSelection, Q)) : Z(o, o.length, i.minDepth, t), new e(o, Q, n, r);
|
|
883
|
+
}
|
|
884
|
+
addSelection(t, n, r, i) {
|
|
885
|
+
let a = this.done.length ? this.done[this.done.length - 1].selectionsAfter : Q;
|
|
886
|
+
return a.length > 0 && n - this.prevTime < i && r == this.prevUserEvent && r && /^select($|\.)/.test(r) && ce(a[a.length - 1], t) ? this : new e(de(this.done, t), this.undone, n, r);
|
|
887
|
+
}
|
|
888
|
+
addMapping(t) {
|
|
889
|
+
return new e($(this.done, t), $(this.undone, t), this.prevTime, this.prevUserEvent);
|
|
890
|
+
}
|
|
891
|
+
pop(e, t, n) {
|
|
892
|
+
let r = e == 0 ? this.done : this.undone;
|
|
893
|
+
if (r.length == 0) return null;
|
|
894
|
+
let i = r[r.length - 1], a = i.selectionsAfter[0] || (i.startSelection ? i.startSelection.map(i.changes.invertedDesc, 1) : t.selection);
|
|
895
|
+
if (n && i.selectionsAfter.length) return t.update({
|
|
896
|
+
selection: i.selectionsAfter[i.selectionsAfter.length - 1],
|
|
897
|
+
annotations: Y.of({
|
|
898
|
+
side: e,
|
|
899
|
+
rest: fe(r),
|
|
900
|
+
selection: a
|
|
901
|
+
}),
|
|
902
|
+
userEvent: e == 0 ? "select.undo" : "select.redo",
|
|
903
|
+
scrollIntoView: !0
|
|
904
|
+
});
|
|
905
|
+
if (i.changes) {
|
|
906
|
+
let n = r.length == 1 ? Q : r.slice(0, r.length - 1);
|
|
907
|
+
return i.mapped && (n = $(n, i.mapped)), t.update({
|
|
908
|
+
changes: i.changes,
|
|
909
|
+
selection: i.startSelection,
|
|
910
|
+
effects: i.effects,
|
|
911
|
+
annotations: Y.of({
|
|
912
|
+
side: e,
|
|
913
|
+
rest: n,
|
|
914
|
+
selection: a
|
|
915
|
+
}),
|
|
916
|
+
filter: !1,
|
|
917
|
+
userEvent: e == 0 ? "undo" : "redo",
|
|
918
|
+
scrollIntoView: !0
|
|
919
|
+
});
|
|
920
|
+
} else return null;
|
|
921
|
+
}
|
|
183
922
|
};
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
P,
|
|
200
|
-
z,
|
|
201
|
-
D,
|
|
202
|
-
L,
|
|
203
|
-
j
|
|
204
|
-
],
|
|
205
|
-
tabWidth: 4,
|
|
206
|
-
useTabs: !1
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
// Listen to SourceEditing mode changes
|
|
210
|
-
afterInit() {
|
|
211
|
-
const o = this.editor.plugins.get("SourceEditing");
|
|
212
|
-
this.listenTo(o, "change:isSourceEditingMode", async (i, n, r) => {
|
|
213
|
-
r ? await this.enableCodeMirror() : this.disableCodeMirror();
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
// Enable CodeMirror with Prettier formatting
|
|
217
|
-
async enableCodeMirror() {
|
|
218
|
-
const e = this.editor;
|
|
219
|
-
e.plugins.get("SourceEditing").updateEditorData();
|
|
220
|
-
const i = await this.formatWithPrettier(e.getData()), n = document.querySelector(".ck-source-editing-area");
|
|
221
|
-
if (!n)
|
|
222
|
-
return;
|
|
223
|
-
const r = n.querySelector("textarea");
|
|
224
|
-
r && (r.style.display = "none");
|
|
225
|
-
const a = document.createElement("div");
|
|
226
|
-
a.classList.add("cm-wrapper"), n.appendChild(a);
|
|
227
|
-
const l = [
|
|
228
|
-
m(),
|
|
229
|
-
w(),
|
|
230
|
-
y(),
|
|
231
|
-
N(O),
|
|
232
|
-
A(),
|
|
233
|
-
k.of(" ")
|
|
234
|
-
], u = e.config.get("sourceEditingCodeMirror")?.extensions ?? [];
|
|
235
|
-
this.view = new f({
|
|
236
|
-
state: x.create({
|
|
237
|
-
doc: i,
|
|
238
|
-
extensions: [
|
|
239
|
-
...l,
|
|
240
|
-
S(),
|
|
241
|
-
...u,
|
|
242
|
-
f.updateListener.of((c) => {
|
|
243
|
-
c.docChanged && e.setData(c.state.doc.toString());
|
|
244
|
-
})
|
|
245
|
-
]
|
|
246
|
-
}),
|
|
247
|
-
parent: a
|
|
248
|
-
}), this.view.dispatch({
|
|
249
|
-
selection: { anchor: 0, head: this.view.state.doc.length }
|
|
250
|
-
}), H(this.view);
|
|
251
|
-
}
|
|
252
|
-
// Disable CodeMirror and show original textarea
|
|
253
|
-
disableCodeMirror() {
|
|
254
|
-
this.view && (this.view.destroy(), this.view = null);
|
|
255
|
-
const e = document.querySelector(".ck-source-editing-area textarea");
|
|
256
|
-
e && (e.style.display = "");
|
|
257
|
-
}
|
|
923
|
+
he.empty = /* @__PURE__ */ new he(Q, Q), typeof Intl < "u" && Intl.Segmenter;
|
|
924
|
+
function ge(e, t) {
|
|
925
|
+
let n = -1;
|
|
926
|
+
return e.changeByRange((r) => {
|
|
927
|
+
let i = [];
|
|
928
|
+
for (let a = r.from; a <= r.to;) {
|
|
929
|
+
let o = e.doc.lineAt(a);
|
|
930
|
+
o.number > n && (r.empty || r.to > o.from) && (t(o, i, r), n = o.number), a = o.to + 1;
|
|
931
|
+
}
|
|
932
|
+
let a = e.changes(i);
|
|
933
|
+
return {
|
|
934
|
+
changes: i,
|
|
935
|
+
range: c.range(a.mapPos(r.anchor, 1), a.mapPos(r.head, 1))
|
|
936
|
+
};
|
|
937
|
+
});
|
|
258
938
|
}
|
|
259
|
-
|
|
260
|
-
|
|
939
|
+
var _e = ({ state: e, dispatch: t }) => {
|
|
940
|
+
if (e.readOnly) return !1;
|
|
941
|
+
let n = Object.create(null), r = new p(e, { overrideIndentation: (e) => n[e] ?? -1 }), i = ge(e, (t, i, a) => {
|
|
942
|
+
let o = h(r, t.from);
|
|
943
|
+
if (o == null) return;
|
|
944
|
+
/\S/.test(t.text) || (o = 0);
|
|
945
|
+
let s = /^\s*/.exec(t.text)[0], c = _(e, o);
|
|
946
|
+
(s != c || a.from < t.from + s.length) && (n[t.from] = o, i.push({
|
|
947
|
+
from: t.from,
|
|
948
|
+
to: t.from + s.length,
|
|
949
|
+
insert: c
|
|
950
|
+
}));
|
|
951
|
+
});
|
|
952
|
+
return i.changes.empty || t(e.update(i, { userEvent: "indent" })), !0;
|
|
953
|
+
}, ve = class extends e {
|
|
954
|
+
constructor() {
|
|
955
|
+
super(...arguments), this.view = null;
|
|
956
|
+
}
|
|
957
|
+
static get pluginName() {
|
|
958
|
+
return "SourceEditingCodeMirror";
|
|
959
|
+
}
|
|
960
|
+
static get requires() {
|
|
961
|
+
return ["SourceEditing"];
|
|
962
|
+
}
|
|
963
|
+
async formatWithPrettier(e) {
|
|
964
|
+
return await b.format(e, {
|
|
965
|
+
parser: "html",
|
|
966
|
+
plugins: [
|
|
967
|
+
x,
|
|
968
|
+
S,
|
|
969
|
+
C,
|
|
970
|
+
w,
|
|
971
|
+
T
|
|
972
|
+
],
|
|
973
|
+
tabWidth: 4,
|
|
974
|
+
useTabs: !1
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
afterInit() {
|
|
978
|
+
let e = this.editor.plugins.get("SourceEditing");
|
|
979
|
+
this.listenTo(e, "change:isSourceEditingMode", async (e, t, n) => {
|
|
980
|
+
n ? await this.enableCodeMirror() : this.disableCodeMirror();
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
async enableCodeMirror() {
|
|
984
|
+
let e = this.editor;
|
|
985
|
+
e.plugins.get("SourceEditing").updateEditorData();
|
|
986
|
+
let a = await this.formatWithPrettier(e.getData()), o = document.querySelector(".ck-source-editing-area");
|
|
987
|
+
if (!o) return;
|
|
988
|
+
let s = o.querySelector("textarea");
|
|
989
|
+
s && (s.style.display = "none");
|
|
990
|
+
let c = document.createElement("div");
|
|
991
|
+
c.classList.add("cm-wrapper"), o.appendChild(c);
|
|
992
|
+
let u = [
|
|
993
|
+
i(),
|
|
994
|
+
n(),
|
|
995
|
+
r(),
|
|
996
|
+
y(m),
|
|
997
|
+
g(),
|
|
998
|
+
v.of(" ")
|
|
999
|
+
], d = e.config.get("sourceEditingCodeMirror")?.extensions ?? [];
|
|
1000
|
+
this.view = new t({
|
|
1001
|
+
state: l.create({
|
|
1002
|
+
doc: a,
|
|
1003
|
+
extensions: [
|
|
1004
|
+
...u,
|
|
1005
|
+
f(),
|
|
1006
|
+
...d,
|
|
1007
|
+
t.updateListener.of((t) => {
|
|
1008
|
+
t.docChanged && e.setData(t.state.doc.toString());
|
|
1009
|
+
})
|
|
1010
|
+
]
|
|
1011
|
+
}),
|
|
1012
|
+
parent: c
|
|
1013
|
+
}), this.view.dispatch({ selection: {
|
|
1014
|
+
anchor: 0,
|
|
1015
|
+
head: this.view.state.doc.length
|
|
1016
|
+
} }), _e(this.view);
|
|
1017
|
+
}
|
|
1018
|
+
disableCodeMirror() {
|
|
1019
|
+
this.view &&= (this.view.destroy(), null);
|
|
1020
|
+
let e = document.querySelector(".ck-source-editing-area textarea");
|
|
1021
|
+
e && (e.style.display = "");
|
|
1022
|
+
}
|
|
261
1023
|
};
|
|
1024
|
+
//#endregion
|
|
1025
|
+
export { ve as default };
|