@scalar/use-codemirror 0.10.0 → 0.10.3
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/CHANGELOG.md +18 -0
- package/README.md +1 -1
- package/dist/index.js +189 -755
- package/package.json +14 -9
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import
|
|
7
|
+
import { yCollab } from "y-codemirror.next";
|
|
8
8
|
import { ref, watch, onBeforeUnmount, toValue, computed, defineComponent, toRef, openBlock, createElementBlock } from "vue";
|
|
9
9
|
class Text {
|
|
10
10
|
/**
|
|
@@ -26,7 +26,7 @@ class Text {
|
|
|
26
26
|
/**
|
|
27
27
|
Replace a range of the text with the given content.
|
|
28
28
|
*/
|
|
29
|
-
replace(from, to,
|
|
29
|
+
replace(from, to, text) {
|
|
30
30
|
[from, to] = clip(this, from, to);
|
|
31
31
|
let parts = [];
|
|
32
32
|
this.decompose(
|
|
@@ -36,10 +36,10 @@ class Text {
|
|
|
36
36
|
2
|
|
37
37
|
/* Open.To */
|
|
38
38
|
);
|
|
39
|
-
if (
|
|
40
|
-
|
|
39
|
+
if (text.length)
|
|
40
|
+
text.decompose(
|
|
41
41
|
0,
|
|
42
|
-
|
|
42
|
+
text.length,
|
|
43
43
|
parts,
|
|
44
44
|
1 | 2
|
|
45
45
|
/* Open.To */
|
|
@@ -51,7 +51,7 @@ class Text {
|
|
|
51
51
|
1
|
|
52
52
|
/* Open.From */
|
|
53
53
|
);
|
|
54
|
-
return TextNode.from(parts, this.length - (to - from) +
|
|
54
|
+
return TextNode.from(parts, this.length - (to - from) + text.length);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
Append another document to this one.
|
|
@@ -147,18 +147,18 @@ class Text {
|
|
|
147
147
|
/**
|
|
148
148
|
Create a `Text` instance for the given array of lines.
|
|
149
149
|
*/
|
|
150
|
-
static of(
|
|
151
|
-
if (
|
|
150
|
+
static of(text) {
|
|
151
|
+
if (text.length == 0)
|
|
152
152
|
throw new RangeError("A document must have at least one line");
|
|
153
|
-
if (
|
|
153
|
+
if (text.length == 1 && !text[0])
|
|
154
154
|
return Text.empty;
|
|
155
|
-
return
|
|
155
|
+
return text.length <= 32 ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
class TextLeaf extends Text {
|
|
159
|
-
constructor(
|
|
159
|
+
constructor(text, length = textLength(text)) {
|
|
160
160
|
super();
|
|
161
|
-
this.text =
|
|
161
|
+
this.text = text;
|
|
162
162
|
this.length = length;
|
|
163
163
|
}
|
|
164
164
|
get lines() {
|
|
@@ -177,26 +177,26 @@ class TextLeaf extends Text {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
decompose(from, to, target, open) {
|
|
180
|
-
let
|
|
180
|
+
let text = from <= 0 && to >= this.length ? this : new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
|
|
181
181
|
if (open & 1) {
|
|
182
182
|
let prev = target.pop();
|
|
183
|
-
let joined = appendText(
|
|
183
|
+
let joined = appendText(text.text, prev.text.slice(), 0, text.length);
|
|
184
184
|
if (joined.length <= 32) {
|
|
185
|
-
target.push(new TextLeaf(joined, prev.length +
|
|
185
|
+
target.push(new TextLeaf(joined, prev.length + text.length));
|
|
186
186
|
} else {
|
|
187
187
|
let mid = joined.length >> 1;
|
|
188
188
|
target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));
|
|
189
189
|
}
|
|
190
190
|
} else {
|
|
191
|
-
target.push(
|
|
191
|
+
target.push(text);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
replace(from, to,
|
|
195
|
-
if (!(
|
|
196
|
-
return super.replace(from, to,
|
|
194
|
+
replace(from, to, text) {
|
|
195
|
+
if (!(text instanceof TextLeaf))
|
|
196
|
+
return super.replace(from, to, text);
|
|
197
197
|
[from, to] = clip(this, from, to);
|
|
198
|
-
let lines = appendText(this.text, appendText(
|
|
199
|
-
let newLen = this.length +
|
|
198
|
+
let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);
|
|
199
|
+
let newLen = this.length + text.length - (to - from);
|
|
200
200
|
if (lines.length <= 32)
|
|
201
201
|
return new TextLeaf(lines, newLen);
|
|
202
202
|
return TextNode.from(TextLeaf.split(lines, []), newLen);
|
|
@@ -221,9 +221,9 @@ class TextLeaf extends Text {
|
|
|
221
221
|
scanIdentical() {
|
|
222
222
|
return 0;
|
|
223
223
|
}
|
|
224
|
-
static split(
|
|
224
|
+
static split(text, target) {
|
|
225
225
|
let part = [], len = -1;
|
|
226
|
-
for (let line of
|
|
226
|
+
for (let line of text) {
|
|
227
227
|
part.push(line);
|
|
228
228
|
len += line.length + 1;
|
|
229
229
|
if (part.length == 32) {
|
|
@@ -268,24 +268,24 @@ class TextNode extends Text {
|
|
|
268
268
|
pos = end + 1;
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
-
replace(from, to,
|
|
271
|
+
replace(from, to, text) {
|
|
272
272
|
[from, to] = clip(this, from, to);
|
|
273
|
-
if (
|
|
273
|
+
if (text.lines < this.lines)
|
|
274
274
|
for (let i = 0, pos = 0; i < this.children.length; i++) {
|
|
275
275
|
let child = this.children[i], end = pos + child.length;
|
|
276
276
|
if (from >= pos && to <= end) {
|
|
277
|
-
let updated = child.replace(from - pos, to - pos,
|
|
277
|
+
let updated = child.replace(from - pos, to - pos, text);
|
|
278
278
|
let totalLines = this.lines - child.lines + updated.lines;
|
|
279
279
|
if (updated.lines < totalLines >> 5 - 1 && updated.lines > totalLines >> 5 + 1) {
|
|
280
280
|
let copy = this.children.slice();
|
|
281
281
|
copy[i] = updated;
|
|
282
|
-
return new TextNode(copy, this.length - (to - from) +
|
|
282
|
+
return new TextNode(copy, this.length - (to - from) + text.length);
|
|
283
283
|
}
|
|
284
284
|
return super.replace(pos, end, updated);
|
|
285
285
|
}
|
|
286
286
|
pos = end + 1;
|
|
287
287
|
}
|
|
288
|
-
return super.replace(from, to,
|
|
288
|
+
return super.replace(from, to, text);
|
|
289
289
|
}
|
|
290
290
|
sliceString(from, to = this.length, lineSep = "\n") {
|
|
291
291
|
[from, to] = clip(this, from, to);
|
|
@@ -368,15 +368,15 @@ class TextNode extends Text {
|
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
Text.empty = /* @__PURE__ */ new TextLeaf([""], 0);
|
|
371
|
-
function textLength(
|
|
371
|
+
function textLength(text) {
|
|
372
372
|
let length = -1;
|
|
373
|
-
for (let line of
|
|
373
|
+
for (let line of text)
|
|
374
374
|
length += line.length + 1;
|
|
375
375
|
return length;
|
|
376
376
|
}
|
|
377
|
-
function appendText(
|
|
378
|
-
for (let pos = 0, i = 0, first = true; i <
|
|
379
|
-
let line =
|
|
377
|
+
function appendText(text, target, from = 0, to = 1e9) {
|
|
378
|
+
for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {
|
|
379
|
+
let line = text[i], end = pos + line.length;
|
|
380
380
|
if (end >= from) {
|
|
381
381
|
if (end > to)
|
|
382
382
|
line = line.slice(0, to - pos);
|
|
@@ -392,17 +392,17 @@ function appendText(text2, target, from = 0, to = 1e9) {
|
|
|
392
392
|
}
|
|
393
393
|
return target;
|
|
394
394
|
}
|
|
395
|
-
function sliceText(
|
|
396
|
-
return appendText(
|
|
395
|
+
function sliceText(text, from, to) {
|
|
396
|
+
return appendText(text, [""], from, to);
|
|
397
397
|
}
|
|
398
398
|
class RawTextCursor {
|
|
399
|
-
constructor(
|
|
399
|
+
constructor(text, dir = 1) {
|
|
400
400
|
this.dir = dir;
|
|
401
401
|
this.done = false;
|
|
402
402
|
this.lineBreak = false;
|
|
403
403
|
this.value = "";
|
|
404
|
-
this.nodes = [
|
|
405
|
-
this.offsets = [dir > 0 ? 1 : (
|
|
404
|
+
this.nodes = [text];
|
|
405
|
+
this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf ? text.text.length : text.children.length) << 1];
|
|
406
406
|
}
|
|
407
407
|
nextInner(skip, dir) {
|
|
408
408
|
this.done = this.lineBreak = false;
|
|
@@ -459,11 +459,11 @@ class RawTextCursor {
|
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
461
|
class PartialTextCursor {
|
|
462
|
-
constructor(
|
|
462
|
+
constructor(text, start, end) {
|
|
463
463
|
this.value = "";
|
|
464
464
|
this.done = false;
|
|
465
|
-
this.cursor = new RawTextCursor(
|
|
466
|
-
this.pos = start > end ?
|
|
465
|
+
this.cursor = new RawTextCursor(text, start > end ? -1 : 1);
|
|
466
|
+
this.pos = start > end ? text.length : 0;
|
|
467
467
|
this.from = Math.min(start, end);
|
|
468
468
|
this.to = Math.max(start, end);
|
|
469
469
|
}
|
|
@@ -539,11 +539,11 @@ class Line {
|
|
|
539
539
|
/**
|
|
540
540
|
@internal
|
|
541
541
|
*/
|
|
542
|
-
constructor(from, to, number2,
|
|
542
|
+
constructor(from, to, number2, text) {
|
|
543
543
|
this.from = from;
|
|
544
544
|
this.to = to;
|
|
545
545
|
this.number = number2;
|
|
546
|
-
this.text =
|
|
546
|
+
this.text = text;
|
|
547
547
|
}
|
|
548
548
|
/**
|
|
549
549
|
The length of the line (not including any line break after it).
|
|
@@ -552,9 +552,9 @@ class Line {
|
|
|
552
552
|
return this.to - this.from;
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
|
-
function clip(
|
|
556
|
-
from = Math.max(0, Math.min(
|
|
557
|
-
return [from, Math.max(from, Math.min(
|
|
555
|
+
function clip(text, from, to) {
|
|
556
|
+
from = Math.max(0, Math.min(text.length, from));
|
|
557
|
+
return [from, Math.max(from, Math.min(text.length, to))];
|
|
558
558
|
}
|
|
559
559
|
let extend = /* @__PURE__ */ "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((s) => s ? parseInt(s, 36) : 1);
|
|
560
560
|
for (let i = 1; i < extend.length; i++)
|
|
@@ -822,7 +822,7 @@ class ChangeSet extends ChangeDesc {
|
|
|
822
822
|
apply(doc2) {
|
|
823
823
|
if (this.length != doc2.length)
|
|
824
824
|
throw new RangeError("Applying change set to a document with the wrong length");
|
|
825
|
-
iterChanges(this, (fromA, toA, fromB, _toB,
|
|
825
|
+
iterChanges(this, (fromA, toA, fromB, _toB, text) => doc2 = doc2.replace(fromB, fromB + (toA - fromA), text), false);
|
|
826
826
|
return doc2;
|
|
827
827
|
}
|
|
828
828
|
mapDesc(other, before = false) {
|
|
@@ -1067,18 +1067,18 @@ function iterChanges(desc, f, individual) {
|
|
|
1067
1067
|
posA += len;
|
|
1068
1068
|
posB += len;
|
|
1069
1069
|
} else {
|
|
1070
|
-
let endA = posA, endB = posB,
|
|
1070
|
+
let endA = posA, endB = posB, text = Text.empty;
|
|
1071
1071
|
for (; ; ) {
|
|
1072
1072
|
endA += len;
|
|
1073
1073
|
endB += ins;
|
|
1074
1074
|
if (ins && inserted)
|
|
1075
|
-
|
|
1075
|
+
text = text.append(inserted[i - 2 >> 1]);
|
|
1076
1076
|
if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)
|
|
1077
1077
|
break;
|
|
1078
1078
|
len = desc.sections[i++];
|
|
1079
1079
|
ins = desc.sections[i++];
|
|
1080
1080
|
}
|
|
1081
|
-
f(posA, endA, posB, endB,
|
|
1081
|
+
f(posA, endA, posB, endB, text);
|
|
1082
1082
|
posA = endA;
|
|
1083
1083
|
posB = endB;
|
|
1084
1084
|
}
|
|
@@ -1699,8 +1699,8 @@ class StateField {
|
|
|
1699
1699
|
way it is initialized. Can be useful when you need to provide a
|
|
1700
1700
|
non-default starting value for the field.
|
|
1701
1701
|
*/
|
|
1702
|
-
init(
|
|
1703
|
-
return [this, initField.of({ field: this, create
|
|
1702
|
+
init(create) {
|
|
1703
|
+
return [this, initField.of({ field: this, create })];
|
|
1704
1704
|
}
|
|
1705
1705
|
/**
|
|
1706
1706
|
State field instances can be used as
|
|
@@ -2324,12 +2324,12 @@ class EditorState {
|
|
|
2324
2324
|
Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
|
|
2325
2325
|
replaces every selection range with the given content.
|
|
2326
2326
|
*/
|
|
2327
|
-
replaceSelection(
|
|
2328
|
-
if (typeof
|
|
2329
|
-
|
|
2327
|
+
replaceSelection(text) {
|
|
2328
|
+
if (typeof text == "string")
|
|
2329
|
+
text = this.toText(text);
|
|
2330
2330
|
return this.changeByRange((range) => ({
|
|
2331
|
-
changes: { from: range.from, to: range.to, insert:
|
|
2332
|
-
range: EditorSelection.cursor(range.from +
|
|
2331
|
+
changes: { from: range.from, to: range.to, insert: text },
|
|
2332
|
+
range: EditorSelection.cursor(range.from + text.length)
|
|
2333
2333
|
}));
|
|
2334
2334
|
}
|
|
2335
2335
|
/**
|
|
@@ -2547,18 +2547,18 @@ class EditorState {
|
|
|
2547
2547
|
this returns null.
|
|
2548
2548
|
*/
|
|
2549
2549
|
wordAt(pos) {
|
|
2550
|
-
let { text
|
|
2550
|
+
let { text, from, length } = this.doc.lineAt(pos);
|
|
2551
2551
|
let cat = this.charCategorizer(pos);
|
|
2552
2552
|
let start = pos - from, end = pos - from;
|
|
2553
2553
|
while (start > 0) {
|
|
2554
|
-
let prev = findClusterBreak(
|
|
2555
|
-
if (cat(
|
|
2554
|
+
let prev = findClusterBreak(text, start, false);
|
|
2555
|
+
if (cat(text.slice(prev, start)) != CharCategory.Word)
|
|
2556
2556
|
break;
|
|
2557
2557
|
start = prev;
|
|
2558
2558
|
}
|
|
2559
2559
|
while (end < length) {
|
|
2560
|
-
let next = findClusterBreak(
|
|
2561
|
-
if (cat(
|
|
2560
|
+
let next = findClusterBreak(text, end);
|
|
2561
|
+
if (cat(text.slice(end, next)) != CharCategory.Word)
|
|
2562
2562
|
break;
|
|
2563
2563
|
end = next;
|
|
2564
2564
|
}
|
|
@@ -3514,10 +3514,10 @@ class StyleSet {
|
|
|
3514
3514
|
if (this.root.adoptedStyleSheets.indexOf(this.sheet) < 0)
|
|
3515
3515
|
this.root.adoptedStyleSheets = [this.sheet, ...this.root.adoptedStyleSheets];
|
|
3516
3516
|
} else {
|
|
3517
|
-
let
|
|
3517
|
+
let text = "";
|
|
3518
3518
|
for (let i = 0; i < this.modules.length; i++)
|
|
3519
|
-
|
|
3520
|
-
this.styleTag.textContent =
|
|
3519
|
+
text += this.modules[i].getRules() + "\n";
|
|
3520
|
+
this.styleTag.textContent = text;
|
|
3521
3521
|
let target = this.root.head || this.root;
|
|
3522
3522
|
if (this.styleTag.parentNode != target)
|
|
3523
3523
|
target.insertBefore(this.styleTag, target.firstChild);
|
|
@@ -4276,14 +4276,14 @@ function mergeChildrenInto(parent, from, to, insert2, openStart, openEnd) {
|
|
|
4276
4276
|
replaceRange(parent, fromI, fromOff, toI, toOff, insert2, 0, openStart, openEnd);
|
|
4277
4277
|
}
|
|
4278
4278
|
let nav = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
|
|
4279
|
-
let doc
|
|
4279
|
+
let doc = typeof document != "undefined" ? document : { documentElement: { style: {} } };
|
|
4280
4280
|
const ie_edge = /* @__PURE__ */ /Edge\/(\d+)/.exec(nav.userAgent);
|
|
4281
4281
|
const ie_upto10 = /* @__PURE__ */ /MSIE \d/.test(nav.userAgent);
|
|
4282
4282
|
const ie_11up = /* @__PURE__ */ /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent);
|
|
4283
4283
|
const ie = !!(ie_upto10 || ie_11up || ie_edge);
|
|
4284
4284
|
const gecko = !ie && /* @__PURE__ */ /gecko\/(\d+)/i.test(nav.userAgent);
|
|
4285
4285
|
const chrome = !ie && /* @__PURE__ */ /Chrome\/(\d+)/.exec(nav.userAgent);
|
|
4286
|
-
const webkit = "webkitFontSmoothing" in doc
|
|
4286
|
+
const webkit = "webkitFontSmoothing" in doc.documentElement.style;
|
|
4287
4287
|
const safari = !ie && /* @__PURE__ */ /Apple Computer/.test(nav.vendor);
|
|
4288
4288
|
const ios = safari && (/* @__PURE__ */ /Mobile\/\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);
|
|
4289
4289
|
var browser = {
|
|
@@ -4291,7 +4291,7 @@ var browser = {
|
|
|
4291
4291
|
windows: /* @__PURE__ */ /Win/.test(nav.platform),
|
|
4292
4292
|
linux: /* @__PURE__ */ /Linux|X11/.test(nav.platform),
|
|
4293
4293
|
ie,
|
|
4294
|
-
ie_version: ie_upto10 ? doc
|
|
4294
|
+
ie_version: ie_upto10 ? doc.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0,
|
|
4295
4295
|
gecko,
|
|
4296
4296
|
gecko_version: gecko ? +(/* @__PURE__ */ /Firefox\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
|
|
4297
4297
|
chrome: !!chrome,
|
|
@@ -4301,13 +4301,13 @@ var browser = {
|
|
|
4301
4301
|
webkit,
|
|
4302
4302
|
safari,
|
|
4303
4303
|
webkit_version: webkit ? +(/* @__PURE__ */ /\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,
|
|
4304
|
-
tabSize: doc
|
|
4304
|
+
tabSize: doc.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
|
|
4305
4305
|
};
|
|
4306
4306
|
const MaxJoinLen = 256;
|
|
4307
4307
|
class TextView extends ContentView {
|
|
4308
|
-
constructor(
|
|
4308
|
+
constructor(text) {
|
|
4309
4309
|
super();
|
|
4310
|
-
this.text =
|
|
4310
|
+
this.text = text;
|
|
4311
4311
|
}
|
|
4312
4312
|
get length() {
|
|
4313
4313
|
return this.text.length;
|
|
@@ -4422,8 +4422,8 @@ class MarkView extends ContentView {
|
|
|
4422
4422
|
return coordsInChildren(this, pos, side);
|
|
4423
4423
|
}
|
|
4424
4424
|
}
|
|
4425
|
-
function textCoords(
|
|
4426
|
-
let length =
|
|
4425
|
+
function textCoords(text, pos, side) {
|
|
4426
|
+
let length = text.nodeValue.length;
|
|
4427
4427
|
if (pos > length)
|
|
4428
4428
|
pos = length;
|
|
4429
4429
|
let from = pos, to = pos, flatten2 = 0;
|
|
@@ -4443,7 +4443,7 @@ function textCoords(text2, pos, side) {
|
|
|
4443
4443
|
else if (to < length)
|
|
4444
4444
|
to++;
|
|
4445
4445
|
}
|
|
4446
|
-
let rects = textRange(
|
|
4446
|
+
let rects = textRange(text, from, to).getClientRects();
|
|
4447
4447
|
if (!rects.length)
|
|
4448
4448
|
return null;
|
|
4449
4449
|
let rect = rects[(flatten2 ? flatten2 < 0 : side >= 0) ? 0 : rects.length - 1];
|
|
@@ -4510,8 +4510,8 @@ class WidgetView extends ContentView {
|
|
|
4510
4510
|
let top2 = this;
|
|
4511
4511
|
while (top2.parent)
|
|
4512
4512
|
top2 = top2.parent;
|
|
4513
|
-
let { view } = top2,
|
|
4514
|
-
return
|
|
4513
|
+
let { view } = top2, text = view && view.state.doc, start = this.posAtStart;
|
|
4514
|
+
return text ? text.slice(start, start + this.length) : Text.empty;
|
|
4515
4515
|
}
|
|
4516
4516
|
domAtPos(pos) {
|
|
4517
4517
|
return (this.length ? pos == 0 : this.side > 0) ? DOMPos.before(this.dom) : DOMPos.after(this.dom, pos == this.length);
|
|
@@ -5347,8 +5347,8 @@ class ContentBuilder {
|
|
|
5347
5347
|
if (this.openStart < 0)
|
|
5348
5348
|
this.openStart = openStart;
|
|
5349
5349
|
}
|
|
5350
|
-
static build(
|
|
5351
|
-
let builder = new ContentBuilder(
|
|
5350
|
+
static build(text, from, to, decorations2, dynamicDecorationMap) {
|
|
5351
|
+
let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);
|
|
5352
5352
|
builder.openEnd = RangeSet.spans(decorations2, from, to, builder);
|
|
5353
5353
|
if (builder.openStart < 0)
|
|
5354
5354
|
builder.openStart = builder.openEnd;
|
|
@@ -5733,9 +5733,9 @@ function moveVisually(line, order, dir, start, forward) {
|
|
|
5733
5733
|
return EditorSelection.cursor(nextSpan.side(!forward, dir) + line.from, nextSpan.forward(forward, dir) ? 1 : -1, nextSpan.level);
|
|
5734
5734
|
return EditorSelection.cursor(nextIndex + line.from, span.forward(forward, dir) ? -1 : 1, span.level);
|
|
5735
5735
|
}
|
|
5736
|
-
function autoDirection(
|
|
5736
|
+
function autoDirection(text, from, to) {
|
|
5737
5737
|
for (let i = from; i < to; i++) {
|
|
5738
|
-
let type = charType(
|
|
5738
|
+
let type = charType(text.charCodeAt(i));
|
|
5739
5739
|
if (type == 1)
|
|
5740
5740
|
return LTR;
|
|
5741
5741
|
if (type == 2 || type == 4)
|
|
@@ -5788,9 +5788,9 @@ const editable = /* @__PURE__ */ Facet.define({ combine: (values2) => values2.le
|
|
|
5788
5788
|
let nextPluginID = 0;
|
|
5789
5789
|
const viewPlugin = /* @__PURE__ */ Facet.define();
|
|
5790
5790
|
class ViewPlugin {
|
|
5791
|
-
constructor(id2,
|
|
5791
|
+
constructor(id2, create, domEventHandlers, domEventObservers, buildExtensions) {
|
|
5792
5792
|
this.id = id2;
|
|
5793
|
-
this.create =
|
|
5793
|
+
this.create = create;
|
|
5794
5794
|
this.domEventHandlers = domEventHandlers;
|
|
5795
5795
|
this.domEventObservers = domEventObservers;
|
|
5796
5796
|
this.extension = buildExtensions(this);
|
|
@@ -5799,9 +5799,9 @@ class ViewPlugin {
|
|
|
5799
5799
|
Define a plugin from a constructor function that creates the
|
|
5800
5800
|
plugin's value, given an editor view.
|
|
5801
5801
|
*/
|
|
5802
|
-
static define(
|
|
5802
|
+
static define(create, spec) {
|
|
5803
5803
|
const { eventHandlers, eventObservers, provide, decorations: deco } = spec || {};
|
|
5804
|
-
return new ViewPlugin(nextPluginID++,
|
|
5804
|
+
return new ViewPlugin(nextPluginID++, create, eventHandlers, eventObservers, (plugin) => {
|
|
5805
5805
|
let ext = [viewPlugin.of(plugin)];
|
|
5806
5806
|
if (deco)
|
|
5807
5807
|
ext.push(decorations.of((view) => {
|
|
@@ -6232,9 +6232,9 @@ class DocView extends ContentView {
|
|
|
6232
6232
|
if (browser.gecko) {
|
|
6233
6233
|
let nextTo = nextToUneditable(anchor.node, anchor.offset);
|
|
6234
6234
|
if (nextTo && nextTo != (1 | 2)) {
|
|
6235
|
-
let
|
|
6236
|
-
if (
|
|
6237
|
-
anchor = new DOMPos(
|
|
6235
|
+
let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 ? 1 : -1);
|
|
6236
|
+
if (text)
|
|
6237
|
+
anchor = new DOMPos(text.node, text.offset);
|
|
6238
6238
|
}
|
|
6239
6239
|
}
|
|
6240
6240
|
rawSel.collapse(anchor.node, anchor.offset);
|
|
@@ -6561,10 +6561,10 @@ function findCompositionRange(view, changes, headPos) {
|
|
|
6561
6561
|
let found = findCompositionNode(view, headPos);
|
|
6562
6562
|
if (!found)
|
|
6563
6563
|
return null;
|
|
6564
|
-
let { node: textNode, from, to } = found,
|
|
6565
|
-
if (/[\n\r]/.test(
|
|
6564
|
+
let { node: textNode, from, to } = found, text = textNode.nodeValue;
|
|
6565
|
+
if (/[\n\r]/.test(text))
|
|
6566
6566
|
return null;
|
|
6567
|
-
if (view.state.doc.sliceString(found.from, found.to) !=
|
|
6567
|
+
if (view.state.doc.sliceString(found.from, found.to) != text)
|
|
6568
6568
|
return null;
|
|
6569
6569
|
let inv = changes.invertedDesc;
|
|
6570
6570
|
let range = new ChangedRange(inv.mapPos(from), inv.mapPos(to), from, to);
|
|
@@ -6803,17 +6803,17 @@ function posAtCoords(view, coords, precise, bias = -1) {
|
|
|
6803
6803
|
return view.viewport.to == view.state.doc.length ? view.state.doc.length : precise ? null : posAtCoordsImprecise(view, content2, block, x, y);
|
|
6804
6804
|
let doc2 = view.dom.ownerDocument;
|
|
6805
6805
|
let root = view.root.elementFromPoint ? view.root : doc2;
|
|
6806
|
-
let
|
|
6807
|
-
if (
|
|
6808
|
-
|
|
6809
|
-
if (!
|
|
6806
|
+
let element = root.elementFromPoint(x, y);
|
|
6807
|
+
if (element && !view.contentDOM.contains(element))
|
|
6808
|
+
element = null;
|
|
6809
|
+
if (!element) {
|
|
6810
6810
|
x = Math.max(content2.left + 1, Math.min(content2.right - 1, x));
|
|
6811
|
-
|
|
6812
|
-
if (
|
|
6813
|
-
|
|
6811
|
+
element = root.elementFromPoint(x, y);
|
|
6812
|
+
if (element && !view.contentDOM.contains(element))
|
|
6813
|
+
element = null;
|
|
6814
6814
|
}
|
|
6815
6815
|
let node, offset = -1;
|
|
6816
|
-
if (
|
|
6816
|
+
if (element && ((_a2 = view.docView.nearest(element)) === null || _a2 === void 0 ? void 0 : _a2.isEditable) != false) {
|
|
6817
6817
|
if (doc2.caretPositionFromPoint) {
|
|
6818
6818
|
let pos = doc2.caretPositionFromPoint(x, y);
|
|
6819
6819
|
if (pos)
|
|
@@ -7325,9 +7325,9 @@ function capturePaste(view) {
|
|
|
7325
7325
|
}, 50);
|
|
7326
7326
|
}
|
|
7327
7327
|
function doPaste(view, input) {
|
|
7328
|
-
let { state } = view, changes, i = 1,
|
|
7329
|
-
let byLine =
|
|
7330
|
-
let linewise = lastLinewiseCopy != null && state.selection.ranges.every((r) => r.empty) && lastLinewiseCopy ==
|
|
7328
|
+
let { state } = view, changes, i = 1, text = state.toText(input);
|
|
7329
|
+
let byLine = text.lines == state.selection.ranges.length;
|
|
7330
|
+
let linewise = lastLinewiseCopy != null && state.selection.ranges.every((r) => r.empty) && lastLinewiseCopy == text.toString();
|
|
7331
7331
|
if (linewise) {
|
|
7332
7332
|
let lastLine = -1;
|
|
7333
7333
|
changes = state.changeByRange((range) => {
|
|
@@ -7335,7 +7335,7 @@ function doPaste(view, input) {
|
|
|
7335
7335
|
if (line.from == lastLine)
|
|
7336
7336
|
return { range };
|
|
7337
7337
|
lastLine = line.from;
|
|
7338
|
-
let insert2 = state.toText((byLine ?
|
|
7338
|
+
let insert2 = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);
|
|
7339
7339
|
return {
|
|
7340
7340
|
changes: { from: line.from, insert: insert2 },
|
|
7341
7341
|
range: EditorSelection.cursor(range.from + insert2.length)
|
|
@@ -7343,14 +7343,14 @@ function doPaste(view, input) {
|
|
|
7343
7343
|
});
|
|
7344
7344
|
} else if (byLine) {
|
|
7345
7345
|
changes = state.changeByRange((range) => {
|
|
7346
|
-
let line =
|
|
7346
|
+
let line = text.line(i++);
|
|
7347
7347
|
return {
|
|
7348
7348
|
changes: { from: range.from, to: range.to, insert: line.text },
|
|
7349
7349
|
range: EditorSelection.cursor(range.from + line.length)
|
|
7350
7350
|
};
|
|
7351
7351
|
});
|
|
7352
7352
|
} else {
|
|
7353
|
-
changes = state.replaceSelection(
|
|
7353
|
+
changes = state.replaceSelection(text);
|
|
7354
7354
|
}
|
|
7355
7355
|
view.dispatch(changes, {
|
|
7356
7356
|
userEvent: "input.paste",
|
|
@@ -7506,13 +7506,13 @@ handlers.dragend = (view) => {
|
|
|
7506
7506
|
view.inputState.draggedContent = null;
|
|
7507
7507
|
return false;
|
|
7508
7508
|
};
|
|
7509
|
-
function dropText(view, event,
|
|
7510
|
-
if (!
|
|
7509
|
+
function dropText(view, event, text, direct) {
|
|
7510
|
+
if (!text)
|
|
7511
7511
|
return;
|
|
7512
7512
|
let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
|
|
7513
7513
|
let { draggedContent } = view.inputState;
|
|
7514
7514
|
let del = direct && draggedContent && dragMovesSelection(view, event) ? { from: draggedContent.from, to: draggedContent.to } : null;
|
|
7515
|
-
let ins = { from: dropPos, insert:
|
|
7515
|
+
let ins = { from: dropPos, insert: text };
|
|
7516
7516
|
let changes = view.state.changes(del ? [del, ins] : ins);
|
|
7517
7517
|
view.focus();
|
|
7518
7518
|
view.dispatch({
|
|
@@ -7529,26 +7529,26 @@ handlers.drop = (view, event) => {
|
|
|
7529
7529
|
return true;
|
|
7530
7530
|
let files = event.dataTransfer.files;
|
|
7531
7531
|
if (files && files.length) {
|
|
7532
|
-
let
|
|
7532
|
+
let text = Array(files.length), read = 0;
|
|
7533
7533
|
let finishFile = () => {
|
|
7534
7534
|
if (++read == files.length)
|
|
7535
|
-
dropText(view, event,
|
|
7535
|
+
dropText(view, event, text.filter((s) => s != null).join(view.state.lineBreak), false);
|
|
7536
7536
|
};
|
|
7537
7537
|
for (let i = 0; i < files.length; i++) {
|
|
7538
7538
|
let reader = new FileReader();
|
|
7539
7539
|
reader.onerror = finishFile;
|
|
7540
7540
|
reader.onload = () => {
|
|
7541
7541
|
if (!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))
|
|
7542
|
-
|
|
7542
|
+
text[i] = reader.result;
|
|
7543
7543
|
finishFile();
|
|
7544
7544
|
};
|
|
7545
7545
|
reader.readAsText(files[i]);
|
|
7546
7546
|
}
|
|
7547
7547
|
return true;
|
|
7548
7548
|
} else {
|
|
7549
|
-
let
|
|
7550
|
-
if (
|
|
7551
|
-
dropText(view, event,
|
|
7549
|
+
let text = event.dataTransfer.getData("Text");
|
|
7550
|
+
if (text) {
|
|
7551
|
+
dropText(view, event, text, true);
|
|
7552
7552
|
return true;
|
|
7553
7553
|
}
|
|
7554
7554
|
}
|
|
@@ -7567,15 +7567,15 @@ handlers.paste = (view, event) => {
|
|
|
7567
7567
|
return false;
|
|
7568
7568
|
}
|
|
7569
7569
|
};
|
|
7570
|
-
function captureCopy(view,
|
|
7570
|
+
function captureCopy(view, text) {
|
|
7571
7571
|
let parent = view.dom.parentNode;
|
|
7572
7572
|
if (!parent)
|
|
7573
7573
|
return;
|
|
7574
7574
|
let target = parent.appendChild(document.createElement("textarea"));
|
|
7575
7575
|
target.style.cssText = "position: fixed; left: -10000px; top: 10px";
|
|
7576
|
-
target.value =
|
|
7576
|
+
target.value = text;
|
|
7577
7577
|
target.focus();
|
|
7578
|
-
target.selectionEnd =
|
|
7578
|
+
target.selectionEnd = text.length;
|
|
7579
7579
|
target.selectionStart = 0;
|
|
7580
7580
|
setTimeout(() => {
|
|
7581
7581
|
target.remove();
|
|
@@ -7605,10 +7605,10 @@ function copiedRange(state) {
|
|
|
7605
7605
|
}
|
|
7606
7606
|
let lastLinewiseCopy = null;
|
|
7607
7607
|
handlers.copy = handlers.cut = (view, event) => {
|
|
7608
|
-
let { text
|
|
7609
|
-
if (!
|
|
7608
|
+
let { text, ranges, linewise } = copiedRange(view.state);
|
|
7609
|
+
if (!text && !linewise)
|
|
7610
7610
|
return false;
|
|
7611
|
-
lastLinewiseCopy = linewise ?
|
|
7611
|
+
lastLinewiseCopy = linewise ? text : null;
|
|
7612
7612
|
if (event.type == "cut" && !view.state.readOnly)
|
|
7613
7613
|
view.dispatch({
|
|
7614
7614
|
changes: ranges,
|
|
@@ -7618,10 +7618,10 @@ handlers.copy = handlers.cut = (view, event) => {
|
|
|
7618
7618
|
let data = brokenClipboardAPI ? null : event.clipboardData;
|
|
7619
7619
|
if (data) {
|
|
7620
7620
|
data.clearData();
|
|
7621
|
-
data.setData("text/plain",
|
|
7621
|
+
data.setData("text/plain", text);
|
|
7622
7622
|
return true;
|
|
7623
7623
|
} else {
|
|
7624
|
-
captureCopy(view,
|
|
7624
|
+
captureCopy(view, text);
|
|
7625
7625
|
return false;
|
|
7626
7626
|
}
|
|
7627
7627
|
};
|
|
@@ -9237,8 +9237,8 @@ class DOMReader {
|
|
|
9237
9237
|
this.text = "";
|
|
9238
9238
|
this.lineSeparator = state.facet(EditorState.lineSeparator);
|
|
9239
9239
|
}
|
|
9240
|
-
append(
|
|
9241
|
-
this.text +=
|
|
9240
|
+
append(text) {
|
|
9241
|
+
this.text += text;
|
|
9242
9242
|
}
|
|
9243
9243
|
lineBreak() {
|
|
9244
9244
|
this.text += LineBreakPlaceholder;
|
|
@@ -9263,20 +9263,20 @@ class DOMReader {
|
|
|
9263
9263
|
return this;
|
|
9264
9264
|
}
|
|
9265
9265
|
readTextNode(node) {
|
|
9266
|
-
let
|
|
9266
|
+
let text = node.nodeValue;
|
|
9267
9267
|
for (let point of this.points)
|
|
9268
9268
|
if (point.node == node)
|
|
9269
|
-
point.pos = this.text.length + Math.min(point.offset,
|
|
9269
|
+
point.pos = this.text.length + Math.min(point.offset, text.length);
|
|
9270
9270
|
for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g; ; ) {
|
|
9271
9271
|
let nextBreak = -1, breakSize = 1, m;
|
|
9272
9272
|
if (this.lineSeparator) {
|
|
9273
|
-
nextBreak =
|
|
9273
|
+
nextBreak = text.indexOf(this.lineSeparator, off);
|
|
9274
9274
|
breakSize = this.lineSeparator.length;
|
|
9275
|
-
} else if (m = re.exec(
|
|
9275
|
+
} else if (m = re.exec(text)) {
|
|
9276
9276
|
nextBreak = m.index;
|
|
9277
9277
|
breakSize = m[0].length;
|
|
9278
9278
|
}
|
|
9279
|
-
this.append(
|
|
9279
|
+
this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
|
|
9280
9280
|
if (nextBreak < 0)
|
|
9281
9281
|
break;
|
|
9282
9282
|
this.lineBreak();
|
|
@@ -9420,12 +9420,12 @@ function applyDOMChange(view, domChange) {
|
|
|
9420
9420
|
return true;
|
|
9421
9421
|
if (browser.android && (change.from == sel.from && change.to == sel.to && change.insert.length == 1 && change.insert.lines == 2 && dispatchKey(view.contentDOM, "Enter", 13) || (change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 || lastKey == 8 && change.insert.length < change.to - change.from && change.to > sel.head) && dispatchKey(view.contentDOM, "Backspace", 8) || change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 && dispatchKey(view.contentDOM, "Delete", 46)))
|
|
9422
9422
|
return true;
|
|
9423
|
-
let
|
|
9423
|
+
let text = change.insert.toString();
|
|
9424
9424
|
if (view.inputState.composing >= 0)
|
|
9425
9425
|
view.inputState.composing++;
|
|
9426
9426
|
let defaultTr;
|
|
9427
9427
|
let defaultInsert = () => defaultTr || (defaultTr = applyDefaultInsert(view, change, newSel));
|
|
9428
|
-
if (!view.state.facet(inputHandler$1).some((h) => h(view, change.from, change.to,
|
|
9428
|
+
if (!view.state.facet(inputHandler$1).some((h) => h(view, change.from, change.to, text, defaultInsert)))
|
|
9429
9429
|
view.dispatch(defaultInsert());
|
|
9430
9430
|
return true;
|
|
9431
9431
|
} else if (newSel && !newSel.main.eq(sel)) {
|
|
@@ -12073,8 +12073,8 @@ const lineNumberGutter = /* @__PURE__ */ activeGutters.compute([lineNumberConfig
|
|
|
12073
12073
|
return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));
|
|
12074
12074
|
},
|
|
12075
12075
|
updateSpacer(spacer, update) {
|
|
12076
|
-
let
|
|
12077
|
-
return
|
|
12076
|
+
let max = formatNumber(update.view, maxLineNumber(update.view.state.doc.lines));
|
|
12077
|
+
return max == spacer.number ? spacer : new NumberMarker(max);
|
|
12078
12078
|
},
|
|
12079
12079
|
domEventHandlers: state.facet(lineNumberConfig).domEventHandlers
|
|
12080
12080
|
}));
|
|
@@ -12091,572 +12091,6 @@ function maxLineNumber(lines) {
|
|
|
12091
12091
|
last = last * 10 + 9;
|
|
12092
12092
|
return last;
|
|
12093
12093
|
}
|
|
12094
|
-
class YRange {
|
|
12095
|
-
/**
|
|
12096
|
-
* @param {Y.RelativePosition} yanchor
|
|
12097
|
-
* @param {Y.RelativePosition} yhead
|
|
12098
|
-
*/
|
|
12099
|
-
constructor(yanchor, yhead) {
|
|
12100
|
-
this.yanchor = yanchor;
|
|
12101
|
-
this.yhead = yhead;
|
|
12102
|
-
}
|
|
12103
|
-
/**
|
|
12104
|
-
* @returns {any}
|
|
12105
|
-
*/
|
|
12106
|
-
toJSON() {
|
|
12107
|
-
return {
|
|
12108
|
-
yanchor: Y.relativePositionToJSON(this.yanchor),
|
|
12109
|
-
yhead: Y.relativePositionToJSON(this.yhead)
|
|
12110
|
-
};
|
|
12111
|
-
}
|
|
12112
|
-
/**
|
|
12113
|
-
* @param {any} json
|
|
12114
|
-
* @return {YRange}
|
|
12115
|
-
*/
|
|
12116
|
-
static fromJSON(json2) {
|
|
12117
|
-
return new YRange(Y.createRelativePositionFromJSON(json2.yanchor), Y.createRelativePositionFromJSON(json2.yhead));
|
|
12118
|
-
}
|
|
12119
|
-
}
|
|
12120
|
-
class YSyncConfig {
|
|
12121
|
-
constructor(ytext, awareness) {
|
|
12122
|
-
this.ytext = ytext;
|
|
12123
|
-
this.awareness = awareness;
|
|
12124
|
-
this.undoManager = new Y.UndoManager(ytext);
|
|
12125
|
-
}
|
|
12126
|
-
/**
|
|
12127
|
-
* Helper function to transform an absolute index position to a Yjs-based relative position
|
|
12128
|
-
* (https://docs.yjs.dev/api/relative-positions).
|
|
12129
|
-
*
|
|
12130
|
-
* A relative position can be transformed back to an absolute position even after the document has changed. The position is
|
|
12131
|
-
* automatically adapted. This does not require any position transformations. Relative positions are computed based on
|
|
12132
|
-
* the internal Yjs document model. Peers that share content through Yjs are guaranteed that their positions will always
|
|
12133
|
-
* synced up when using relatve positions.
|
|
12134
|
-
*
|
|
12135
|
-
* ```js
|
|
12136
|
-
* import { ySyncFacet } from 'y-codemirror'
|
|
12137
|
-
*
|
|
12138
|
-
* ..
|
|
12139
|
-
* const ysync = view.state.facet(ySyncFacet)
|
|
12140
|
-
* // transform an absolute index position to a ypos
|
|
12141
|
-
* const ypos = ysync.getYPos(3)
|
|
12142
|
-
* // transform the ypos back to an absolute position
|
|
12143
|
-
* ysync.fromYPos(ypos) // => 3
|
|
12144
|
-
* ```
|
|
12145
|
-
*
|
|
12146
|
-
* It cannot be guaranteed that absolute index positions can be synced up between peers.
|
|
12147
|
-
* This might lead to undesired behavior when implementing features that require that all peers see the
|
|
12148
|
-
* same marked range (e.g. a comment plugin).
|
|
12149
|
-
*
|
|
12150
|
-
* @param {number} pos
|
|
12151
|
-
* @param {number} [assoc]
|
|
12152
|
-
*/
|
|
12153
|
-
toYPos(pos, assoc = 0) {
|
|
12154
|
-
return Y.createRelativePositionFromTypeIndex(this.ytext, pos, assoc);
|
|
12155
|
-
}
|
|
12156
|
-
/**
|
|
12157
|
-
* @param {Y.RelativePosition | Object} rpos
|
|
12158
|
-
*/
|
|
12159
|
-
fromYPos(rpos) {
|
|
12160
|
-
const pos = Y.createAbsolutePositionFromRelativePosition(Y.createRelativePositionFromJSON(rpos), this.ytext.doc);
|
|
12161
|
-
if (pos == null || pos.type !== this.ytext) {
|
|
12162
|
-
throw new Error("[y-codemirror] The position you want to retrieve was created by a different document");
|
|
12163
|
-
}
|
|
12164
|
-
return {
|
|
12165
|
-
pos: pos.index,
|
|
12166
|
-
assoc: pos.assoc
|
|
12167
|
-
};
|
|
12168
|
-
}
|
|
12169
|
-
/**
|
|
12170
|
-
* @param {cmState.SelectionRange} range
|
|
12171
|
-
* @return {YRange}
|
|
12172
|
-
*/
|
|
12173
|
-
toYRange(range) {
|
|
12174
|
-
const assoc = range.assoc;
|
|
12175
|
-
const yanchor = this.toYPos(range.anchor, assoc);
|
|
12176
|
-
const yhead = this.toYPos(range.head, assoc);
|
|
12177
|
-
return new YRange(yanchor, yhead);
|
|
12178
|
-
}
|
|
12179
|
-
/**
|
|
12180
|
-
* @param {YRange} yrange
|
|
12181
|
-
*/
|
|
12182
|
-
fromYRange(yrange) {
|
|
12183
|
-
const anchor = this.fromYPos(yrange.yanchor);
|
|
12184
|
-
const head = this.fromYPos(yrange.yhead);
|
|
12185
|
-
if (anchor.pos === head.pos) {
|
|
12186
|
-
return EditorSelection.cursor(head.pos, head.assoc);
|
|
12187
|
-
}
|
|
12188
|
-
return EditorSelection.range(anchor.pos, head.pos);
|
|
12189
|
-
}
|
|
12190
|
-
}
|
|
12191
|
-
const ySyncFacet = Facet.define({
|
|
12192
|
-
combine(inputs) {
|
|
12193
|
-
return inputs[inputs.length - 1];
|
|
12194
|
-
}
|
|
12195
|
-
});
|
|
12196
|
-
const ySyncAnnotation = Annotation.define();
|
|
12197
|
-
class YSyncPluginValue {
|
|
12198
|
-
/**
|
|
12199
|
-
* @param {cmView.EditorView} view
|
|
12200
|
-
*/
|
|
12201
|
-
constructor(view) {
|
|
12202
|
-
this.view = view;
|
|
12203
|
-
this.conf = view.state.facet(ySyncFacet);
|
|
12204
|
-
this._observer = (event, tr) => {
|
|
12205
|
-
if (tr.origin !== this.conf) {
|
|
12206
|
-
const delta = event.delta;
|
|
12207
|
-
const changes = [];
|
|
12208
|
-
let pos = 0;
|
|
12209
|
-
for (let i = 0; i < delta.length; i++) {
|
|
12210
|
-
const d = delta[i];
|
|
12211
|
-
if (d.insert != null) {
|
|
12212
|
-
changes.push({ from: pos, to: pos, insert: d.insert });
|
|
12213
|
-
} else if (d.delete != null) {
|
|
12214
|
-
changes.push({ from: pos, to: pos + d.delete, insert: "" });
|
|
12215
|
-
pos += d.delete;
|
|
12216
|
-
} else {
|
|
12217
|
-
pos += d.retain;
|
|
12218
|
-
}
|
|
12219
|
-
}
|
|
12220
|
-
view.dispatch({ changes, annotations: [ySyncAnnotation.of(this.conf)] });
|
|
12221
|
-
}
|
|
12222
|
-
};
|
|
12223
|
-
this._ytext = this.conf.ytext;
|
|
12224
|
-
this._ytext.observe(this._observer);
|
|
12225
|
-
}
|
|
12226
|
-
/**
|
|
12227
|
-
* @param {cmView.ViewUpdate} update
|
|
12228
|
-
*/
|
|
12229
|
-
update(update) {
|
|
12230
|
-
if (!update.docChanged || update.transactions.length > 0 && update.transactions[0].annotation(ySyncAnnotation) === this.conf) {
|
|
12231
|
-
return;
|
|
12232
|
-
}
|
|
12233
|
-
const ytext = this.conf.ytext;
|
|
12234
|
-
ytext.doc.transact(() => {
|
|
12235
|
-
let adj = 0;
|
|
12236
|
-
update.changes.iterChanges((fromA, toA, fromB, toB, insert2) => {
|
|
12237
|
-
const insertText = insert2.sliceString(0, insert2.length, "\n");
|
|
12238
|
-
if (fromA !== toA) {
|
|
12239
|
-
ytext.delete(fromA + adj, toA - fromA);
|
|
12240
|
-
}
|
|
12241
|
-
if (insertText.length > 0) {
|
|
12242
|
-
ytext.insert(fromA + adj, insertText);
|
|
12243
|
-
}
|
|
12244
|
-
adj += insertText.length - (toA - fromA);
|
|
12245
|
-
});
|
|
12246
|
-
}, this.conf);
|
|
12247
|
-
}
|
|
12248
|
-
destroy() {
|
|
12249
|
-
this._ytext.unobserve(this._observer);
|
|
12250
|
-
}
|
|
12251
|
-
}
|
|
12252
|
-
const ySync = ViewPlugin.fromClass(YSyncPluginValue);
|
|
12253
|
-
class Pair {
|
|
12254
|
-
/**
|
|
12255
|
-
* @param {L} left
|
|
12256
|
-
* @param {R} right
|
|
12257
|
-
*/
|
|
12258
|
-
constructor(left, right) {
|
|
12259
|
-
this.left = left;
|
|
12260
|
-
this.right = right;
|
|
12261
|
-
}
|
|
12262
|
-
}
|
|
12263
|
-
const create = (left, right) => new Pair(left, right);
|
|
12264
|
-
const forEach = (arr, f) => arr.forEach((p) => f(p.left, p.right));
|
|
12265
|
-
const doc = (
|
|
12266
|
-
/** @type {Document} */
|
|
12267
|
-
typeof document !== "undefined" ? document : {}
|
|
12268
|
-
);
|
|
12269
|
-
const createElement = (name2) => doc.createElement(name2);
|
|
12270
|
-
const createDocumentFragment = () => doc.createDocumentFragment();
|
|
12271
|
-
const createTextNode = (text2) => doc.createTextNode(text2);
|
|
12272
|
-
typeof DOMParser !== "undefined" ? new DOMParser() : null;
|
|
12273
|
-
const setAttributes = (el, attrs) => {
|
|
12274
|
-
forEach(attrs, (key, value) => {
|
|
12275
|
-
if (value === false) {
|
|
12276
|
-
el.removeAttribute(key);
|
|
12277
|
-
} else if (value === true) {
|
|
12278
|
-
el.setAttribute(key, "");
|
|
12279
|
-
} else {
|
|
12280
|
-
el.setAttribute(key, value);
|
|
12281
|
-
}
|
|
12282
|
-
});
|
|
12283
|
-
return el;
|
|
12284
|
-
};
|
|
12285
|
-
const fragment = (children) => {
|
|
12286
|
-
const fragment2 = createDocumentFragment();
|
|
12287
|
-
for (let i = 0; i < children.length; i++) {
|
|
12288
|
-
appendChild(fragment2, children[i]);
|
|
12289
|
-
}
|
|
12290
|
-
return fragment2;
|
|
12291
|
-
};
|
|
12292
|
-
const append = (parent, nodes) => {
|
|
12293
|
-
appendChild(parent, fragment(nodes));
|
|
12294
|
-
return parent;
|
|
12295
|
-
};
|
|
12296
|
-
const element = (name2, attrs = [], children = []) => append(setAttributes(createElement(name2), attrs), children);
|
|
12297
|
-
const text = createTextNode;
|
|
12298
|
-
const appendChild = (parent, child) => parent.appendChild(child);
|
|
12299
|
-
doc.ELEMENT_NODE;
|
|
12300
|
-
doc.TEXT_NODE;
|
|
12301
|
-
doc.CDATA_SECTION_NODE;
|
|
12302
|
-
doc.COMMENT_NODE;
|
|
12303
|
-
doc.DOCUMENT_NODE;
|
|
12304
|
-
doc.DOCUMENT_TYPE_NODE;
|
|
12305
|
-
doc.DOCUMENT_FRAGMENT_NODE;
|
|
12306
|
-
const min = (a, b) => a < b ? a : b;
|
|
12307
|
-
const max = (a, b) => a > b ? a : b;
|
|
12308
|
-
const yRemoteSelectionsTheme = EditorView.baseTheme({
|
|
12309
|
-
".cm-ySelection": {},
|
|
12310
|
-
".cm-yLineSelection": {
|
|
12311
|
-
padding: 0,
|
|
12312
|
-
margin: "0px 2px 0px 4px"
|
|
12313
|
-
},
|
|
12314
|
-
".cm-ySelectionCaret": {
|
|
12315
|
-
position: "relative",
|
|
12316
|
-
borderLeft: "1px solid black",
|
|
12317
|
-
borderRight: "1px solid black",
|
|
12318
|
-
marginLeft: "-1px",
|
|
12319
|
-
marginRight: "-1px",
|
|
12320
|
-
boxSizing: "border-box",
|
|
12321
|
-
display: "inline"
|
|
12322
|
-
},
|
|
12323
|
-
".cm-ySelectionCaretDot": {
|
|
12324
|
-
borderRadius: "50%",
|
|
12325
|
-
position: "absolute",
|
|
12326
|
-
width: ".4em",
|
|
12327
|
-
height: ".4em",
|
|
12328
|
-
top: "-.2em",
|
|
12329
|
-
left: "-.2em",
|
|
12330
|
-
backgroundColor: "inherit",
|
|
12331
|
-
transition: "transform .3s ease-in-out",
|
|
12332
|
-
boxSizing: "border-box"
|
|
12333
|
-
},
|
|
12334
|
-
".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot": {
|
|
12335
|
-
transformOrigin: "bottom center",
|
|
12336
|
-
transform: "scale(0)"
|
|
12337
|
-
},
|
|
12338
|
-
".cm-ySelectionInfo": {
|
|
12339
|
-
position: "absolute",
|
|
12340
|
-
top: "-1.05em",
|
|
12341
|
-
left: "-1px",
|
|
12342
|
-
fontSize: ".75em",
|
|
12343
|
-
fontFamily: "serif",
|
|
12344
|
-
fontStyle: "normal",
|
|
12345
|
-
fontWeight: "normal",
|
|
12346
|
-
lineHeight: "normal",
|
|
12347
|
-
userSelect: "none",
|
|
12348
|
-
color: "white",
|
|
12349
|
-
paddingLeft: "2px",
|
|
12350
|
-
paddingRight: "2px",
|
|
12351
|
-
zIndex: 101,
|
|
12352
|
-
transition: "opacity .3s ease-in-out",
|
|
12353
|
-
backgroundColor: "inherit",
|
|
12354
|
-
// these should be separate
|
|
12355
|
-
opacity: 0,
|
|
12356
|
-
transitionDelay: "0s",
|
|
12357
|
-
whiteSpace: "nowrap"
|
|
12358
|
-
},
|
|
12359
|
-
".cm-ySelectionCaret:hover > .cm-ySelectionInfo": {
|
|
12360
|
-
opacity: 1,
|
|
12361
|
-
transitionDelay: "0s"
|
|
12362
|
-
}
|
|
12363
|
-
});
|
|
12364
|
-
const yRemoteSelectionsAnnotation = Annotation.define();
|
|
12365
|
-
class YRemoteCaretWidget extends WidgetType {
|
|
12366
|
-
/**
|
|
12367
|
-
* @param {string} color
|
|
12368
|
-
* @param {string} name
|
|
12369
|
-
*/
|
|
12370
|
-
constructor(color, name2) {
|
|
12371
|
-
super();
|
|
12372
|
-
this.color = color;
|
|
12373
|
-
this.name = name2;
|
|
12374
|
-
}
|
|
12375
|
-
toDOM() {
|
|
12376
|
-
return (
|
|
12377
|
-
/** @type {HTMLElement} */
|
|
12378
|
-
element("span", [create("class", "cm-ySelectionCaret"), create("style", `background-color: ${this.color}; border-color: ${this.color}`)], [
|
|
12379
|
-
text(""),
|
|
12380
|
-
element("div", [
|
|
12381
|
-
create("class", "cm-ySelectionCaretDot")
|
|
12382
|
-
]),
|
|
12383
|
-
text(""),
|
|
12384
|
-
element("div", [
|
|
12385
|
-
create("class", "cm-ySelectionInfo")
|
|
12386
|
-
], [
|
|
12387
|
-
text(this.name)
|
|
12388
|
-
]),
|
|
12389
|
-
text("")
|
|
12390
|
-
])
|
|
12391
|
-
);
|
|
12392
|
-
}
|
|
12393
|
-
eq(widget) {
|
|
12394
|
-
return widget.color === this.color;
|
|
12395
|
-
}
|
|
12396
|
-
compare(widget) {
|
|
12397
|
-
return widget.color === this.color;
|
|
12398
|
-
}
|
|
12399
|
-
updateDOM() {
|
|
12400
|
-
return false;
|
|
12401
|
-
}
|
|
12402
|
-
get estimatedHeight() {
|
|
12403
|
-
return -1;
|
|
12404
|
-
}
|
|
12405
|
-
ignoreEvent() {
|
|
12406
|
-
return true;
|
|
12407
|
-
}
|
|
12408
|
-
}
|
|
12409
|
-
class YRemoteSelectionsPluginValue {
|
|
12410
|
-
/**
|
|
12411
|
-
* @param {cmView.EditorView} view
|
|
12412
|
-
*/
|
|
12413
|
-
constructor(view) {
|
|
12414
|
-
this.conf = view.state.facet(ySyncFacet);
|
|
12415
|
-
this._listener = ({ added, updated, removed }, s, t2) => {
|
|
12416
|
-
const clients = added.concat(updated).concat(removed);
|
|
12417
|
-
if (clients.findIndex((id2) => id2 !== this.conf.awareness.doc.clientID) >= 0) {
|
|
12418
|
-
view.dispatch({ annotations: [yRemoteSelectionsAnnotation.of([])] });
|
|
12419
|
-
}
|
|
12420
|
-
};
|
|
12421
|
-
this._awareness = this.conf.awareness;
|
|
12422
|
-
this._awareness.on("change", this._listener);
|
|
12423
|
-
this.decorations = RangeSet.of([]);
|
|
12424
|
-
}
|
|
12425
|
-
destroy() {
|
|
12426
|
-
this._awareness.off("change", this._listener);
|
|
12427
|
-
}
|
|
12428
|
-
/**
|
|
12429
|
-
* @param {cmView.ViewUpdate} update
|
|
12430
|
-
*/
|
|
12431
|
-
update(update) {
|
|
12432
|
-
const ytext = this.conf.ytext;
|
|
12433
|
-
const ydoc = (
|
|
12434
|
-
/** @type {Y.Doc} */
|
|
12435
|
-
ytext.doc
|
|
12436
|
-
);
|
|
12437
|
-
const awareness = this.conf.awareness;
|
|
12438
|
-
const decorations2 = [];
|
|
12439
|
-
const localAwarenessState = this.conf.awareness.getLocalState();
|
|
12440
|
-
if (localAwarenessState != null) {
|
|
12441
|
-
const hasFocus = update.view.hasFocus && update.view.dom.ownerDocument.hasFocus();
|
|
12442
|
-
const sel = hasFocus ? update.state.selection.main : null;
|
|
12443
|
-
const currentAnchor = localAwarenessState.cursor == null ? null : Y.createRelativePositionFromJSON(localAwarenessState.cursor.anchor);
|
|
12444
|
-
const currentHead = localAwarenessState.cursor == null ? null : Y.createRelativePositionFromJSON(localAwarenessState.cursor.head);
|
|
12445
|
-
if (sel != null) {
|
|
12446
|
-
const anchor = Y.createRelativePositionFromTypeIndex(ytext, sel.anchor);
|
|
12447
|
-
const head = Y.createRelativePositionFromTypeIndex(ytext, sel.head);
|
|
12448
|
-
if (localAwarenessState.cursor == null || !Y.compareRelativePositions(currentAnchor, anchor) || !Y.compareRelativePositions(currentHead, head)) {
|
|
12449
|
-
awareness.setLocalStateField("cursor", {
|
|
12450
|
-
anchor,
|
|
12451
|
-
head
|
|
12452
|
-
});
|
|
12453
|
-
}
|
|
12454
|
-
} else if (localAwarenessState.cursor != null && hasFocus) {
|
|
12455
|
-
awareness.setLocalStateField("cursor", null);
|
|
12456
|
-
}
|
|
12457
|
-
}
|
|
12458
|
-
awareness.getStates().forEach((state, clientid) => {
|
|
12459
|
-
if (clientid === awareness.doc.clientID) {
|
|
12460
|
-
return;
|
|
12461
|
-
}
|
|
12462
|
-
const cursor = state.cursor;
|
|
12463
|
-
if (cursor == null || cursor.anchor == null || cursor.head == null) {
|
|
12464
|
-
return;
|
|
12465
|
-
}
|
|
12466
|
-
const anchor = Y.createAbsolutePositionFromRelativePosition(cursor.anchor, ydoc);
|
|
12467
|
-
const head = Y.createAbsolutePositionFromRelativePosition(cursor.head, ydoc);
|
|
12468
|
-
if (anchor == null || head == null || anchor.type !== ytext || head.type !== ytext) {
|
|
12469
|
-
return;
|
|
12470
|
-
}
|
|
12471
|
-
const { color = "#30bced", name: name2 = "Anonymous" } = state.user || {};
|
|
12472
|
-
const colorLight = state.user && state.user.colorLight || color + "33";
|
|
12473
|
-
const start = min(anchor.index, head.index);
|
|
12474
|
-
const end = max(anchor.index, head.index);
|
|
12475
|
-
const startLine = update.view.state.doc.lineAt(start);
|
|
12476
|
-
const endLine = update.view.state.doc.lineAt(end);
|
|
12477
|
-
if (startLine.number === endLine.number) {
|
|
12478
|
-
decorations2.push({
|
|
12479
|
-
from: start,
|
|
12480
|
-
to: end,
|
|
12481
|
-
value: Decoration.mark({
|
|
12482
|
-
attributes: { style: `background-color: ${colorLight}` },
|
|
12483
|
-
class: "cm-ySelection"
|
|
12484
|
-
})
|
|
12485
|
-
});
|
|
12486
|
-
} else {
|
|
12487
|
-
decorations2.push({
|
|
12488
|
-
from: start,
|
|
12489
|
-
to: startLine.from + startLine.length,
|
|
12490
|
-
value: Decoration.mark({
|
|
12491
|
-
attributes: { style: `background-color: ${colorLight}` },
|
|
12492
|
-
class: "cm-ySelection"
|
|
12493
|
-
})
|
|
12494
|
-
});
|
|
12495
|
-
decorations2.push({
|
|
12496
|
-
from: endLine.from,
|
|
12497
|
-
to: end,
|
|
12498
|
-
value: Decoration.mark({
|
|
12499
|
-
attributes: { style: `background-color: ${colorLight}` },
|
|
12500
|
-
class: "cm-ySelection"
|
|
12501
|
-
})
|
|
12502
|
-
});
|
|
12503
|
-
for (let i = startLine.number + 1; i < endLine.number; i++) {
|
|
12504
|
-
const linePos = update.view.state.doc.line(i).from;
|
|
12505
|
-
decorations2.push({
|
|
12506
|
-
from: linePos,
|
|
12507
|
-
to: linePos,
|
|
12508
|
-
value: Decoration.line({
|
|
12509
|
-
attributes: { style: `background-color: ${colorLight}`, class: "cm-yLineSelection" }
|
|
12510
|
-
})
|
|
12511
|
-
});
|
|
12512
|
-
}
|
|
12513
|
-
}
|
|
12514
|
-
decorations2.push({
|
|
12515
|
-
from: head.index,
|
|
12516
|
-
to: head.index,
|
|
12517
|
-
value: Decoration.widget({
|
|
12518
|
-
side: head.index - anchor.index > 0 ? -1 : 1,
|
|
12519
|
-
// the local cursor should be rendered outside the remote selection
|
|
12520
|
-
block: false,
|
|
12521
|
-
widget: new YRemoteCaretWidget(color, name2)
|
|
12522
|
-
})
|
|
12523
|
-
});
|
|
12524
|
-
});
|
|
12525
|
-
this.decorations = Decoration.set(decorations2, true);
|
|
12526
|
-
}
|
|
12527
|
-
}
|
|
12528
|
-
const yRemoteSelections = ViewPlugin.fromClass(YRemoteSelectionsPluginValue, {
|
|
12529
|
-
decorations: (v) => v.decorations
|
|
12530
|
-
});
|
|
12531
|
-
const createMutex = () => {
|
|
12532
|
-
let token = true;
|
|
12533
|
-
return (f, g) => {
|
|
12534
|
-
if (token) {
|
|
12535
|
-
token = false;
|
|
12536
|
-
try {
|
|
12537
|
-
f();
|
|
12538
|
-
} finally {
|
|
12539
|
-
token = true;
|
|
12540
|
-
}
|
|
12541
|
-
} else if (g !== void 0) {
|
|
12542
|
-
g();
|
|
12543
|
-
}
|
|
12544
|
-
};
|
|
12545
|
-
};
|
|
12546
|
-
class YUndoManagerConfig {
|
|
12547
|
-
/**
|
|
12548
|
-
* @param {Y.UndoManager} undoManager
|
|
12549
|
-
*/
|
|
12550
|
-
constructor(undoManager) {
|
|
12551
|
-
this.undoManager = undoManager;
|
|
12552
|
-
}
|
|
12553
|
-
/**
|
|
12554
|
-
* @param {any} origin
|
|
12555
|
-
*/
|
|
12556
|
-
addTrackedOrigin(origin) {
|
|
12557
|
-
this.undoManager.addTrackedOrigin(origin);
|
|
12558
|
-
}
|
|
12559
|
-
/**
|
|
12560
|
-
* @param {any} origin
|
|
12561
|
-
*/
|
|
12562
|
-
removeTrackedOrigin(origin) {
|
|
12563
|
-
this.undoManager.removeTrackedOrigin(origin);
|
|
12564
|
-
}
|
|
12565
|
-
/**
|
|
12566
|
-
* @return {boolean} Whether a change was undone.
|
|
12567
|
-
*/
|
|
12568
|
-
undo() {
|
|
12569
|
-
return this.undoManager.undo() != null;
|
|
12570
|
-
}
|
|
12571
|
-
/**
|
|
12572
|
-
* @return {boolean} Whether a change was redone.
|
|
12573
|
-
*/
|
|
12574
|
-
redo() {
|
|
12575
|
-
return this.undoManager.redo() != null;
|
|
12576
|
-
}
|
|
12577
|
-
}
|
|
12578
|
-
const yUndoManagerFacet = Facet.define({
|
|
12579
|
-
combine(inputs) {
|
|
12580
|
-
return inputs[inputs.length - 1];
|
|
12581
|
-
}
|
|
12582
|
-
});
|
|
12583
|
-
class YUndoManagerPluginValue {
|
|
12584
|
-
/**
|
|
12585
|
-
* @param {cmView.EditorView} view
|
|
12586
|
-
*/
|
|
12587
|
-
constructor(view) {
|
|
12588
|
-
this.view = view;
|
|
12589
|
-
this.conf = view.state.facet(yUndoManagerFacet);
|
|
12590
|
-
this._undoManager = this.conf.undoManager;
|
|
12591
|
-
this.syncConf = view.state.facet(ySyncFacet);
|
|
12592
|
-
this._beforeChangeSelection = null;
|
|
12593
|
-
this._mux = createMutex();
|
|
12594
|
-
this._onStackItemAdded = ({ stackItem, changedParentTypes }) => {
|
|
12595
|
-
if (changedParentTypes.has(this.syncConf.ytext) && this._beforeChangeSelection && !stackItem.meta.has(this)) {
|
|
12596
|
-
stackItem.meta.set(this, this._beforeChangeSelection);
|
|
12597
|
-
}
|
|
12598
|
-
};
|
|
12599
|
-
this._onStackItemPopped = ({ stackItem }) => {
|
|
12600
|
-
const sel = stackItem.meta.get(this);
|
|
12601
|
-
if (sel) {
|
|
12602
|
-
const selection = this.syncConf.fromYRange(sel);
|
|
12603
|
-
view.dispatch(view.state.update({ selection }));
|
|
12604
|
-
this._storeSelection();
|
|
12605
|
-
}
|
|
12606
|
-
};
|
|
12607
|
-
this._storeSelection = () => {
|
|
12608
|
-
this._beforeChangeSelection = this.syncConf.toYRange(this.view.state.selection.main);
|
|
12609
|
-
};
|
|
12610
|
-
this._undoManager.on("stack-item-added", this._onStackItemAdded);
|
|
12611
|
-
this._undoManager.on("stack-item-popped", this._onStackItemPopped);
|
|
12612
|
-
this._undoManager.addTrackedOrigin(this.syncConf);
|
|
12613
|
-
}
|
|
12614
|
-
/**
|
|
12615
|
-
* @param {cmView.ViewUpdate} update
|
|
12616
|
-
*/
|
|
12617
|
-
update(update) {
|
|
12618
|
-
if (update.selectionSet && (update.transactions.length === 0 || update.transactions[0].annotation(ySyncAnnotation) !== this.syncConf)) {
|
|
12619
|
-
this._storeSelection();
|
|
12620
|
-
}
|
|
12621
|
-
}
|
|
12622
|
-
destroy() {
|
|
12623
|
-
this._undoManager.off("stack-item-added", this._onStackItemAdded);
|
|
12624
|
-
this._undoManager.off("stack-item-popped", this._onStackItemPopped);
|
|
12625
|
-
this._undoManager.removeTrackedOrigin(this.syncConf);
|
|
12626
|
-
}
|
|
12627
|
-
}
|
|
12628
|
-
const yUndoManager = ViewPlugin.fromClass(YUndoManagerPluginValue);
|
|
12629
|
-
const undo = ({ state, dispatch }) => state.facet(yUndoManagerFacet).undo() || true;
|
|
12630
|
-
const redo = ({ state, dispatch }) => state.facet(yUndoManagerFacet).redo() || true;
|
|
12631
|
-
const yCollab = (ytext, awareness, { undoManager = new Y.UndoManager(ytext) } = {}) => {
|
|
12632
|
-
const ySyncConfig = new YSyncConfig(ytext, awareness);
|
|
12633
|
-
const plugins = [
|
|
12634
|
-
ySyncFacet.of(ySyncConfig),
|
|
12635
|
-
ySync
|
|
12636
|
-
];
|
|
12637
|
-
if (awareness) {
|
|
12638
|
-
plugins.push(
|
|
12639
|
-
yRemoteSelectionsTheme,
|
|
12640
|
-
yRemoteSelections
|
|
12641
|
-
);
|
|
12642
|
-
}
|
|
12643
|
-
if (undoManager !== false) {
|
|
12644
|
-
plugins.push(
|
|
12645
|
-
yUndoManagerFacet.of(new YUndoManagerConfig(undoManager)),
|
|
12646
|
-
yUndoManager,
|
|
12647
|
-
EditorView.domEventHandlers({
|
|
12648
|
-
beforeinput(e, view) {
|
|
12649
|
-
if (e.inputType === "historyUndo")
|
|
12650
|
-
return undo(view);
|
|
12651
|
-
if (e.inputType === "historyRedo")
|
|
12652
|
-
return redo(view);
|
|
12653
|
-
return false;
|
|
12654
|
-
}
|
|
12655
|
-
})
|
|
12656
|
-
);
|
|
12657
|
-
}
|
|
12658
|
-
return plugins;
|
|
12659
|
-
};
|
|
12660
12094
|
const DefaultBufferLength = 1024;
|
|
12661
12095
|
let nextPropID = 0;
|
|
12662
12096
|
class Range2 {
|
|
@@ -15966,18 +15400,18 @@ class IndentContext {
|
|
|
15966
15400
|
textAfterPos(pos, bias = 1) {
|
|
15967
15401
|
if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak)
|
|
15968
15402
|
return "";
|
|
15969
|
-
let { text
|
|
15970
|
-
return
|
|
15403
|
+
let { text, from } = this.lineAt(pos, bias);
|
|
15404
|
+
return text.slice(pos - from, Math.min(text.length, pos + 100 - from));
|
|
15971
15405
|
}
|
|
15972
15406
|
/**
|
|
15973
15407
|
Find the column for the given position.
|
|
15974
15408
|
*/
|
|
15975
15409
|
column(pos, bias = 1) {
|
|
15976
|
-
let { text
|
|
15977
|
-
let result = this.countColumn(
|
|
15410
|
+
let { text, from } = this.lineAt(pos, bias);
|
|
15411
|
+
let result = this.countColumn(text, pos - from);
|
|
15978
15412
|
let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;
|
|
15979
15413
|
if (override > -1)
|
|
15980
|
-
result += override - this.countColumn(
|
|
15414
|
+
result += override - this.countColumn(text, text.search(/\S|$/));
|
|
15981
15415
|
return result;
|
|
15982
15416
|
}
|
|
15983
15417
|
/**
|
|
@@ -15991,14 +15425,14 @@ class IndentContext {
|
|
|
15991
15425
|
Find the indentation column of the line at the given point.
|
|
15992
15426
|
*/
|
|
15993
15427
|
lineIndent(pos, bias = 1) {
|
|
15994
|
-
let { text
|
|
15428
|
+
let { text, from } = this.lineAt(pos, bias);
|
|
15995
15429
|
let override = this.options.overrideIndentation;
|
|
15996
15430
|
if (override) {
|
|
15997
15431
|
let overriden = override(from);
|
|
15998
15432
|
if (overriden > -1)
|
|
15999
15433
|
return overriden;
|
|
16000
15434
|
}
|
|
16001
|
-
return this.countColumn(
|
|
15435
|
+
return this.countColumn(text, text.search(/\S|$/));
|
|
16002
15436
|
}
|
|
16003
15437
|
/**
|
|
16004
15438
|
Returns the [simulated line
|
|
@@ -16480,12 +15914,12 @@ function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, b
|
|
|
16480
15914
|
let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };
|
|
16481
15915
|
let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;
|
|
16482
15916
|
for (let distance = 0; !iter.next().done && distance <= maxScanDistance; ) {
|
|
16483
|
-
let
|
|
15917
|
+
let text = iter.value;
|
|
16484
15918
|
if (dir < 0)
|
|
16485
|
-
distance +=
|
|
15919
|
+
distance += text.length;
|
|
16486
15920
|
let basePos = pos + distance * dir;
|
|
16487
|
-
for (let pos2 = dir > 0 ? 0 :
|
|
16488
|
-
let found = brackets.indexOf(
|
|
15921
|
+
for (let pos2 = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos2 != end; pos2 += dir) {
|
|
15922
|
+
let found = brackets.indexOf(text[pos2]);
|
|
16489
15923
|
if (found < 0 || tree.resolveInner(basePos + pos2, 1).type != tokenType)
|
|
16490
15924
|
continue;
|
|
16491
15925
|
if (found % 2 == 0 == dir > 0) {
|
|
@@ -16497,7 +15931,7 @@ function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, b
|
|
|
16497
15931
|
}
|
|
16498
15932
|
}
|
|
16499
15933
|
if (dir > 0)
|
|
16500
|
-
distance +=
|
|
15934
|
+
distance += text.length;
|
|
16501
15935
|
}
|
|
16502
15936
|
return iter.done ? { start: startToken, matched: false } : null;
|
|
16503
15937
|
}
|
|
@@ -16971,25 +16405,25 @@ function rgbToHSL(r, g, b) {
|
|
|
16971
16405
|
const redPercent = r / 255;
|
|
16972
16406
|
const greenPercent = g / 255;
|
|
16973
16407
|
const bluePercent = b / 255;
|
|
16974
|
-
const
|
|
16975
|
-
const
|
|
16976
|
-
const luminance = (
|
|
16977
|
-
if (
|
|
16408
|
+
const min = Math.min(redPercent, greenPercent, bluePercent);
|
|
16409
|
+
const max = Math.max(redPercent, greenPercent, bluePercent);
|
|
16410
|
+
const luminance = (max + min) / 2;
|
|
16411
|
+
if (max === min) {
|
|
16978
16412
|
return [0, 0, luminance];
|
|
16979
16413
|
}
|
|
16980
16414
|
let saturation;
|
|
16981
16415
|
if (luminance <= 0.5) {
|
|
16982
|
-
saturation = (
|
|
16416
|
+
saturation = (max - min) / (max + min);
|
|
16983
16417
|
} else {
|
|
16984
|
-
saturation = (
|
|
16418
|
+
saturation = (max - min) / (2 - max - min);
|
|
16985
16419
|
}
|
|
16986
16420
|
let hue;
|
|
16987
|
-
if (
|
|
16988
|
-
hue = (greenPercent - bluePercent) / (
|
|
16989
|
-
} else if (greenPercent ===
|
|
16990
|
-
hue = 2 + (bluePercent - redPercent) / (
|
|
16421
|
+
if (max === redPercent) {
|
|
16422
|
+
hue = (greenPercent - bluePercent) / (max - min);
|
|
16423
|
+
} else if (greenPercent === max) {
|
|
16424
|
+
hue = 2 + (bluePercent - redPercent) / (max - min);
|
|
16991
16425
|
} else {
|
|
16992
|
-
hue = 4 + (redPercent - greenPercent) / (
|
|
16426
|
+
hue = 4 + (redPercent - greenPercent) / (max - min);
|
|
16993
16427
|
}
|
|
16994
16428
|
hue = Math.round(hue * 60);
|
|
16995
16429
|
while (hue < 0) {
|
|
@@ -17202,14 +16636,14 @@ function ensureAnchor(expr, start) {
|
|
|
17202
16636
|
return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, (_a2 = expr.flags) !== null && _a2 !== void 0 ? _a2 : expr.ignoreCase ? "i" : "");
|
|
17203
16637
|
}
|
|
17204
16638
|
const pickedCompletion = /* @__PURE__ */ Annotation.define();
|
|
17205
|
-
function insertCompletionText(state,
|
|
16639
|
+
function insertCompletionText(state, text, from, to) {
|
|
17206
16640
|
let { main } = state.selection, fromOff = from - main.from, toOff = to - main.from;
|
|
17207
16641
|
return Object.assign(Object.assign({}, state.changeByRange((range) => {
|
|
17208
16642
|
if (range != main && from != to && state.sliceDoc(range.from + fromOff, range.from + toOff) != state.sliceDoc(from, to))
|
|
17209
16643
|
return { range };
|
|
17210
16644
|
return {
|
|
17211
|
-
changes: { from: range.from + fromOff, to: to == main.from ? range.to : range.from + toOff, insert:
|
|
17212
|
-
range: EditorSelection.cursor(range.from + fromOff +
|
|
16645
|
+
changes: { from: range.from + fromOff, to: to == main.from ? range.to : range.from + toOff, insert: text },
|
|
16646
|
+
range: EditorSelection.cursor(range.from + fromOff + text.length)
|
|
17213
16647
|
};
|
|
17214
16648
|
})), { scrollIntoView: true, userEvent: "input.complete" });
|
|
17215
16649
|
}
|
|
@@ -17454,17 +16888,17 @@ function optionContent(config2) {
|
|
|
17454
16888
|
});
|
|
17455
16889
|
return content2.sort((a, b) => a.position - b.position).map((a) => a.render);
|
|
17456
16890
|
}
|
|
17457
|
-
function rangeAroundSelected(total, selected,
|
|
17458
|
-
if (total <=
|
|
16891
|
+
function rangeAroundSelected(total, selected, max) {
|
|
16892
|
+
if (total <= max)
|
|
17459
16893
|
return { from: 0, to: total };
|
|
17460
16894
|
if (selected < 0)
|
|
17461
16895
|
selected = 0;
|
|
17462
16896
|
if (selected <= total >> 1) {
|
|
17463
|
-
let off2 = Math.floor(selected /
|
|
17464
|
-
return { from: off2 *
|
|
16897
|
+
let off2 = Math.floor(selected / max);
|
|
16898
|
+
return { from: off2 * max, to: (off2 + 1) * max };
|
|
17465
16899
|
}
|
|
17466
|
-
let off = Math.floor((total - selected) /
|
|
17467
|
-
return { from: total - (off + 1) *
|
|
16900
|
+
let off = Math.floor((total - selected) / max);
|
|
16901
|
+
return { from: total - (off + 1) * max, to: total - off * max };
|
|
17468
16902
|
}
|
|
17469
16903
|
class CompletionTooltip {
|
|
17470
16904
|
constructor(view, stateField, applyCompletion2) {
|
|
@@ -17692,9 +17126,9 @@ class CompletionTooltip {
|
|
|
17692
17126
|
function completionTooltip(stateField, applyCompletion2) {
|
|
17693
17127
|
return (view) => new CompletionTooltip(view, stateField, applyCompletion2);
|
|
17694
17128
|
}
|
|
17695
|
-
function scrollIntoView(container,
|
|
17129
|
+
function scrollIntoView(container, element) {
|
|
17696
17130
|
let parent = container.getBoundingClientRect();
|
|
17697
|
-
let self =
|
|
17131
|
+
let self = element.getBoundingClientRect();
|
|
17698
17132
|
let scaleY = parent.height / container.offsetHeight;
|
|
17699
17133
|
if (self.top < parent.top)
|
|
17700
17134
|
container.scrollTop -= (parent.top - self.top) / scaleY;
|
|
@@ -17986,8 +17420,8 @@ class ActiveResult extends ActiveSource {
|
|
|
17986
17420
|
function checkValid(validFor, state, from, to) {
|
|
17987
17421
|
if (!validFor)
|
|
17988
17422
|
return false;
|
|
17989
|
-
let
|
|
17990
|
-
return typeof validFor == "function" ? validFor(
|
|
17423
|
+
let text = state.sliceDoc(from, to);
|
|
17424
|
+
return typeof validFor == "function" ? validFor(text, from, to, state) : ensureAnchor(validFor, true).test(text);
|
|
17991
17425
|
}
|
|
17992
17426
|
const setActiveEffect = /* @__PURE__ */ StateEffect.define({
|
|
17993
17427
|
map(sources, mapping) {
|
|
@@ -18362,21 +17796,21 @@ class Snippet {
|
|
|
18362
17796
|
this.fieldPositions = fieldPositions;
|
|
18363
17797
|
}
|
|
18364
17798
|
instantiate(state, pos) {
|
|
18365
|
-
let
|
|
17799
|
+
let text = [], lineStart = [pos];
|
|
18366
17800
|
let lineObj = state.doc.lineAt(pos), baseIndent = /^\s*/.exec(lineObj.text)[0];
|
|
18367
17801
|
for (let line of this.lines) {
|
|
18368
|
-
if (
|
|
17802
|
+
if (text.length) {
|
|
18369
17803
|
let indent = baseIndent, tabs = /^\t*/.exec(line)[0].length;
|
|
18370
17804
|
for (let i = 0; i < tabs; i++)
|
|
18371
17805
|
indent += state.facet(indentUnit);
|
|
18372
17806
|
lineStart.push(pos + indent.length - tabs);
|
|
18373
17807
|
line = indent + line.slice(tabs);
|
|
18374
17808
|
}
|
|
18375
|
-
|
|
17809
|
+
text.push(line);
|
|
18376
17810
|
pos += line.length + 1;
|
|
18377
17811
|
}
|
|
18378
17812
|
let ranges = this.fieldPositions.map((pos2) => new FieldRange(pos2.field, lineStart[pos2.line] + pos2.from, lineStart[pos2.line] + pos2.to));
|
|
18379
|
-
return { text
|
|
17813
|
+
return { text, ranges };
|
|
18380
17814
|
}
|
|
18381
17815
|
static parse(template) {
|
|
18382
17816
|
let fields = [];
|
|
@@ -18476,9 +17910,9 @@ function fieldSelection(ranges, field) {
|
|
|
18476
17910
|
function snippet(template) {
|
|
18477
17911
|
let snippet2 = Snippet.parse(template);
|
|
18478
17912
|
return (editor, completion, from, to) => {
|
|
18479
|
-
let { text
|
|
17913
|
+
let { text, ranges } = snippet2.instantiate(editor.state, from);
|
|
18480
17914
|
let spec = {
|
|
18481
|
-
changes: { from, to, insert: Text.of(
|
|
17915
|
+
changes: { from, to, insert: Text.of(text) },
|
|
18482
17916
|
scrollIntoView: true,
|
|
18483
17917
|
annotations: completion ? [pickedCompletion.of(completion), Transaction.userEvent.of("input.complete")] : void 0
|
|
18484
17918
|
};
|
|
@@ -22339,16 +21773,16 @@ function findOpenTag(node) {
|
|
|
22339
21773
|
node = node.parent;
|
|
22340
21774
|
}
|
|
22341
21775
|
}
|
|
22342
|
-
function elementName$1(doc2, tree,
|
|
21776
|
+
function elementName$1(doc2, tree, max = doc2.length) {
|
|
22343
21777
|
for (let ch = tree === null || tree === void 0 ? void 0 : tree.firstChild; ch; ch = ch.nextSibling) {
|
|
22344
21778
|
if (ch.name == "JSXIdentifier" || ch.name == "JSXBuiltin" || ch.name == "JSXNamespacedName" || ch.name == "JSXMemberExpression")
|
|
22345
|
-
return doc2.sliceString(ch.from, Math.min(ch.to,
|
|
21779
|
+
return doc2.sliceString(ch.from, Math.min(ch.to, max));
|
|
22346
21780
|
}
|
|
22347
21781
|
return "";
|
|
22348
21782
|
}
|
|
22349
21783
|
const android = typeof navigator == "object" && /* @__PURE__ */ /Android\b/.test(navigator.userAgent);
|
|
22350
|
-
const autoCloseTags$1 = /* @__PURE__ */ EditorView.inputHandler.of((view, from, to,
|
|
22351
|
-
if ((android ? view.composing : view.compositionStarted) || view.state.readOnly || from != to ||
|
|
21784
|
+
const autoCloseTags$1 = /* @__PURE__ */ EditorView.inputHandler.of((view, from, to, text, defaultInsert) => {
|
|
21785
|
+
if ((android ? view.composing : view.compositionStarted) || view.state.readOnly || from != to || text != ">" && text != "/" || !javascriptLanguage.isActiveAt(view.state, from, -1))
|
|
22352
21786
|
return false;
|
|
22353
21787
|
let base2 = defaultInsert(), { state } = base2;
|
|
22354
21788
|
let closeTags = state.changeByRange((range) => {
|
|
@@ -22356,17 +21790,17 @@ const autoCloseTags$1 = /* @__PURE__ */ EditorView.inputHandler.of((view, from,
|
|
|
22356
21790
|
let { head } = range, around = syntaxTree(state).resolveInner(head - 1, -1), name2;
|
|
22357
21791
|
if (around.name == "JSXStartTag")
|
|
22358
21792
|
around = around.parent;
|
|
22359
|
-
if (state.doc.sliceString(head - 1, head) !=
|
|
21793
|
+
if (state.doc.sliceString(head - 1, head) != text || around.name == "JSXAttributeValue" && around.to > head)
|
|
22360
21794
|
;
|
|
22361
|
-
else if (
|
|
21795
|
+
else if (text == ">" && around.name == "JSXFragmentTag") {
|
|
22362
21796
|
return { range, changes: { from: head, insert: `</>` } };
|
|
22363
|
-
} else if (
|
|
21797
|
+
} else if (text == "/" && around.name == "JSXStartCloseTag") {
|
|
22364
21798
|
let empty = around.parent, base3 = empty.parent;
|
|
22365
21799
|
if (base3 && empty.from == head - 2 && ((name2 = elementName$1(state.doc, base3.firstChild, head)) || ((_a2 = base3.firstChild) === null || _a2 === void 0 ? void 0 : _a2.name) == "JSXFragmentTag")) {
|
|
22366
21800
|
let insert2 = `${name2}>`;
|
|
22367
21801
|
return { range: EditorSelection.cursor(head + insert2.length, -1), changes: { from: head, insert: insert2 } };
|
|
22368
21802
|
}
|
|
22369
|
-
} else if (
|
|
21803
|
+
} else if (text == ">") {
|
|
22370
21804
|
let openTag = findOpenTag(around);
|
|
22371
21805
|
if (openTag && openTag.name == "JSXOpenTag" && !/^\/?>|^<\//.test(state.doc.sliceString(head, head + 2)) && (name2 = elementName$1(state.doc, openTag, head)))
|
|
22372
21806
|
return { range, changes: { from: head, insert: `</${name2}>` } };
|
|
@@ -22819,12 +22253,12 @@ class Schema {
|
|
|
22819
22253
|
}
|
|
22820
22254
|
}
|
|
22821
22255
|
Schema.default = /* @__PURE__ */ new Schema();
|
|
22822
|
-
function elementName(doc2, tree,
|
|
22256
|
+
function elementName(doc2, tree, max = doc2.length) {
|
|
22823
22257
|
if (!tree)
|
|
22824
22258
|
return "";
|
|
22825
22259
|
let tag = tree.firstChild;
|
|
22826
22260
|
let name2 = tag && tag.getChild("TagName");
|
|
22827
|
-
return name2 ? doc2.sliceString(name2.from, Math.min(name2.to,
|
|
22261
|
+
return name2 ? doc2.sliceString(name2.from, Math.min(name2.to, max)) : "";
|
|
22828
22262
|
}
|
|
22829
22263
|
function findParentElement(tree, skip = false) {
|
|
22830
22264
|
for (; tree; tree = tree.parent)
|
|
@@ -23066,23 +22500,23 @@ function html(config2 = {}) {
|
|
|
23066
22500
|
]);
|
|
23067
22501
|
}
|
|
23068
22502
|
const selfClosers = /* @__PURE__ */ new Set(/* @__PURE__ */ "area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" "));
|
|
23069
|
-
const autoCloseTags = /* @__PURE__ */ EditorView.inputHandler.of((view, from, to,
|
|
23070
|
-
if (view.composing || view.state.readOnly || from != to ||
|
|
22503
|
+
const autoCloseTags = /* @__PURE__ */ EditorView.inputHandler.of((view, from, to, text, insertTransaction) => {
|
|
22504
|
+
if (view.composing || view.state.readOnly || from != to || text != ">" && text != "/" || !htmlLanguage.isActiveAt(view.state, from, -1))
|
|
23071
22505
|
return false;
|
|
23072
22506
|
let base2 = insertTransaction(), { state } = base2;
|
|
23073
22507
|
let closeTags = state.changeByRange((range) => {
|
|
23074
22508
|
var _a2, _b, _c;
|
|
23075
|
-
let didType = state.doc.sliceString(range.from - 1, range.to) ==
|
|
22509
|
+
let didType = state.doc.sliceString(range.from - 1, range.to) == text;
|
|
23076
22510
|
let { head } = range, around = syntaxTree(state).resolveInner(head - 1, -1), name2;
|
|
23077
22511
|
if (around.name == "TagName" || around.name == "StartTag")
|
|
23078
22512
|
around = around.parent;
|
|
23079
|
-
if (didType &&
|
|
22513
|
+
if (didType && text == ">" && around.name == "OpenTag") {
|
|
23080
22514
|
if (((_b = (_a2 = around.parent) === null || _a2 === void 0 ? void 0 : _a2.lastChild) === null || _b === void 0 ? void 0 : _b.name) != "CloseTag" && (name2 = elementName(state.doc, around.parent, head)) && !selfClosers.has(name2)) {
|
|
23081
22515
|
let to2 = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
|
|
23082
22516
|
let insert2 = `</${name2}>`;
|
|
23083
22517
|
return { range, changes: { from: head, to: to2, insert: insert2 } };
|
|
23084
22518
|
}
|
|
23085
|
-
} else if (didType &&
|
|
22519
|
+
} else if (didType && text == "/" && around.name == "IncompleteCloseTag") {
|
|
23086
22520
|
let base3 = around.parent;
|
|
23087
22521
|
if (around.from == head - 2 && ((_c = base3.lastChild) === null || _c === void 0 ? void 0 : _c.name) != "CloseTag" && (name2 = elementName(state.doc, base3, head)) && !selfClosers.has(name2)) {
|
|
23088
22522
|
let to2 = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
|