@rcarls/rc-textarea 0.5.0 → 0.7.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/CHANGELOG.md +204 -0
- package/README.md +67 -31
- package/dist/custom-elements.json +637 -41
- package/dist/folding-action-controller-sxM3IomW.js +91 -0
- package/dist/folding-action-controller-sxM3IomW.js.map +1 -0
- package/dist/{line-actions-controller-CB8U0WvH.js → line-actions-controller-DUdXQxMA.js} +912 -785
- package/dist/line-actions-controller-DUdXQxMA.js.map +1 -0
- package/dist/rc-textarea-define.js +2 -2
- package/dist/rc-textarea-folding.js +5 -0
- package/dist/rc-textarea-folding.js.map +1 -0
- package/dist/rc-textarea.js +1 -1
- package/dist/types/packages/rc-textarea/src/blots.d.ts +1 -1
- package/dist/types/packages/rc-textarea/src/decoration.d.ts +3 -2
- package/dist/types/packages/rc-textarea/src/document.d.ts +2 -1
- package/dist/types/packages/rc-textarea/src/folding-action-controller.d.ts +46 -0
- package/dist/types/packages/rc-textarea/src/folding.d.ts +2 -0
- package/dist/types/packages/rc-textarea/src/index.d.ts +7 -7
- package/dist/types/packages/rc-textarea/src/line-actions-controller.d.ts +5 -4
- package/dist/types/packages/rc-textarea/src/line-decorator.d.ts +1 -1
- package/dist/types/packages/rc-textarea/src/pattern-matcher.d.ts +1 -1
- package/dist/types/packages/rc-textarea/src/rc-textarea.d.ts +123 -20
- package/dist/types/packages/rc-textarea/src/selection.d.ts +2 -0
- package/dist/types/packages/rc-textarea/src/types.d.ts +52 -9
- package/package.json +9 -3
- package/dist/line-actions-controller-CB8U0WvH.js.map +0 -1
- package/dist/types/packages/rc-textarea/src/decoration.unit.test.d.ts +0 -1
- package/dist/types/packages/rc-textarea/src/line-decorator.test.d.ts +0 -1
- package/dist/types/packages/rc-textarea/src/pattern-matcher.unit.test.d.ts +0 -1
- package/dist/types/packages/rc-textarea/src/rc-textarea.test.d.ts +0 -0
- package/dist/types/packages/rc-textarea/src/test-helpers.d.ts +0 -20
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { property as
|
|
3
|
-
import { NativeChildController as
|
|
4
|
-
var
|
|
5
|
-
class
|
|
1
|
+
import { css as Ut, LitElement as ct, html as Vt } from "lit";
|
|
2
|
+
import { property as N, query as rt } from "lit/decorators.js";
|
|
3
|
+
import { NativeChildController as qt, FlowController as Wt, LocaleController as Kt, resolveFlow as V, numberFormat as Gt, cssZoom as jt, logicalRect as ht, isPhysicalReversed as Xt } from "@rcarls/rc-common";
|
|
4
|
+
var p = /* @__PURE__ */ ((r) => (r[r.TYPE = 3] = "TYPE", r[r.LEVEL = 12] = "LEVEL", r[r.ATTRIBUTE = 13] = "ATTRIBUTE", r[r.BLOT = 14] = "BLOT", r[r.INLINE = 7] = "INLINE", r[r.BLOCK = 11] = "BLOCK", r[r.BLOCK_BLOT = 10] = "BLOCK_BLOT", r[r.INLINE_BLOT = 6] = "INLINE_BLOT", r[r.BLOCK_ATTRIBUTE = 9] = "BLOCK_ATTRIBUTE", r[r.INLINE_ATTRIBUTE = 5] = "INLINE_ATTRIBUTE", r[r.ANY = 15] = "ANY", r))(p || {});
|
|
5
|
+
class D {
|
|
6
6
|
constructor(t, e, s = {}) {
|
|
7
7
|
this.attrName = t, this.keyName = e;
|
|
8
|
-
const i =
|
|
8
|
+
const i = p.TYPE & p.ATTRIBUTE;
|
|
9
9
|
this.scope = s.scope != null ? (
|
|
10
10
|
// Ignore type bits, force attribute bit
|
|
11
|
-
s.scope &
|
|
12
|
-
) :
|
|
11
|
+
s.scope & p.LEVEL | i
|
|
12
|
+
) : p.ATTRIBUTE, s.whitelist != null && (this.whitelist = s.whitelist);
|
|
13
13
|
}
|
|
14
14
|
static keys(t) {
|
|
15
15
|
return Array.from(t.attributes).map((e) => e.name);
|
|
@@ -28,12 +28,12 @@ class T {
|
|
|
28
28
|
return this.canAdd(t, e) && e ? e : "";
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
class
|
|
31
|
+
class T extends Error {
|
|
32
32
|
constructor(t) {
|
|
33
33
|
t = "[Parchment] " + t, super(t), this.message = t, this.name = this.constructor.name;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const Et = class tt {
|
|
37
37
|
constructor() {
|
|
38
38
|
this.attributes = {}, this.classes = {}, this.tags = {}, this.types = {};
|
|
39
39
|
}
|
|
@@ -56,40 +56,40 @@ const ut = class X {
|
|
|
56
56
|
create(t, e, s) {
|
|
57
57
|
const i = this.query(e);
|
|
58
58
|
if (i == null)
|
|
59
|
-
throw new
|
|
60
|
-
const
|
|
59
|
+
throw new T(`Unable to create ${e} blot`);
|
|
60
|
+
const n = i, o = (
|
|
61
61
|
// @ts-expect-error Fix me later
|
|
62
|
-
e instanceof Node || e.nodeType === Node.TEXT_NODE ? e :
|
|
63
|
-
), a = new
|
|
64
|
-
return
|
|
62
|
+
e instanceof Node || e.nodeType === Node.TEXT_NODE ? e : n.create(s)
|
|
63
|
+
), a = new n(t, o, s);
|
|
64
|
+
return tt.blots.set(a.domNode, a), a;
|
|
65
65
|
}
|
|
66
66
|
find(t, e = !1) {
|
|
67
|
-
return
|
|
67
|
+
return tt.find(t, e);
|
|
68
68
|
}
|
|
69
|
-
query(t, e =
|
|
69
|
+
query(t, e = p.ANY) {
|
|
70
70
|
let s;
|
|
71
|
-
return typeof t == "string" ? s = this.types[t] || this.attributes[t] : t instanceof Text || t.nodeType === Node.TEXT_NODE ? s = this.types.text : typeof t == "number" ? t &
|
|
71
|
+
return typeof t == "string" ? s = this.types[t] || this.attributes[t] : t instanceof Text || t.nodeType === Node.TEXT_NODE ? s = this.types.text : typeof t == "number" ? t & p.LEVEL & p.BLOCK ? s = this.types.block : t & p.LEVEL & p.INLINE && (s = this.types.inline) : t instanceof Element && ((t.getAttribute("class") || "").split(/\s+/).some((i) => (s = this.classes[i], !!s)), s = s || this.tags[t.tagName]), s == null ? null : "scope" in s && e & p.LEVEL & s.scope && e & p.TYPE & s.scope ? s : null;
|
|
72
72
|
}
|
|
73
73
|
register(...t) {
|
|
74
74
|
return t.map((e) => {
|
|
75
75
|
const s = "blotName" in e, i = "attrName" in e;
|
|
76
76
|
if (!s && !i)
|
|
77
|
-
throw new
|
|
77
|
+
throw new T("Invalid definition");
|
|
78
78
|
if (s && e.blotName === "abstract")
|
|
79
|
-
throw new
|
|
80
|
-
const
|
|
81
|
-
return this.types[
|
|
79
|
+
throw new T("Cannot register abstract class");
|
|
80
|
+
const n = s ? e.blotName : i ? e.attrName : void 0;
|
|
81
|
+
return this.types[n] = e, i ? typeof e.keyName == "string" && (this.attributes[e.keyName] = e) : s && (e.className && (this.classes[e.className] = e), e.tagName && (Array.isArray(e.tagName) ? e.tagName = e.tagName.map((o) => o.toUpperCase()) : e.tagName = e.tagName.toUpperCase(), (Array.isArray(e.tagName) ? e.tagName : [e.tagName]).forEach((o) => {
|
|
82
82
|
(this.tags[o] == null || e.className == null) && (this.tags[o] = e);
|
|
83
83
|
}))), e;
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
|
|
88
|
-
let
|
|
89
|
-
function
|
|
90
|
-
return (
|
|
87
|
+
Et.blots = /* @__PURE__ */ new WeakMap();
|
|
88
|
+
let q = Et;
|
|
89
|
+
function ut(r, t) {
|
|
90
|
+
return (r.getAttribute("class") || "").split(/\s+/).filter((e) => e.indexOf(`${t}-`) === 0);
|
|
91
91
|
}
|
|
92
|
-
class
|
|
92
|
+
class Yt extends D {
|
|
93
93
|
static keys(t) {
|
|
94
94
|
return (t.getAttribute("class") || "").split(/\s+/).map((e) => e.split("-").slice(0, -1).join("-"));
|
|
95
95
|
}
|
|
@@ -97,37 +97,37 @@ class Bt extends T {
|
|
|
97
97
|
return this.canAdd(t, e) ? (this.remove(t), t.classList.add(`${this.keyName}-${e}`), !0) : !1;
|
|
98
98
|
}
|
|
99
99
|
remove(t) {
|
|
100
|
-
|
|
100
|
+
ut(t, this.keyName).forEach((e) => {
|
|
101
101
|
t.classList.remove(e);
|
|
102
102
|
}), t.classList.length === 0 && t.removeAttribute("class");
|
|
103
103
|
}
|
|
104
104
|
value(t) {
|
|
105
|
-
const e = (
|
|
105
|
+
const e = (ut(t, this.keyName)[0] || "").slice(this.keyName.length + 1);
|
|
106
106
|
return this.canAdd(t, e) ? e : "";
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
const
|
|
110
|
-
function
|
|
111
|
-
const t =
|
|
109
|
+
const Zt = Yt;
|
|
110
|
+
function Z(r) {
|
|
111
|
+
const t = r.split("-"), e = t.slice(1).map((s) => s[0].toUpperCase() + s.slice(1)).join("");
|
|
112
112
|
return t[0] + e;
|
|
113
113
|
}
|
|
114
|
-
class
|
|
114
|
+
class Jt extends D {
|
|
115
115
|
static keys(t) {
|
|
116
116
|
return (t.getAttribute("style") || "").split(";").map((e) => e.split(":")[0].trim());
|
|
117
117
|
}
|
|
118
118
|
add(t, e) {
|
|
119
|
-
return this.canAdd(t, e) ? (t.style[
|
|
119
|
+
return this.canAdd(t, e) ? (t.style[Z(this.keyName)] = e, !0) : !1;
|
|
120
120
|
}
|
|
121
121
|
remove(t) {
|
|
122
|
-
t.style[
|
|
122
|
+
t.style[Z(this.keyName)] = "", t.getAttribute("style") || t.removeAttribute("style");
|
|
123
123
|
}
|
|
124
124
|
value(t) {
|
|
125
|
-
const e = t.style[
|
|
125
|
+
const e = t.style[Z(this.keyName)];
|
|
126
126
|
return this.canAdd(t, e) ? e : "";
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
const
|
|
130
|
-
class
|
|
129
|
+
const Qt = Jt;
|
|
130
|
+
class te {
|
|
131
131
|
constructor(t) {
|
|
132
132
|
this.attributes = {}, this.domNode = t, this.build();
|
|
133
133
|
}
|
|
@@ -136,13 +136,13 @@ class $t {
|
|
|
136
136
|
}
|
|
137
137
|
build() {
|
|
138
138
|
this.attributes = {};
|
|
139
|
-
const t =
|
|
139
|
+
const t = q.find(this.domNode);
|
|
140
140
|
if (t == null)
|
|
141
141
|
return;
|
|
142
|
-
const e =
|
|
143
|
-
e.concat(s).concat(i).forEach((
|
|
144
|
-
const o = t.scroll.query(
|
|
145
|
-
o instanceof
|
|
142
|
+
const e = D.keys(this.domNode), s = Zt.keys(this.domNode), i = Qt.keys(this.domNode);
|
|
143
|
+
e.concat(s).concat(i).forEach((n) => {
|
|
144
|
+
const o = t.scroll.query(n, p.ATTRIBUTE);
|
|
145
|
+
o instanceof D && (this.attributes[o.attrName] = o);
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
copy(t) {
|
|
@@ -163,13 +163,13 @@ class $t {
|
|
|
163
163
|
);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
const
|
|
166
|
+
const Ct = te, At = class {
|
|
167
167
|
constructor(t, e) {
|
|
168
|
-
this.scroll = t, this.domNode = e,
|
|
168
|
+
this.scroll = t, this.domNode = e, q.blots.set(e, this), this.prev = null, this.next = null;
|
|
169
169
|
}
|
|
170
170
|
static create(t) {
|
|
171
171
|
if (this.tagName == null)
|
|
172
|
-
throw new
|
|
172
|
+
throw new T("Blot definition missing tagName");
|
|
173
173
|
let e, s;
|
|
174
174
|
return Array.isArray(this.tagName) ? (typeof t == "string" ? (s = t.toUpperCase(), parseInt(s, 10).toString() === s && (s = parseInt(s, 10))) : typeof t == "number" && (s = t), typeof s == "number" ? e = document.createElement(this.tagName[s - 1]) : s && this.tagName.indexOf(s) > -1 ? e = document.createElement(s) : e = document.createElement(this.tagName[0])) : e = document.createElement(this.tagName), this.className && e.classList.add(this.className), e;
|
|
175
175
|
}
|
|
@@ -184,23 +184,23 @@ const dt = $t, ft = class {
|
|
|
184
184
|
return this.scroll.create(t);
|
|
185
185
|
}
|
|
186
186
|
detach() {
|
|
187
|
-
this.parent != null && this.parent.removeChild(this),
|
|
187
|
+
this.parent != null && this.parent.removeChild(this), q.blots.delete(this.domNode);
|
|
188
188
|
}
|
|
189
189
|
deleteAt(t, e) {
|
|
190
190
|
this.isolate(t, e).remove();
|
|
191
191
|
}
|
|
192
192
|
formatAt(t, e, s, i) {
|
|
193
|
-
const
|
|
194
|
-
if (this.scroll.query(s,
|
|
195
|
-
|
|
196
|
-
else if (this.scroll.query(s,
|
|
193
|
+
const n = this.isolate(t, e);
|
|
194
|
+
if (this.scroll.query(s, p.BLOT) != null && i)
|
|
195
|
+
n.wrap(s, i);
|
|
196
|
+
else if (this.scroll.query(s, p.ATTRIBUTE) != null) {
|
|
197
197
|
const o = this.scroll.create(this.statics.scope);
|
|
198
|
-
|
|
198
|
+
n.wrap(o), o.format(s, i);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
insertAt(t, e, s) {
|
|
202
|
-
const i = s == null ? this.scroll.create("text", e) : this.scroll.create(e, s),
|
|
203
|
-
this.parent.insertBefore(i,
|
|
202
|
+
const i = s == null ? this.scroll.create("text", e) : this.scroll.create(e, s), n = this.split(t);
|
|
203
|
+
this.parent.insertBefore(i, n || void 0);
|
|
204
204
|
}
|
|
205
205
|
isolate(t, e) {
|
|
206
206
|
const s = this.split(t);
|
|
@@ -232,13 +232,13 @@ const dt = $t, ft = class {
|
|
|
232
232
|
wrap(t, e) {
|
|
233
233
|
const s = typeof t == "string" ? this.scroll.create(t, e) : t;
|
|
234
234
|
if (this.parent != null && this.parent.insertBefore(s, this.next || void 0), typeof s.appendChild != "function")
|
|
235
|
-
throw new
|
|
235
|
+
throw new T(`Cannot wrap ${t}`);
|
|
236
236
|
return s.appendChild(this), s;
|
|
237
237
|
}
|
|
238
238
|
};
|
|
239
|
-
|
|
240
|
-
let
|
|
241
|
-
const
|
|
239
|
+
At.blotName = "abstract";
|
|
240
|
+
let Ot = At;
|
|
241
|
+
const Lt = class extends Ot {
|
|
242
242
|
/**
|
|
243
243
|
* Returns the value represented by domNode if it is this Blot's type
|
|
244
244
|
* No checking that domNode can represent this Blot type is required so
|
|
@@ -273,10 +273,10 @@ const mt = class extends pt {
|
|
|
273
273
|
};
|
|
274
274
|
}
|
|
275
275
|
};
|
|
276
|
-
|
|
277
|
-
let
|
|
278
|
-
const
|
|
279
|
-
class
|
|
276
|
+
Lt.scope = p.INLINE_BLOT;
|
|
277
|
+
let ee = Lt;
|
|
278
|
+
const X = ee;
|
|
279
|
+
class se {
|
|
280
280
|
constructor() {
|
|
281
281
|
this.head = null, this.tail = null, this.length = 0;
|
|
282
282
|
}
|
|
@@ -338,10 +338,10 @@ class Mt {
|
|
|
338
338
|
const s = this.iterator();
|
|
339
339
|
let i = s();
|
|
340
340
|
for (; i; ) {
|
|
341
|
-
const
|
|
342
|
-
if (t <
|
|
341
|
+
const n = i.length();
|
|
342
|
+
if (t < n || e && t === n && (i.next == null || i.next.length() !== 0))
|
|
343
343
|
return [i, t];
|
|
344
|
-
t -=
|
|
344
|
+
t -= n, i = s();
|
|
345
345
|
}
|
|
346
346
|
return [null, 0];
|
|
347
347
|
}
|
|
@@ -354,17 +354,17 @@ class Mt {
|
|
|
354
354
|
forEachAt(t, e, s) {
|
|
355
355
|
if (e <= 0)
|
|
356
356
|
return;
|
|
357
|
-
const [i,
|
|
358
|
-
let o = t -
|
|
357
|
+
const [i, n] = this.find(t);
|
|
358
|
+
let o = t - n;
|
|
359
359
|
const a = this.iterator(i);
|
|
360
360
|
let l = a();
|
|
361
361
|
for (; l && o < t + e; ) {
|
|
362
|
-
const
|
|
362
|
+
const c = l.length();
|
|
363
363
|
t > o ? s(
|
|
364
364
|
l,
|
|
365
365
|
t - o,
|
|
366
|
-
Math.min(e, o +
|
|
367
|
-
) : s(l, 0, Math.min(
|
|
366
|
+
Math.min(e, o + c - t)
|
|
367
|
+
) : s(l, 0, Math.min(c, t + e - o)), o += c, l = a();
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
map(t) {
|
|
@@ -378,20 +378,20 @@ class Mt {
|
|
|
378
378
|
return e;
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
|
-
function
|
|
382
|
-
const e = t.find(
|
|
381
|
+
function dt(r, t) {
|
|
382
|
+
const e = t.find(r);
|
|
383
383
|
if (e)
|
|
384
384
|
return e;
|
|
385
385
|
try {
|
|
386
|
-
return t.create(
|
|
386
|
+
return t.create(r);
|
|
387
387
|
} catch {
|
|
388
|
-
const s = t.create(
|
|
389
|
-
return Array.from(
|
|
388
|
+
const s = t.create(p.INLINE);
|
|
389
|
+
return Array.from(r.childNodes).forEach((i) => {
|
|
390
390
|
s.domNode.appendChild(i);
|
|
391
|
-
}),
|
|
391
|
+
}), r.parentNode && r.parentNode.replaceChild(s.domNode, r), s.attach(), s;
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
const
|
|
394
|
+
const St = class x extends Ot {
|
|
395
395
|
constructor(t, e) {
|
|
396
396
|
super(t, e), this.uiNode = null, this.build();
|
|
397
397
|
}
|
|
@@ -404,18 +404,18 @@ const gt = class N extends pt {
|
|
|
404
404
|
});
|
|
405
405
|
}
|
|
406
406
|
attachUI(t) {
|
|
407
|
-
this.uiNode != null && this.uiNode.remove(), this.uiNode = t,
|
|
407
|
+
this.uiNode != null && this.uiNode.remove(), this.uiNode = t, x.uiClass && this.uiNode.classList.add(x.uiClass), this.uiNode.setAttribute("contenteditable", "false"), this.domNode.insertBefore(this.uiNode, this.domNode.firstChild);
|
|
408
408
|
}
|
|
409
409
|
/**
|
|
410
410
|
* Called during construction, should fill its own children LinkedList.
|
|
411
411
|
*/
|
|
412
412
|
build() {
|
|
413
|
-
this.children = new
|
|
413
|
+
this.children = new se(), Array.from(this.domNode.childNodes).filter((t) => t !== this.uiNode).reverse().forEach((t) => {
|
|
414
414
|
try {
|
|
415
|
-
const e =
|
|
415
|
+
const e = dt(t, this.scroll);
|
|
416
416
|
this.insertBefore(e, this.children.head || void 0);
|
|
417
417
|
} catch (e) {
|
|
418
|
-
if (e instanceof
|
|
418
|
+
if (e instanceof T)
|
|
419
419
|
return;
|
|
420
420
|
throw e;
|
|
421
421
|
}
|
|
@@ -424,23 +424,23 @@ const gt = class N extends pt {
|
|
|
424
424
|
deleteAt(t, e) {
|
|
425
425
|
if (t === 0 && e === this.length())
|
|
426
426
|
return this.remove();
|
|
427
|
-
this.children.forEachAt(t, e, (s, i,
|
|
428
|
-
s.deleteAt(i,
|
|
427
|
+
this.children.forEachAt(t, e, (s, i, n) => {
|
|
428
|
+
s.deleteAt(i, n);
|
|
429
429
|
});
|
|
430
430
|
}
|
|
431
431
|
descendant(t, e = 0) {
|
|
432
432
|
const [s, i] = this.children.find(e);
|
|
433
|
-
return t.blotName == null && t(s) || t.blotName != null && s instanceof t ? [s, i] : s instanceof
|
|
433
|
+
return t.blotName == null && t(s) || t.blotName != null && s instanceof t ? [s, i] : s instanceof x ? s.descendant(t, i) : [null, -1];
|
|
434
434
|
}
|
|
435
435
|
descendants(t, e = 0, s = Number.MAX_VALUE) {
|
|
436
|
-
let i = [],
|
|
436
|
+
let i = [], n = s;
|
|
437
437
|
return this.children.forEachAt(
|
|
438
438
|
e,
|
|
439
439
|
s,
|
|
440
440
|
(o, a, l) => {
|
|
441
|
-
(t.blotName == null && t(o) || t.blotName != null && o instanceof t) && i.push(o), o instanceof
|
|
442
|
-
o.descendants(t, a,
|
|
443
|
-
)),
|
|
441
|
+
(t.blotName == null && t(o) || t.blotName != null && o instanceof t) && i.push(o), o instanceof x && (i = i.concat(
|
|
442
|
+
o.descendants(t, a, n)
|
|
443
|
+
)), n -= l;
|
|
444
444
|
}
|
|
445
445
|
), i;
|
|
446
446
|
}
|
|
@@ -454,18 +454,18 @@ const gt = class N extends pt {
|
|
|
454
454
|
this.children.forEach((e) => {
|
|
455
455
|
t || this.statics.allowedChildren.some(
|
|
456
456
|
(s) => e instanceof s
|
|
457
|
-
) || (e.statics.scope ===
|
|
457
|
+
) || (e.statics.scope === p.BLOCK_BLOT ? (e.next != null && this.splitAfter(e), e.prev != null && this.splitAfter(e.prev), e.parent.unwrap(), t = !0) : e instanceof x ? e.unwrap() : e.remove());
|
|
458
458
|
});
|
|
459
459
|
}
|
|
460
460
|
formatAt(t, e, s, i) {
|
|
461
|
-
this.children.forEachAt(t, e, (
|
|
462
|
-
|
|
461
|
+
this.children.forEachAt(t, e, (n, o, a) => {
|
|
462
|
+
n.formatAt(o, a, s, i);
|
|
463
463
|
});
|
|
464
464
|
}
|
|
465
465
|
insertAt(t, e, s) {
|
|
466
|
-
const [i,
|
|
466
|
+
const [i, n] = this.children.find(t);
|
|
467
467
|
if (i)
|
|
468
|
-
i.insertAt(
|
|
468
|
+
i.insertAt(n, e, s);
|
|
469
469
|
else {
|
|
470
470
|
const o = s == null ? this.scroll.create("text", e) : this.scroll.create(e, s);
|
|
471
471
|
this.appendChild(o);
|
|
@@ -493,15 +493,15 @@ const gt = class N extends pt {
|
|
|
493
493
|
this.remove();
|
|
494
494
|
}
|
|
495
495
|
path(t, e = !1) {
|
|
496
|
-
const [s, i] = this.children.find(t, e),
|
|
497
|
-
return s instanceof
|
|
496
|
+
const [s, i] = this.children.find(t, e), n = [[this, t]];
|
|
497
|
+
return s instanceof x ? n.concat(s.path(i, e)) : (s != null && n.push([s, i]), n);
|
|
498
498
|
}
|
|
499
499
|
removeChild(t) {
|
|
500
500
|
this.children.remove(t);
|
|
501
501
|
}
|
|
502
502
|
replaceWith(t, e) {
|
|
503
503
|
const s = typeof t == "string" ? this.scroll.create(t, e) : t;
|
|
504
|
-
return s instanceof
|
|
504
|
+
return s instanceof x && this.moveChildren(s), super.replaceWith(s);
|
|
505
505
|
}
|
|
506
506
|
split(t, e = !1) {
|
|
507
507
|
if (!e) {
|
|
@@ -511,8 +511,8 @@ const gt = class N extends pt {
|
|
|
511
511
|
return this.next;
|
|
512
512
|
}
|
|
513
513
|
const s = this.clone();
|
|
514
|
-
return this.parent && this.parent.insertBefore(s, this.next || void 0), this.children.forEachAt(t, this.length(), (i,
|
|
515
|
-
const a = i.split(
|
|
514
|
+
return this.parent && this.parent.insertBefore(s, this.next || void 0), this.children.forEachAt(t, this.length(), (i, n, o) => {
|
|
515
|
+
const a = i.split(n, e);
|
|
516
516
|
a != null && s.appendChild(a);
|
|
517
517
|
}), s;
|
|
518
518
|
}
|
|
@@ -527,39 +527,39 @@ const gt = class N extends pt {
|
|
|
527
527
|
}
|
|
528
528
|
update(t, e) {
|
|
529
529
|
const s = [], i = [];
|
|
530
|
-
t.forEach((
|
|
531
|
-
|
|
532
|
-
}), i.forEach((
|
|
533
|
-
if (
|
|
534
|
-
|
|
530
|
+
t.forEach((n) => {
|
|
531
|
+
n.target === this.domNode && n.type === "childList" && (s.push(...n.addedNodes), i.push(...n.removedNodes));
|
|
532
|
+
}), i.forEach((n) => {
|
|
533
|
+
if (n.parentNode != null && // @ts-expect-error Fix me later
|
|
534
|
+
n.tagName !== "IFRAME" && document.body.compareDocumentPosition(n) & Node.DOCUMENT_POSITION_CONTAINED_BY)
|
|
535
535
|
return;
|
|
536
|
-
const o = this.scroll.find(
|
|
536
|
+
const o = this.scroll.find(n);
|
|
537
537
|
o != null && (o.domNode.parentNode == null || o.domNode.parentNode === this.domNode) && o.detach();
|
|
538
|
-
}), s.filter((
|
|
538
|
+
}), s.filter((n) => n.parentNode === this.domNode && n !== this.uiNode).sort((n, o) => n === o ? 0 : n.compareDocumentPosition(o) & Node.DOCUMENT_POSITION_FOLLOWING ? 1 : -1).forEach((n) => {
|
|
539
539
|
let o = null;
|
|
540
|
-
|
|
541
|
-
const a =
|
|
540
|
+
n.nextSibling != null && (o = this.scroll.find(n.nextSibling));
|
|
541
|
+
const a = dt(n, this.scroll);
|
|
542
542
|
(a.next !== o || a.next == null) && (a.parent != null && a.parent.removeChild(this), this.insertBefore(a, o || void 0));
|
|
543
543
|
}), this.enforceAllowedChildren();
|
|
544
544
|
}
|
|
545
545
|
};
|
|
546
|
-
|
|
547
|
-
let
|
|
548
|
-
const
|
|
549
|
-
function
|
|
550
|
-
if (Object.keys(
|
|
546
|
+
St.uiClass = "";
|
|
547
|
+
let ie = St;
|
|
548
|
+
const B = ie;
|
|
549
|
+
function ne(r, t) {
|
|
550
|
+
if (Object.keys(r).length !== Object.keys(t).length)
|
|
551
551
|
return !1;
|
|
552
|
-
for (const e in
|
|
553
|
-
if (
|
|
552
|
+
for (const e in r)
|
|
553
|
+
if (r[e] !== t[e])
|
|
554
554
|
return !1;
|
|
555
555
|
return !0;
|
|
556
556
|
}
|
|
557
|
-
const
|
|
557
|
+
const O = class L extends B {
|
|
558
558
|
static create(t) {
|
|
559
559
|
return super.create(t);
|
|
560
560
|
}
|
|
561
561
|
static formats(t, e) {
|
|
562
|
-
const s = e.query(
|
|
562
|
+
const s = e.query(L.blotName);
|
|
563
563
|
if (!(s != null && t.tagName === s.tagName)) {
|
|
564
564
|
if (typeof this.tagName == "string")
|
|
565
565
|
return !0;
|
|
@@ -568,18 +568,18 @@ const E = class C extends L {
|
|
|
568
568
|
}
|
|
569
569
|
}
|
|
570
570
|
constructor(t, e) {
|
|
571
|
-
super(t, e), this.attributes = new
|
|
571
|
+
super(t, e), this.attributes = new Ct(this.domNode);
|
|
572
572
|
}
|
|
573
573
|
format(t, e) {
|
|
574
574
|
if (t === this.statics.blotName && !e)
|
|
575
575
|
this.children.forEach((s) => {
|
|
576
|
-
s instanceof
|
|
576
|
+
s instanceof L || (s = s.wrap(L.blotName, !0)), this.attributes.copy(s);
|
|
577
577
|
}), this.unwrap();
|
|
578
578
|
else {
|
|
579
|
-
const s = this.scroll.query(t,
|
|
579
|
+
const s = this.scroll.query(t, p.INLINE);
|
|
580
580
|
if (s == null)
|
|
581
581
|
return;
|
|
582
|
-
s instanceof
|
|
582
|
+
s instanceof D ? this.attributes.attribute(s, e) : e && (t !== this.statics.blotName || this.formats()[t] !== e) && this.replaceWith(t, e);
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
585
|
formats() {
|
|
@@ -587,7 +587,7 @@ const E = class C extends L {
|
|
|
587
587
|
return e != null && (t[this.statics.blotName] = e), t;
|
|
588
588
|
}
|
|
589
589
|
formatAt(t, e, s, i) {
|
|
590
|
-
this.formats()[s] != null || this.scroll.query(s,
|
|
590
|
+
this.formats()[s] != null || this.scroll.query(s, p.ATTRIBUTE) ? this.isolate(t, e).format(s, i) : super.formatAt(t, e, s, i);
|
|
591
591
|
}
|
|
592
592
|
optimize(t) {
|
|
593
593
|
super.optimize(t);
|
|
@@ -595,7 +595,7 @@ const E = class C extends L {
|
|
|
595
595
|
if (Object.keys(e).length === 0)
|
|
596
596
|
return this.unwrap();
|
|
597
597
|
const s = this.next;
|
|
598
|
-
s instanceof
|
|
598
|
+
s instanceof L && s.prev === this && ne(e, s.formats()) && (s.moveChildren(this), s.remove());
|
|
599
599
|
}
|
|
600
600
|
replaceWith(t, e) {
|
|
601
601
|
const s = super.replaceWith(t, e);
|
|
@@ -608,17 +608,17 @@ const E = class C extends L {
|
|
|
608
608
|
}
|
|
609
609
|
wrap(t, e) {
|
|
610
610
|
const s = super.wrap(t, e);
|
|
611
|
-
return s instanceof
|
|
611
|
+
return s instanceof L && this.attributes.move(s), s;
|
|
612
612
|
}
|
|
613
613
|
};
|
|
614
|
-
|
|
615
|
-
let
|
|
616
|
-
const
|
|
614
|
+
O.allowedChildren = [O, X], O.blotName = "inline", O.scope = p.INLINE_BLOT, O.tagName = "SPAN";
|
|
615
|
+
let re = O;
|
|
616
|
+
const kt = re, S = class et extends B {
|
|
617
617
|
static create(t) {
|
|
618
618
|
return super.create(t);
|
|
619
619
|
}
|
|
620
620
|
static formats(t, e) {
|
|
621
|
-
const s = e.query(
|
|
621
|
+
const s = e.query(et.blotName);
|
|
622
622
|
if (!(s != null && t.tagName === s.tagName)) {
|
|
623
623
|
if (typeof this.tagName == "string")
|
|
624
624
|
return !0;
|
|
@@ -627,27 +627,27 @@ const _t = Ht, A = class Y extends L {
|
|
|
627
627
|
}
|
|
628
628
|
}
|
|
629
629
|
constructor(t, e) {
|
|
630
|
-
super(t, e), this.attributes = new
|
|
630
|
+
super(t, e), this.attributes = new Ct(this.domNode);
|
|
631
631
|
}
|
|
632
632
|
format(t, e) {
|
|
633
|
-
const s = this.scroll.query(t,
|
|
634
|
-
s != null && (s instanceof
|
|
633
|
+
const s = this.scroll.query(t, p.BLOCK);
|
|
634
|
+
s != null && (s instanceof D ? this.attributes.attribute(s, e) : t === this.statics.blotName && !e ? this.replaceWith(et.blotName) : e && (t !== this.statics.blotName || this.formats()[t] !== e) && this.replaceWith(t, e));
|
|
635
635
|
}
|
|
636
636
|
formats() {
|
|
637
637
|
const t = this.attributes.values(), e = this.statics.formats(this.domNode, this.scroll);
|
|
638
638
|
return e != null && (t[this.statics.blotName] = e), t;
|
|
639
639
|
}
|
|
640
640
|
formatAt(t, e, s, i) {
|
|
641
|
-
this.scroll.query(s,
|
|
641
|
+
this.scroll.query(s, p.BLOCK) != null ? this.format(s, i) : super.formatAt(t, e, s, i);
|
|
642
642
|
}
|
|
643
643
|
insertAt(t, e, s) {
|
|
644
|
-
if (s == null || this.scroll.query(e,
|
|
644
|
+
if (s == null || this.scroll.query(e, p.INLINE) != null)
|
|
645
645
|
super.insertAt(t, e, s);
|
|
646
646
|
else {
|
|
647
647
|
const i = this.split(t);
|
|
648
648
|
if (i != null) {
|
|
649
|
-
const
|
|
650
|
-
i.parent.insertBefore(
|
|
649
|
+
const n = this.scroll.create(e, s);
|
|
650
|
+
i.parent.insertBefore(n, i);
|
|
651
651
|
} else
|
|
652
652
|
throw new Error("Attempt to insertAt after block boundaries");
|
|
653
653
|
}
|
|
@@ -662,13 +662,13 @@ const _t = Ht, A = class Y extends L {
|
|
|
662
662
|
) && this.attributes.build();
|
|
663
663
|
}
|
|
664
664
|
};
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
665
|
+
S.blotName = "block", S.scope = p.BLOCK_BLOT, S.tagName = "P", S.allowedChildren = [
|
|
666
|
+
kt,
|
|
667
|
+
S,
|
|
668
|
+
X
|
|
669
669
|
];
|
|
670
|
-
let
|
|
671
|
-
const
|
|
670
|
+
let oe = S;
|
|
671
|
+
const st = oe, it = class extends B {
|
|
672
672
|
checkMerge() {
|
|
673
673
|
return this.next !== null && this.next.statics.blotName === this.statics.blotName;
|
|
674
674
|
}
|
|
@@ -685,10 +685,10 @@ const Z = Kt, J = class extends L {
|
|
|
685
685
|
super.optimize(t), this.children.length > 0 && this.next != null && this.checkMerge() && (this.next.moveChildren(this), this.next.remove());
|
|
686
686
|
}
|
|
687
687
|
};
|
|
688
|
-
|
|
689
|
-
let
|
|
690
|
-
const
|
|
691
|
-
class
|
|
688
|
+
it.blotName = "container", it.scope = p.BLOCK_BLOT;
|
|
689
|
+
let ae = it;
|
|
690
|
+
const le = ae;
|
|
691
|
+
class ce extends X {
|
|
692
692
|
static formats(t, e) {
|
|
693
693
|
}
|
|
694
694
|
format(t, e) {
|
|
@@ -701,17 +701,17 @@ class Wt extends q {
|
|
|
701
701
|
return this.statics.formats(this.domNode, this.scroll);
|
|
702
702
|
}
|
|
703
703
|
}
|
|
704
|
-
const
|
|
704
|
+
const he = ce, ue = {
|
|
705
705
|
attributes: !0,
|
|
706
706
|
characterData: !0,
|
|
707
707
|
characterDataOldValue: !0,
|
|
708
708
|
childList: !0,
|
|
709
709
|
subtree: !0
|
|
710
|
-
},
|
|
710
|
+
}, de = 100, k = class extends B {
|
|
711
711
|
constructor(t, e) {
|
|
712
712
|
super(null, e), this.registry = t, this.scroll = this, this.build(), this.observer = new MutationObserver((s) => {
|
|
713
713
|
this.update(s);
|
|
714
|
-
}), this.observer.observe(this.domNode,
|
|
714
|
+
}), this.observer.observe(this.domNode, ue), this.attach();
|
|
715
715
|
}
|
|
716
716
|
create(t, e) {
|
|
717
717
|
return this.registry.create(this, t, e);
|
|
@@ -720,7 +720,7 @@ const Ft = Wt, Gt = {
|
|
|
720
720
|
const s = this.registry.find(t, e);
|
|
721
721
|
return s ? s.scroll === this ? s : e ? this.find(s.scroll.domNode.parentNode, !0) : null : null;
|
|
722
722
|
}
|
|
723
|
-
query(t, e =
|
|
723
|
+
query(t, e = p.ANY) {
|
|
724
724
|
return this.registry.query(t, e);
|
|
725
725
|
}
|
|
726
726
|
register(...t) {
|
|
@@ -749,23 +749,23 @@ const Ft = Wt, Gt = {
|
|
|
749
749
|
let i = Array.from(this.observer.takeRecords());
|
|
750
750
|
for (; i.length > 0; )
|
|
751
751
|
t.push(i.pop());
|
|
752
|
-
const
|
|
753
|
-
l == null || l === this || l.domNode.parentNode != null && (s.has(l.domNode) || s.set(l.domNode, []),
|
|
752
|
+
const n = (l, c = !0) => {
|
|
753
|
+
l == null || l === this || l.domNode.parentNode != null && (s.has(l.domNode) || s.set(l.domNode, []), c && n(l.parent));
|
|
754
754
|
}, o = (l) => {
|
|
755
|
-
s.has(l.domNode) && (l instanceof
|
|
755
|
+
s.has(l.domNode) && (l instanceof B && l.children.forEach(o), s.delete(l.domNode), l.optimize(e));
|
|
756
756
|
};
|
|
757
757
|
let a = t;
|
|
758
758
|
for (let l = 0; a.length > 0; l += 1) {
|
|
759
|
-
if (l >=
|
|
759
|
+
if (l >= de)
|
|
760
760
|
throw new Error("[Parchment] Maximum optimize iterations reached");
|
|
761
|
-
for (a.forEach((
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
const
|
|
765
|
-
|
|
766
|
-
|
|
761
|
+
for (a.forEach((c) => {
|
|
762
|
+
const h = this.find(c.target, !0);
|
|
763
|
+
h != null && (h.domNode === c.target && (c.type === "childList" ? (n(this.find(c.previousSibling, !1)), Array.from(c.addedNodes).forEach((u) => {
|
|
764
|
+
const d = this.find(u, !1);
|
|
765
|
+
n(d, !1), d instanceof B && d.children.forEach((f) => {
|
|
766
|
+
n(f, !1);
|
|
767
767
|
});
|
|
768
|
-
})) :
|
|
768
|
+
})) : c.type === "attributes" && n(h.prev)), n(h));
|
|
769
769
|
}), this.children.forEach(o), a = Array.from(this.observer.takeRecords()), i = a.slice(); i.length > 0; )
|
|
770
770
|
t.push(i.pop());
|
|
771
771
|
}
|
|
@@ -774,16 +774,16 @@ const Ft = Wt, Gt = {
|
|
|
774
774
|
t = t || this.observer.takeRecords();
|
|
775
775
|
const s = /* @__PURE__ */ new WeakMap();
|
|
776
776
|
t.map((i) => {
|
|
777
|
-
const
|
|
778
|
-
return
|
|
777
|
+
const n = this.find(i.target, !0);
|
|
778
|
+
return n == null ? null : s.has(n.domNode) ? (s.get(n.domNode).push(i), null) : (s.set(n.domNode, [i]), n);
|
|
779
779
|
}).forEach((i) => {
|
|
780
780
|
i != null && i !== this && s.has(i.domNode) && i.update(s.get(i.domNode) || [], e);
|
|
781
781
|
}), e.mutationsMap = s, s.has(this.domNode) && super.update(s.get(this.domNode), e), this.optimize(t, e);
|
|
782
782
|
}
|
|
783
783
|
};
|
|
784
|
-
|
|
785
|
-
let
|
|
786
|
-
const
|
|
784
|
+
k.blotName = "scroll", k.defaultChild = st, k.allowedChildren = [st, le], k.scope = p.BLOCK_BLOT, k.tagName = "DIV";
|
|
785
|
+
let fe = k;
|
|
786
|
+
const pe = fe, ft = class Tt extends X {
|
|
787
787
|
static create(t) {
|
|
788
788
|
return document.createTextNode(t);
|
|
789
789
|
}
|
|
@@ -806,7 +806,7 @@ const Yt = Xt, nt = class vt extends q {
|
|
|
806
806
|
return this.text.length;
|
|
807
807
|
}
|
|
808
808
|
optimize(t) {
|
|
809
|
-
super.optimize(t), this.text = this.statics.value(this.domNode), this.text.length === 0 ? this.remove() : this.next instanceof
|
|
809
|
+
super.optimize(t), this.text = this.statics.value(this.domNode), this.text.length === 0 ? this.remove() : this.next instanceof Tt && this.next.prev === this && (this.insertAt(this.length(), this.next.value()), this.next.remove());
|
|
810
810
|
}
|
|
811
811
|
position(t, e = !1) {
|
|
812
812
|
return [this.domNode, t];
|
|
@@ -828,8 +828,8 @@ const Yt = Xt, nt = class vt extends q {
|
|
|
828
828
|
return this.text;
|
|
829
829
|
}
|
|
830
830
|
};
|
|
831
|
-
|
|
832
|
-
const
|
|
831
|
+
ft.blotName = "text", ft.scope = p.INLINE_BLOT;
|
|
832
|
+
const ot = class ot extends pe {
|
|
833
833
|
constructor(t, e) {
|
|
834
834
|
super(t, e), this.observer.disconnect();
|
|
835
835
|
}
|
|
@@ -839,88 +839,95 @@ const et = class et extends Yt {
|
|
|
839
839
|
optimize(t, e) {
|
|
840
840
|
}
|
|
841
841
|
};
|
|
842
|
-
|
|
843
|
-
let
|
|
844
|
-
const
|
|
842
|
+
ot.blotName = "rc-scroll";
|
|
843
|
+
let nt = ot;
|
|
844
|
+
const P = class P extends st {
|
|
845
845
|
};
|
|
846
|
-
|
|
847
|
-
let
|
|
848
|
-
const
|
|
846
|
+
P.blotName = "rc-block", P.tagName = "DIV", P.className = "line";
|
|
847
|
+
let W = P;
|
|
848
|
+
const M = class M extends kt {
|
|
849
849
|
static create(t) {
|
|
850
850
|
const e = super.create();
|
|
851
|
-
return t &&
|
|
851
|
+
return t && ge(e, t), e;
|
|
852
852
|
}
|
|
853
853
|
};
|
|
854
|
-
|
|
855
|
-
let
|
|
856
|
-
function
|
|
854
|
+
M.blotName = "rc-inline", M.tagName = "SPAN", M.className = "mark";
|
|
855
|
+
let K = M;
|
|
856
|
+
function ge(r, t) {
|
|
857
857
|
if (t.className)
|
|
858
858
|
for (const e of t.className.split(/\s+/).filter(Boolean))
|
|
859
|
-
|
|
860
|
-
t.bold && (
|
|
859
|
+
r.classList.add(e);
|
|
860
|
+
t.bold && (r.style.fontWeight = "bold"), t.italic && (r.style.fontStyle = "italic"), t.color && (r.style.color = t.color), t.background && (r.style.backgroundColor = t.background), t.underline && (r.style.textDecoration = `${t.underline} underline`, t.underlineColor && (r.style.textDecorationColor = t.underlineColor));
|
|
861
861
|
}
|
|
862
|
-
const
|
|
862
|
+
const z = class z extends he {
|
|
863
863
|
static create() {
|
|
864
864
|
const t = super.create();
|
|
865
865
|
return t.contentEditable = "false", t.setAttribute("aria-hidden", "true"), t;
|
|
866
866
|
}
|
|
867
867
|
};
|
|
868
|
-
|
|
869
|
-
let
|
|
870
|
-
function
|
|
871
|
-
const
|
|
872
|
-
return
|
|
868
|
+
z.blotName = "rc-widget", z.tagName = "SPAN", z.className = "widget";
|
|
869
|
+
let G = z;
|
|
870
|
+
function me() {
|
|
871
|
+
const r = new q();
|
|
872
|
+
return r.register(W, K, G), r;
|
|
873
873
|
}
|
|
874
|
-
function
|
|
874
|
+
function _e(r, t, e, s, i) {
|
|
875
875
|
if (t.length === 0) {
|
|
876
|
-
|
|
876
|
+
r.appendChild(document.createElement("br"));
|
|
877
|
+
for (const a of i)
|
|
878
|
+
r.appendChild(I(a));
|
|
877
879
|
return;
|
|
878
880
|
}
|
|
879
|
-
const
|
|
881
|
+
const n = /* @__PURE__ */ new Set([0, t.length]);
|
|
880
882
|
for (const a of s)
|
|
881
|
-
|
|
883
|
+
n.add(Math.max(0, a.from - e)), n.add(Math.min(t.length, a.to - e));
|
|
882
884
|
for (const a of i) {
|
|
883
885
|
const l = a.offset - e;
|
|
884
|
-
l >= 0 && l <= t.length &&
|
|
885
|
-
}
|
|
886
|
-
const o = [...
|
|
887
|
-
for (
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
886
|
+
l >= 0 && l <= t.length && n.add(l);
|
|
887
|
+
}
|
|
888
|
+
const o = [...n].sort((a, l) => a - l);
|
|
889
|
+
for (const a of i)
|
|
890
|
+
a.offset === e && a.side === "after" && r.appendChild(I(a));
|
|
891
|
+
for (const [a, l] of o.entries()) {
|
|
892
|
+
const c = o[a + 1];
|
|
893
|
+
if (c === void 0)
|
|
894
|
+
break;
|
|
895
|
+
for (const f of i)
|
|
896
|
+
f.offset - e === l && (f.side ?? "before") === "before" && r.appendChild(I(f));
|
|
897
|
+
const h = t.slice(l, c);
|
|
898
|
+
if (!h)
|
|
893
899
|
continue;
|
|
894
|
-
let
|
|
895
|
-
for (const
|
|
896
|
-
const m =
|
|
897
|
-
if (m <= l &&
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
+
let u, d = 1 / 0;
|
|
901
|
+
for (const f of s) {
|
|
902
|
+
const m = f.from - e, w = f.to - e;
|
|
903
|
+
if (m <= l && w >= c) {
|
|
904
|
+
const C = w - m;
|
|
905
|
+
C < d && (d = C, u = f);
|
|
900
906
|
}
|
|
901
907
|
}
|
|
902
|
-
if (
|
|
903
|
-
const
|
|
904
|
-
if (
|
|
905
|
-
for (const [m,
|
|
906
|
-
|
|
907
|
-
|
|
908
|
+
if (u) {
|
|
909
|
+
const f = K.create(u);
|
|
910
|
+
if (u.attributes)
|
|
911
|
+
for (const [m, w] of Object.entries(u.attributes))
|
|
912
|
+
f.setAttribute(m, w);
|
|
913
|
+
f.appendChild(document.createTextNode(h)), r.appendChild(f);
|
|
908
914
|
} else
|
|
909
|
-
|
|
910
|
-
for (const
|
|
911
|
-
|
|
915
|
+
r.appendChild(document.createTextNode(h));
|
|
916
|
+
for (const f of i)
|
|
917
|
+
f.offset - e === c && f.side === "after" && r.appendChild(I(f));
|
|
912
918
|
}
|
|
913
919
|
for (const a of i)
|
|
914
|
-
a.offset - e === t.length && (a.side ?? "before") === "before" &&
|
|
920
|
+
a.offset - e === t.length && (a.side ?? "before") === "before" && r.appendChild(I(a));
|
|
915
921
|
}
|
|
916
|
-
function
|
|
917
|
-
const t =
|
|
918
|
-
return t.appendChild(
|
|
922
|
+
function I(r) {
|
|
923
|
+
const t = G.create();
|
|
924
|
+
return r.accessible && t.removeAttribute("aria-hidden"), r.layout && t.classList.add(`widget--${r.layout}`), t.appendChild(r.create()), t;
|
|
919
925
|
}
|
|
920
|
-
class
|
|
926
|
+
class be {
|
|
921
927
|
constructor(t) {
|
|
922
|
-
|
|
923
|
-
|
|
928
|
+
this.lineSignatures = /* @__PURE__ */ new WeakMap();
|
|
929
|
+
const e = me();
|
|
930
|
+
this.scroll = new nt(e, t);
|
|
924
931
|
}
|
|
925
932
|
/**
|
|
926
933
|
* Rebuild the document tree.
|
|
@@ -930,50 +937,66 @@ class te {
|
|
|
930
937
|
*/
|
|
931
938
|
build(t, e) {
|
|
932
939
|
const s = this.scroll.domNode, i = t.split(`
|
|
933
|
-
`),
|
|
934
|
-
for (const
|
|
935
|
-
if (
|
|
936
|
-
const
|
|
937
|
-
|
|
938
|
-
} else
|
|
939
|
-
|
|
940
|
+
`), n = Array.from(s.querySelectorAll(".line")), o = /* @__PURE__ */ new Map(), a = [], l = [], c = /* @__PURE__ */ new Set();
|
|
941
|
+
for (const u of e)
|
|
942
|
+
if (u.type === "line") {
|
|
943
|
+
const d = o.get(u.line) ?? [];
|
|
944
|
+
d.push(u), o.set(u.line, d);
|
|
945
|
+
} else if (u.type === "mark")
|
|
946
|
+
a.push(u);
|
|
947
|
+
else if (u.type === "widget")
|
|
948
|
+
l.push(u);
|
|
949
|
+
else
|
|
950
|
+
for (let d = Math.max(2, u.fromLine); d <= u.toLine && d <= i.length; d++)
|
|
951
|
+
c.add(d);
|
|
952
|
+
a.sort((u, d) => u.from - d.from || u.to - d.to), l.sort((u, d) => u.offset - d.offset);
|
|
940
953
|
let h = 0;
|
|
941
|
-
for (
|
|
942
|
-
const f =
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
954
|
+
for (const [u, d] of i.entries()) {
|
|
955
|
+
const f = u + 1, m = h, w = m + d.length, C = o.get(f) ?? [], at = a.filter((g) => g.from < w && g.to > m), R = l.filter((g) => g.offset >= m && g.offset <= w), lt = c.has(f), H = R.length > 0 && R.every((g) => g.key) ? JSON.stringify([
|
|
956
|
+
d,
|
|
957
|
+
lt,
|
|
958
|
+
[...C, ...at, ...R].map(
|
|
959
|
+
({ id: g, ...y }) => y.type === "line" ? { ...y, gutterContent: void 0 } : y
|
|
960
|
+
)
|
|
961
|
+
]) : void 0, $ = n[u];
|
|
962
|
+
if ($ && H && this.lineSignatures.get($) === H && Bt($) === d) {
|
|
963
|
+
h += d.length + 1;
|
|
964
|
+
continue;
|
|
965
|
+
}
|
|
966
|
+
let _;
|
|
967
|
+
if ($) {
|
|
968
|
+
_ = $;
|
|
969
|
+
for (const g of _.getAttributeNames())
|
|
970
|
+
_.removeAttribute(g);
|
|
971
|
+
for (_.className = "line"; _.firstChild; )
|
|
972
|
+
_.removeChild(_.firstChild);
|
|
949
973
|
} else
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
for (const
|
|
953
|
-
if (
|
|
954
|
-
for (const
|
|
955
|
-
|
|
956
|
-
if (
|
|
957
|
-
for (const [
|
|
958
|
-
|
|
974
|
+
_ = W.create(), s.appendChild(_);
|
|
975
|
+
lt && (_.hidden = !0);
|
|
976
|
+
for (const g of C) {
|
|
977
|
+
if (g.className)
|
|
978
|
+
for (const y of g.className.split(/\s+/).filter(Boolean))
|
|
979
|
+
_.classList.add(y);
|
|
980
|
+
if (g.attributes)
|
|
981
|
+
for (const [y, A] of Object.entries(g.attributes))
|
|
982
|
+
_.setAttribute(y, A);
|
|
959
983
|
}
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
const _ = W.map((w) => w.message).join(" · "), x = [
|
|
984
|
+
_e(_, d, m, at, R), R.some((g) => g.layout === "trailing") && _.classList.add("line--trailing-widget"), H ? this.lineSignatures.set(_, H) : this.lineSignatures.delete(_);
|
|
985
|
+
const Y = C.filter((g) => g.message);
|
|
986
|
+
if (Y.length > 0) {
|
|
987
|
+
const g = Y.map((A) => A.message).join(" · "), y = [
|
|
965
988
|
...new Set(
|
|
966
|
-
|
|
967
|
-
(
|
|
989
|
+
Y.flatMap(
|
|
990
|
+
(A) => A.messageClassName ? A.messageClassName.split(/\s+/).filter(Boolean) : []
|
|
968
991
|
)
|
|
969
992
|
)
|
|
970
993
|
];
|
|
971
|
-
|
|
994
|
+
_.dataset.message = g, _.title = g, y.length > 0 && (_.dataset.messageClass = y.join(" "));
|
|
972
995
|
}
|
|
973
|
-
h +=
|
|
996
|
+
h += d.length + 1;
|
|
974
997
|
}
|
|
975
998
|
for (; s.children.length > i.length; )
|
|
976
|
-
s.
|
|
999
|
+
s.lastChild?.remove();
|
|
977
1000
|
}
|
|
978
1001
|
destroy() {
|
|
979
1002
|
const t = this.scroll.domNode;
|
|
@@ -981,30 +1004,30 @@ class te {
|
|
|
981
1004
|
t.removeChild(t.firstChild);
|
|
982
1005
|
}
|
|
983
1006
|
}
|
|
984
|
-
function
|
|
985
|
-
const t = Array.from(
|
|
986
|
-
return t.length > 0 ? t.map((e) =>
|
|
987
|
-
`) :
|
|
1007
|
+
function J(r) {
|
|
1008
|
+
const t = Array.from(r.querySelectorAll(".line"));
|
|
1009
|
+
return t.length > 0 ? t.map((e) => Bt(e)).join(`
|
|
1010
|
+
`) : Rt(r);
|
|
988
1011
|
}
|
|
989
|
-
function
|
|
1012
|
+
function Bt(r) {
|
|
990
1013
|
let t = "";
|
|
991
|
-
for (const e of
|
|
992
|
-
t +=
|
|
1014
|
+
for (const e of r.childNodes)
|
|
1015
|
+
t += Dt(e);
|
|
993
1016
|
return t;
|
|
994
1017
|
}
|
|
995
|
-
function
|
|
996
|
-
if (
|
|
997
|
-
return
|
|
998
|
-
if (!(
|
|
1018
|
+
function Dt(r) {
|
|
1019
|
+
if (r.nodeType === Node.TEXT_NODE)
|
|
1020
|
+
return r.data;
|
|
1021
|
+
if (!(r instanceof Element) || r.classList.contains("widget") || r.classList.contains("line-message") || r.tagName === "BR")
|
|
999
1022
|
return "";
|
|
1000
1023
|
let t = "";
|
|
1001
|
-
for (const e of
|
|
1002
|
-
t +=
|
|
1024
|
+
for (const e of r.childNodes)
|
|
1025
|
+
t += Dt(e);
|
|
1003
1026
|
return t;
|
|
1004
1027
|
}
|
|
1005
|
-
function
|
|
1028
|
+
function Rt(r) {
|
|
1006
1029
|
let t = "", e = !0;
|
|
1007
|
-
for (const s of
|
|
1030
|
+
for (const s of r.childNodes)
|
|
1008
1031
|
if (s.nodeType === Node.TEXT_NODE)
|
|
1009
1032
|
t += s.data;
|
|
1010
1033
|
else if (s instanceof HTMLElement) {
|
|
@@ -1016,52 +1039,53 @@ function bt(n) {
|
|
|
1016
1039
|
if (s.classList.contains("widget"))
|
|
1017
1040
|
continue;
|
|
1018
1041
|
(s.tagName === "DIV" || s.tagName === "P") && !e && (t += `
|
|
1019
|
-
`), e = !1, t +=
|
|
1042
|
+
`), e = !1, t += Rt(s);
|
|
1020
1043
|
}
|
|
1021
1044
|
return t;
|
|
1022
1045
|
}
|
|
1023
|
-
function
|
|
1024
|
-
if (
|
|
1025
|
-
return
|
|
1026
|
-
if (!(
|
|
1046
|
+
function F(r) {
|
|
1047
|
+
if (r.nodeType === Node.TEXT_NODE)
|
|
1048
|
+
return r.length;
|
|
1049
|
+
if (!(r instanceof Element) || r.classList.contains("widget") || r.tagName === "BR")
|
|
1027
1050
|
return 0;
|
|
1028
1051
|
let t = 0;
|
|
1029
|
-
for (const e of
|
|
1030
|
-
t +=
|
|
1052
|
+
for (const e of r.childNodes)
|
|
1053
|
+
t += F(e);
|
|
1031
1054
|
return t;
|
|
1032
1055
|
}
|
|
1033
|
-
function
|
|
1034
|
-
const s = Array.from(
|
|
1056
|
+
function pt(r, t, e) {
|
|
1057
|
+
const s = Array.from(r.querySelectorAll(".line"));
|
|
1035
1058
|
let i = 0;
|
|
1036
|
-
for (
|
|
1037
|
-
|
|
1038
|
-
|
|
1059
|
+
for (const [n, o] of s.entries()) {
|
|
1060
|
+
if (n > 0 && i++, t === r && r.childNodes[e] === o)
|
|
1061
|
+
return i;
|
|
1062
|
+
const a = $t(o, t, e, i);
|
|
1039
1063
|
if (a.found)
|
|
1040
1064
|
return a.offset;
|
|
1041
|
-
i +=
|
|
1065
|
+
i += F(o);
|
|
1042
1066
|
}
|
|
1043
1067
|
return i;
|
|
1044
1068
|
}
|
|
1045
|
-
function
|
|
1046
|
-
if (
|
|
1047
|
-
if (
|
|
1069
|
+
function $t(r, t, e, s) {
|
|
1070
|
+
if (r === t) {
|
|
1071
|
+
if (r.nodeType === Node.TEXT_NODE)
|
|
1048
1072
|
return { found: !0, offset: s + e };
|
|
1049
|
-
const i = Array.from(
|
|
1050
|
-
let
|
|
1051
|
-
for (
|
|
1052
|
-
|
|
1053
|
-
return { found: !0, offset:
|
|
1054
|
-
}
|
|
1055
|
-
if (
|
|
1056
|
-
return { found: !1, offset: s +
|
|
1057
|
-
if (
|
|
1058
|
-
if (
|
|
1073
|
+
const i = Array.from(r.childNodes);
|
|
1074
|
+
let n = s;
|
|
1075
|
+
for (const o of i.slice(0, e))
|
|
1076
|
+
n += F(o);
|
|
1077
|
+
return { found: !0, offset: n };
|
|
1078
|
+
}
|
|
1079
|
+
if (r.nodeType === Node.TEXT_NODE)
|
|
1080
|
+
return { found: !1, offset: s + r.length };
|
|
1081
|
+
if (r instanceof Element) {
|
|
1082
|
+
if (r.classList.contains("widget"))
|
|
1059
1083
|
return { found: !1, offset: s };
|
|
1060
|
-
if (
|
|
1084
|
+
if (r.tagName === "BR")
|
|
1061
1085
|
return { found: !1, offset: s };
|
|
1062
1086
|
let i = s;
|
|
1063
|
-
for (const
|
|
1064
|
-
const o =
|
|
1087
|
+
for (const n of r.childNodes) {
|
|
1088
|
+
const o = $t(n, t, e, i);
|
|
1065
1089
|
if (o.found)
|
|
1066
1090
|
return o;
|
|
1067
1091
|
i = o.offset;
|
|
@@ -1070,172 +1094,195 @@ function Nt(n, t, e, s) {
|
|
|
1070
1094
|
}
|
|
1071
1095
|
return { found: !1, offset: s };
|
|
1072
1096
|
}
|
|
1073
|
-
function
|
|
1074
|
-
const e = Array.from(
|
|
1097
|
+
function gt(r, t) {
|
|
1098
|
+
const e = Array.from(r.querySelectorAll(".line"));
|
|
1075
1099
|
let s = t;
|
|
1076
|
-
for (
|
|
1077
|
-
if (
|
|
1100
|
+
for (const [n, o] of e.entries()) {
|
|
1101
|
+
if (n > 0) {
|
|
1078
1102
|
if (s === 0)
|
|
1079
|
-
return { node:
|
|
1103
|
+
return { node: o, offset: 0 };
|
|
1080
1104
|
s--;
|
|
1081
1105
|
}
|
|
1082
|
-
const
|
|
1106
|
+
const a = F(o);
|
|
1083
1107
|
if (s <= a) {
|
|
1084
|
-
const l =
|
|
1108
|
+
const l = It(o, s);
|
|
1085
1109
|
return l || { node: o, offset: o.childNodes.length };
|
|
1086
1110
|
}
|
|
1087
1111
|
s -= a;
|
|
1088
1112
|
}
|
|
1089
1113
|
const i = e[e.length - 1];
|
|
1090
|
-
return i ? { node: i, offset: i.childNodes.length } : { node:
|
|
1114
|
+
return i ? { node: i, offset: i.childNodes.length } : { node: r, offset: r.childNodes.length };
|
|
1091
1115
|
}
|
|
1092
|
-
function
|
|
1093
|
-
if (
|
|
1094
|
-
const e =
|
|
1116
|
+
function It(r, t) {
|
|
1117
|
+
if (r.nodeType === Node.TEXT_NODE) {
|
|
1118
|
+
const e = r;
|
|
1095
1119
|
return t <= e.length ? { node: e, offset: t } : null;
|
|
1096
1120
|
}
|
|
1097
|
-
if (
|
|
1098
|
-
if (
|
|
1121
|
+
if (r instanceof Element) {
|
|
1122
|
+
if (r.classList.contains("widget") || r.tagName === "BR")
|
|
1099
1123
|
return null;
|
|
1100
1124
|
let e = 0;
|
|
1101
|
-
for (const s of
|
|
1102
|
-
const i =
|
|
1125
|
+
for (const s of r.childNodes) {
|
|
1126
|
+
const i = F(s);
|
|
1103
1127
|
if (t <= i) {
|
|
1104
|
-
const
|
|
1105
|
-
return
|
|
1128
|
+
const n = It(s, t);
|
|
1129
|
+
return n || { node: r, offset: e + 1 };
|
|
1106
1130
|
}
|
|
1107
1131
|
t -= i, e++;
|
|
1108
1132
|
}
|
|
1109
1133
|
}
|
|
1110
1134
|
return null;
|
|
1111
1135
|
}
|
|
1112
|
-
function
|
|
1113
|
-
|
|
1114
|
-
if (!s || s.rangeCount === 0)
|
|
1136
|
+
function mt(r, t) {
|
|
1137
|
+
if (!t || t.rangeCount === 0 || !t.anchorNode || !t.focusNode)
|
|
1115
1138
|
return null;
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
const [r] = s.getComposedRanges({ shadowRoots: [t] });
|
|
1124
|
-
if (r && n.contains(r.startContainer) && n.contains(r.endContainer))
|
|
1125
|
-
return {
|
|
1126
|
-
anchorOffset: $(n, r.startContainer, r.startOffset),
|
|
1127
|
-
focusOffset: $(n, r.endContainer, r.endOffset)
|
|
1128
|
-
};
|
|
1129
|
-
}
|
|
1130
|
-
return null;
|
|
1139
|
+
const e = t.getRangeAt(0);
|
|
1140
|
+
return !r.contains(e.commonAncestorContainer) || !r.contains(t.anchorNode) || !r.contains(t.focusNode) ? null : {
|
|
1141
|
+
$anchorNode: t.anchorNode,
|
|
1142
|
+
anchorOffset: t.anchorOffset,
|
|
1143
|
+
$focusNode: t.focusNode,
|
|
1144
|
+
focusOffset: t.focusOffset
|
|
1145
|
+
};
|
|
1131
1146
|
}
|
|
1132
|
-
function
|
|
1133
|
-
const
|
|
1147
|
+
function Pt(r) {
|
|
1148
|
+
const t = r.getRootNode(), e = t.getSelection, s = mt(
|
|
1149
|
+
r,
|
|
1150
|
+
e?.call(t) ?? null
|
|
1151
|
+
);
|
|
1152
|
+
if (s)
|
|
1153
|
+
return s;
|
|
1154
|
+
const i = window.getSelection(), n = mt(r, i);
|
|
1155
|
+
if (n)
|
|
1156
|
+
return n;
|
|
1157
|
+
if (!(t instanceof ShadowRoot))
|
|
1158
|
+
return null;
|
|
1159
|
+
const [o] = i?.getComposedRanges?.({
|
|
1160
|
+
shadowRoots: [t]
|
|
1161
|
+
}) ?? [];
|
|
1162
|
+
return !o || !r.contains(o.startContainer) || !r.contains(o.endContainer) ? null : {
|
|
1163
|
+
$anchorNode: o.startContainer,
|
|
1164
|
+
anchorOffset: o.startOffset,
|
|
1165
|
+
$focusNode: o.endContainer,
|
|
1166
|
+
focusOffset: o.endOffset
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
function ve(r) {
|
|
1170
|
+
return Pt(r)?.$focusNode ?? null;
|
|
1171
|
+
}
|
|
1172
|
+
function E(r) {
|
|
1173
|
+
const t = Pt(r);
|
|
1174
|
+
return t ? {
|
|
1175
|
+
anchorOffset: pt(r, t.$anchorNode, t.anchorOffset),
|
|
1176
|
+
focusOffset: pt(r, t.$focusNode, t.focusOffset)
|
|
1177
|
+
} : null;
|
|
1178
|
+
}
|
|
1179
|
+
function ye(r, t) {
|
|
1180
|
+
const e = gt(r, t.anchorOffset), s = gt(r, t.focusOffset);
|
|
1134
1181
|
if (!(!e || !s))
|
|
1135
1182
|
try {
|
|
1136
1183
|
const i = window.getSelection();
|
|
1137
1184
|
if (!i)
|
|
1138
1185
|
return;
|
|
1139
|
-
const
|
|
1140
|
-
|
|
1186
|
+
const n = document.createRange();
|
|
1187
|
+
n.setStart(e.node, e.offset), n.setEnd(s.node, s.offset), i.removeAllRanges(), i.addRange(n);
|
|
1141
1188
|
} catch {
|
|
1142
1189
|
}
|
|
1143
1190
|
}
|
|
1144
|
-
function
|
|
1191
|
+
function U() {
|
|
1145
1192
|
return crypto.randomUUID();
|
|
1146
1193
|
}
|
|
1147
|
-
function
|
|
1194
|
+
function Mt(r, t) {
|
|
1148
1195
|
let e = 0;
|
|
1149
|
-
for (; e <
|
|
1196
|
+
for (; e < r.length && e < t.length && r[e] === t[e]; )
|
|
1150
1197
|
e++;
|
|
1151
|
-
let s =
|
|
1152
|
-
for (; s > e && i > e &&
|
|
1198
|
+
let s = r.length, i = t.length;
|
|
1199
|
+
for (; s > e && i > e && r[s - 1] === t[i - 1]; )
|
|
1153
1200
|
s--, i--;
|
|
1154
1201
|
return { start: e, removed: s - e, inserted: i - e };
|
|
1155
1202
|
}
|
|
1156
|
-
function
|
|
1203
|
+
function _t(r, t, e) {
|
|
1157
1204
|
const s = e.start + e.removed, i = e.inserted - e.removed;
|
|
1158
1205
|
if (t <= e.start)
|
|
1159
|
-
return { from:
|
|
1160
|
-
if (
|
|
1161
|
-
return { from:
|
|
1162
|
-
const
|
|
1206
|
+
return { from: r, to: t };
|
|
1207
|
+
if (r >= s)
|
|
1208
|
+
return { from: r + i, to: t + i };
|
|
1209
|
+
const n = Math.min(r, e.start), o = Math.max(
|
|
1163
1210
|
t > s ? t + i : e.start + e.inserted,
|
|
1164
1211
|
e.start + e.inserted
|
|
1165
1212
|
);
|
|
1166
|
-
return
|
|
1213
|
+
return n >= o ? null : { from: n, to: o };
|
|
1167
1214
|
}
|
|
1168
|
-
function
|
|
1215
|
+
function Ne(r, t) {
|
|
1169
1216
|
let e = 0;
|
|
1170
|
-
for (let s = 0; s < t && s <
|
|
1171
|
-
|
|
1217
|
+
for (let s = 0; s < t && s < r.length; s++)
|
|
1218
|
+
r[s] === `
|
|
1172
1219
|
` && e++;
|
|
1173
1220
|
return e;
|
|
1174
1221
|
}
|
|
1175
|
-
function
|
|
1176
|
-
const s =
|
|
1177
|
-
for (const
|
|
1178
|
-
if (
|
|
1179
|
-
const m =
|
|
1180
|
-
m &&
|
|
1181
|
-
} else if (
|
|
1182
|
-
|
|
1183
|
-
else {
|
|
1184
|
-
const m =
|
|
1185
|
-
m &&
|
|
1222
|
+
function xe(r, t, e) {
|
|
1223
|
+
const s = Mt(t, e), i = s.start + s.removed, n = t.slice(s.start, i), o = e.slice(s.start, s.start + s.inserted), a = (n.match(/\n/g) ?? []).length, c = (o.match(/\n/g) ?? []).length - a, h = Ne(t, s.start) + 1, u = h + a, d = [];
|
|
1224
|
+
for (const f of r)
|
|
1225
|
+
if (f.type === "mark") {
|
|
1226
|
+
const m = _t(f.from, f.to, s);
|
|
1227
|
+
m && d.push({ ...f, from: m.from, to: m.to });
|
|
1228
|
+
} else if (f.type === "line")
|
|
1229
|
+
f.line < h ? d.push(f) : f.line <= u || d.push({ ...f, line: f.line + c });
|
|
1230
|
+
else if (f.type === "widget") {
|
|
1231
|
+
const m = _t(f.offset, f.offset + 1, s);
|
|
1232
|
+
m && d.push({ ...f, offset: m.from });
|
|
1186
1233
|
}
|
|
1187
|
-
return
|
|
1234
|
+
return d;
|
|
1188
1235
|
}
|
|
1189
|
-
function
|
|
1190
|
-
if (
|
|
1236
|
+
function we(r, t) {
|
|
1237
|
+
if (r.length === 0)
|
|
1191
1238
|
return !1;
|
|
1192
1239
|
const e = Math.max(t.removed, t.inserted);
|
|
1193
|
-
return e > 50 && e >
|
|
1240
|
+
return e > 50 && e > r.length * 0.5;
|
|
1194
1241
|
}
|
|
1195
|
-
function
|
|
1196
|
-
const s =
|
|
1197
|
-
return
|
|
1242
|
+
function Q(r, t, e) {
|
|
1243
|
+
const s = Mt(t, e);
|
|
1244
|
+
return we(t, s) ? [] : xe(r, t, e);
|
|
1198
1245
|
}
|
|
1199
|
-
function
|
|
1246
|
+
function bt(r, t) {
|
|
1200
1247
|
const e = crypto.randomUUID();
|
|
1201
|
-
return
|
|
1248
|
+
return r.set(e, { ...t, id: e }), e;
|
|
1202
1249
|
}
|
|
1203
|
-
function
|
|
1204
|
-
|
|
1250
|
+
function Ee(r, t) {
|
|
1251
|
+
r.clear();
|
|
1205
1252
|
for (const e of t) {
|
|
1206
1253
|
const s = crypto.randomUUID();
|
|
1207
|
-
|
|
1254
|
+
r.set(s, { ...e, id: s });
|
|
1208
1255
|
}
|
|
1209
1256
|
}
|
|
1210
|
-
function
|
|
1257
|
+
function Ce(r, t) {
|
|
1211
1258
|
const e = [], s = [];
|
|
1212
1259
|
for (const i of t) {
|
|
1213
|
-
let
|
|
1214
|
-
i.captureGroups && !
|
|
1215
|
-
const o = new RegExp(i.pattern.source,
|
|
1260
|
+
let n = i.pattern.flags.includes("g") ? i.pattern.flags : i.pattern.flags + "g";
|
|
1261
|
+
i.captureGroups && !n.includes("d") && (n += "d");
|
|
1262
|
+
const o = new RegExp(i.pattern.source, n);
|
|
1216
1263
|
let a;
|
|
1217
|
-
for (; (a = o.exec(
|
|
1264
|
+
for (; (a = o.exec(r)) !== null; ) {
|
|
1218
1265
|
if (a[0].length === 0) {
|
|
1219
1266
|
o.lastIndex++;
|
|
1220
1267
|
continue;
|
|
1221
1268
|
}
|
|
1222
1269
|
const l = a.index;
|
|
1223
1270
|
if (i.captureGroups) {
|
|
1224
|
-
const
|
|
1225
|
-
if (
|
|
1226
|
-
for (const [
|
|
1227
|
-
const
|
|
1228
|
-
if (
|
|
1271
|
+
const c = a.indices?.groups;
|
|
1272
|
+
if (c)
|
|
1273
|
+
for (const [h, u] of Object.entries(i.captureGroups)) {
|
|
1274
|
+
const d = c[h];
|
|
1275
|
+
if (d === void 0)
|
|
1229
1276
|
continue;
|
|
1230
|
-
const [
|
|
1231
|
-
e.push({ type: "mark", from:
|
|
1277
|
+
const [f, m] = d;
|
|
1278
|
+
e.push({ type: "mark", from: f, to: m, ...u });
|
|
1232
1279
|
}
|
|
1233
1280
|
} else {
|
|
1234
|
-
const
|
|
1281
|
+
const c = l + a[0].length;
|
|
1235
1282
|
e.push({
|
|
1236
1283
|
type: "mark",
|
|
1237
1284
|
from: l,
|
|
1238
|
-
to:
|
|
1285
|
+
to: c,
|
|
1239
1286
|
className: i.className,
|
|
1240
1287
|
bold: i.bold,
|
|
1241
1288
|
italic: i.italic,
|
|
@@ -1247,240 +1294,150 @@ function le(n, t) {
|
|
|
1247
1294
|
});
|
|
1248
1295
|
}
|
|
1249
1296
|
if (i.createLineDecoration) {
|
|
1250
|
-
const
|
|
1251
|
-
if (
|
|
1252
|
-
const
|
|
1297
|
+
const c = i.createLineDecoration(a);
|
|
1298
|
+
if (c) {
|
|
1299
|
+
const h = r.slice(0, l).split(`
|
|
1253
1300
|
`).length;
|
|
1254
|
-
s.push({ type: "line", line:
|
|
1301
|
+
s.push({ type: "line", line: h, ...c });
|
|
1255
1302
|
}
|
|
1256
1303
|
}
|
|
1257
1304
|
}
|
|
1258
1305
|
}
|
|
1259
1306
|
return { markDecorations: e, lineDecorations: s };
|
|
1260
1307
|
}
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
#gutter-cells {
|
|
1299
|
-
padding: var(--rc-textarea-padding, 0.5em);
|
|
1300
|
-
padding-inline-end: var(--rc-textarea-gutter-padding-inline-end, 0.75em);
|
|
1301
|
-
font-family: var(--rc-textarea-gutter-font-family, var(--rc-textarea-font-family, monospace));
|
|
1302
|
-
font-size: var(--rc-textarea-font-size, 1em);
|
|
1303
|
-
line-height: var(--rc-textarea-line-height, 1.5);
|
|
1304
|
-
text-align: right;
|
|
1305
|
-
min-width: 2.5ch;
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
.gutter-cell {
|
|
1309
|
-
display: block;
|
|
1310
|
-
white-space: pre;
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
.gutter-cell--active {
|
|
1314
|
-
color: var(--rc-textarea-color, var(--rc-text, FieldText));
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
#editor-area {
|
|
1318
|
-
position: relative;
|
|
1319
|
-
flex: 1;
|
|
1320
|
-
min-width: 0;
|
|
1321
|
-
overflow: hidden;
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
#editor {
|
|
1325
|
-
position: relative;
|
|
1326
|
-
z-index: 1;
|
|
1327
|
-
width: 100%;
|
|
1328
|
-
min-height: 100%;
|
|
1329
|
-
box-sizing: border-box;
|
|
1330
|
-
padding: var(--rc-textarea-padding, 0.5em);
|
|
1331
|
-
font-family: var(--rc-textarea-font-family, monospace);
|
|
1332
|
-
font-size: var(--rc-textarea-font-size, 1em);
|
|
1333
|
-
line-height: var(--rc-textarea-line-height, 1.5);
|
|
1334
|
-
color: var(--rc-textarea-color, var(--rc-text, FieldText));
|
|
1335
|
-
caret-color: var(--rc-textarea-caret-color, var(--rc-textarea-color, FieldText));
|
|
1336
|
-
background: transparent;
|
|
1337
|
-
outline: none;
|
|
1338
|
-
overflow: auto;
|
|
1339
|
-
resize: none;
|
|
1340
|
-
white-space: pre;
|
|
1341
|
-
word-break: normal;
|
|
1342
|
-
overflow-wrap: normal;
|
|
1343
|
-
tab-size: 4;
|
|
1344
|
-
word-break: normal;
|
|
1345
|
-
/* Prevent contenteditable from injecting <div> wrappers on Enter in some browsers */
|
|
1346
|
-
-webkit-user-modify: read-write-plaintext-only;
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
:host([word-wrap]) #editor {
|
|
1350
|
-
white-space: pre-wrap;
|
|
1351
|
-
overflow-wrap: break-word;
|
|
1352
|
-
word-break: normal;
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
:host([auto-grow]) #editor {
|
|
1356
|
-
overflow: visible;
|
|
1357
|
-
height: auto;
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
:host([auto-grow]) #root {
|
|
1361
|
-
height: auto;
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
:host([read-only]) #root {
|
|
1365
|
-
border: none;
|
|
1366
|
-
background: transparent;
|
|
1367
|
-
border-radius: 0;
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
:host([read-only]) #editor {
|
|
1371
|
-
cursor: default;
|
|
1372
|
-
padding: 0;
|
|
1373
|
-
-webkit-user-modify: read-only;
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
/* Focus ring on the root when editor is focused */
|
|
1377
|
-
#root:has(#editor:focus) {
|
|
1378
|
-
outline: var(--rc-textarea-focus-outline, 2px solid Highlight);
|
|
1379
|
-
outline-offset: -1px;
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
/* Slotted textarea is hidden on host upgrade */
|
|
1383
|
-
::slotted(textarea) {
|
|
1384
|
-
position: absolute !important;
|
|
1385
|
-
width: 1px !important;
|
|
1386
|
-
height: 1px !important;
|
|
1387
|
-
padding: 0 !important;
|
|
1388
|
-
margin: -1px !important;
|
|
1389
|
-
overflow: hidden !important;
|
|
1390
|
-
clip: rect(0, 0, 0, 0) !important;
|
|
1391
|
-
border: 0 !important;
|
|
1392
|
-
opacity: 0 !important;
|
|
1393
|
-
pointer-events: none !important;
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
.line {
|
|
1397
|
-
position: relative;
|
|
1398
|
-
display: block;
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
/* Active line highlight — opt-in via CSS custom property. */
|
|
1402
|
-
.line--active {
|
|
1403
|
-
background: var(--rc-textarea-active-line-bg, transparent);
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
/* Error-lens -style end-of-line diagnostic message */
|
|
1407
|
-
.line[data-message]::after {
|
|
1408
|
-
content: attr(data-message);
|
|
1409
|
-
display: inline;
|
|
1410
|
-
margin-left: 4ch;
|
|
1411
|
-
white-space: nowrap;
|
|
1412
|
-
pointer-events: none;
|
|
1413
|
-
font-size: 0.875em;
|
|
1414
|
-
opacity: 0.8;
|
|
1415
|
-
font-style: italic;
|
|
1308
|
+
const Ae = Ut`.widget.widget--block{white-space:normal;display:block}.line--trailing-widget{min-block-size:var(--rc-textarea-trailing-size,2.5em);padding-inline-end:var(--rc-textarea-trailing-size,2.5em);position:relative}.widget--trailing{inline-size:var(--rc-textarea-trailing-size,2.5em);white-space:normal;position:absolute;inset-block-start:0;inset-inline-end:0}.fold-action-trigger{box-sizing:border-box;cursor:pointer;block-size:1lh;inline-size:100%;color:inherit;font:inherit;background:0 0;border:0;padding:0}.gutter-cell{position:relative}.gutter-cell>.fold-action-trigger:before,.gutter-cell>:not(.fold-action-group) .fold-action-trigger:before{content:"";position:absolute;inset:0}.fold-action-group,.fold-action-single{vertical-align:top;align-items:center;display:inline-flex}.fold-action-group .fold-action-trigger{min-inline-size:24px}.widget--trailing .fold-action-trigger{min-block-size:var(--rc-textarea-trailing-size,2.5em)}.widget--block [hidden]{display:none}:host{box-sizing:border-box;min-inline-size:0;color-scheme:inherit;display:block}:host([hidden]){display:none}#root{border:var(--rc-textarea-border,1px solid ButtonBorder);border-radius:var(--rc-textarea-border-radius,2px);background:var(--rc-textarea-background,Field);color:var(--rc-textarea-color,var(--rc-field-text,FieldText));min-height:var(--_rc-textarea-min-height,auto);align-items:stretch;display:flex;overflow:hidden}#gutter{background:var(--rc-textarea-gutter-bg,Canvas);color:var(--rc-textarea-gutter-color,GrayText);border-inline-end:var(--rc-textarea-gutter-border,1px solid ButtonBorder);user-select:none;flex-shrink:0;display:none;overflow:hidden}:host([line-numbers]) #gutter,:host([gutter]) #gutter{display:block}#gutter-cells{box-sizing:border-box;padding-block:var(--rc-textarea-padding-block,.5em);padding-inline:var(--rc-textarea-padding-inline,.5em) var(--rc-textarea-gutter-padding-inline-end,.75em);font-family:var(--rc-textarea-gutter-font-family,var(--rc-textarea-font-family,monospace));font-size:var(--rc-textarea-font-size,1em);line-height:var(--rc-textarea-line-height,1.5);text-align:end;min-inline-size:var(--rc-textarea-gutter-min-inline-size,24px)}.gutter-cell{min-inline-size:var(--rc-textarea-gutter-min-inline-size,24px);white-space:pre;display:block}.gutter-cell[hidden],.line[hidden]{display:none}.gutter-cell-composite{align-items:center;gap:var(--rc-textarea-gutter-content-gap,.25em);display:inline-flex}.gutter-cell-number{font-variant-numeric:tabular-nums}.gutter-cell-content{align-items:center;display:inline-flex}.gutter-cell--active{isolation:isolate;color:var(--rc-textarea-color,var(--rc-field-text,FieldText));position:relative}.gutter-cell--active:before{content:"";z-index:-1;background:var(--rc-textarea-active-line-bg,transparent);pointer-events:none;position:absolute;inset-block:0;inset-inline-start:calc(-1 * var(--rc-textarea-padding-inline,.5em));inset-inline-end:calc(-1 * var(--rc-textarea-gutter-padding-inline-end,.75em))}#editor-area{flex:1;min-width:0;position:relative;overflow:hidden}#editor{z-index:1;box-sizing:border-box;width:100%;min-height:100%;padding-block:var(--rc-textarea-padding-block,.5em);padding-inline:var(--rc-textarea-padding-inline,.5em);font-family:var(--rc-textarea-font-family,monospace);font-size:var(--rc-textarea-font-size,1em);line-height:var(--rc-textarea-line-height,1.5);color:var(--rc-textarea-color,var(--rc-field-text,FieldText));caret-color:var(--rc-textarea-caret-color,var(--rc-textarea-color,FieldText));resize:none;white-space:pre;word-break:normal;overflow-wrap:normal;tab-size:4;word-break:normal;-webkit-user-modify:read-write-plaintext-only;background:0 0;outline:none;position:relative;overflow:auto}:host([word-wrap]) #editor{white-space:pre-wrap;overflow-wrap:break-word;word-break:normal}:host([auto-grow]) #editor{height:auto;overflow:visible}:host([auto-grow]) #root{height:auto}:host([data-readonly]) #editor{-webkit-user-modify:read-only}#root:has(#editor:focus){outline:var(--rc-textarea-focus-outline,2px solid Highlight);outline-offset:-1px}::slotted(textarea){clip:rect(0, 0, 0, 0)!important;opacity:0!important;pointer-events:none!important;border:0!important;width:1px!important;height:1px!important;margin:-1px!important;padding:0!important;position:absolute!important;overflow:hidden!important}.line{display:block;position:relative}:host(:not([word-wrap])) .line{inline-size:max-content;min-inline-size:100%}.line--active{isolation:isolate}.line--active:before{content:"";z-index:-1;inset-block:0;inset-inline:calc(-1 * var(--rc-textarea-padding-inline,.5em));background:var(--rc-textarea-active-line-bg,transparent);pointer-events:none;position:absolute}.line[data-message]:after{content:attr(data-message);white-space:nowrap;pointer-events:none;opacity:.8;unicode-bidi:isolate;margin-inline-start:4ch;font-size:.875em;font-style:italic;display:inline}:host([line-direction=auto]) .line:not(.line--neutral){unicode-bidi:plaintext}.mark{border-radius:2px}.widget{user-select:none;cursor:default;vertical-align:middle;unicode-bidi:isolate;display:inline-block}`;
|
|
1309
|
+
var Oe = Object.defineProperty, Le = Object.getOwnPropertyDescriptor, v = (r, t, e, s) => {
|
|
1310
|
+
for (var i = s > 1 ? void 0 : s ? Le(t, e) : t, n = r.length - 1, o; n >= 0; n--)
|
|
1311
|
+
(o = r[n]) && (i = (s ? o(t, e, i) : o(i)) || i);
|
|
1312
|
+
return s && i && Oe(t, e, i), i;
|
|
1313
|
+
};
|
|
1314
|
+
function Se(r, t) {
|
|
1315
|
+
const e = r.split(`
|
|
1316
|
+
`), s = [];
|
|
1317
|
+
let i = 0;
|
|
1318
|
+
for (const n of e)
|
|
1319
|
+
s.push(i), i += n.length + 1;
|
|
1320
|
+
return t.flatMap((n) => n.fromLine < 2 || n.toLine < n.fromLine || n.toLine > e.length ? [] : [
|
|
1321
|
+
{
|
|
1322
|
+
from: s[n.fromLine - 1],
|
|
1323
|
+
to: s[n.toLine - 1] + e[n.toLine - 1].length,
|
|
1324
|
+
anchorEnd: s[n.fromLine - 2] + e[n.fromLine - 2].length,
|
|
1325
|
+
reveal: n.reveal
|
|
1326
|
+
}
|
|
1327
|
+
]);
|
|
1328
|
+
}
|
|
1329
|
+
const ke = 100, Te = /[\p{L}\u061C\u200E\u200F]/u, Be = /[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF\u061C\u200F\u{10800}-\u{10FFF}\u{1E800}-\u{1EFFF}]/u, De = /[\p{L}\p{N}]/u, vt = /[\p{L}\p{M}\p{N}_]/u;
|
|
1330
|
+
function yt(r) {
|
|
1331
|
+
let t = 0;
|
|
1332
|
+
for (const e of r) {
|
|
1333
|
+
if ("".includes(e)) {
|
|
1334
|
+
t += 1;
|
|
1335
|
+
continue;
|
|
1336
|
+
}
|
|
1337
|
+
if (e === "") {
|
|
1338
|
+
t = Math.max(0, t - 1);
|
|
1339
|
+
continue;
|
|
1340
|
+
}
|
|
1341
|
+
if (t === 0 && Te.test(e))
|
|
1342
|
+
return Be.test(e) ? "rtl" : "ltr";
|
|
1416
1343
|
}
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1344
|
+
return null;
|
|
1345
|
+
}
|
|
1346
|
+
const Nt = /* @__PURE__ */ new Map();
|
|
1347
|
+
function Re(r) {
|
|
1348
|
+
let t = Nt.get(r);
|
|
1349
|
+
if (t === void 0) {
|
|
1350
|
+
if (typeof Intl.Segmenter != "function")
|
|
1351
|
+
t = null;
|
|
1352
|
+
else
|
|
1353
|
+
try {
|
|
1354
|
+
t = new Intl.Segmenter(r || void 0, { granularity: "word" });
|
|
1355
|
+
} catch {
|
|
1356
|
+
t = new Intl.Segmenter(void 0, { granularity: "word" });
|
|
1357
|
+
}
|
|
1358
|
+
Nt.set(r, t);
|
|
1420
1359
|
}
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1360
|
+
return t;
|
|
1361
|
+
}
|
|
1362
|
+
function $e(r, t, e) {
|
|
1363
|
+
const s = Re(e);
|
|
1364
|
+
if (!s) {
|
|
1365
|
+
let n = t, o = t;
|
|
1366
|
+
for (; n > 0 && vt.test(r.charAt(n - 1)); )
|
|
1367
|
+
n--;
|
|
1368
|
+
for (; o < r.length && vt.test(r.charAt(o)); )
|
|
1369
|
+
o++;
|
|
1370
|
+
return n === o ? null : { from: n, to: o };
|
|
1371
|
+
}
|
|
1372
|
+
const i = s.segment(r);
|
|
1373
|
+
for (const n of [t, t - 1]) {
|
|
1374
|
+
if (n < 0 || n >= r.length)
|
|
1375
|
+
continue;
|
|
1376
|
+
const o = i.containing(n);
|
|
1377
|
+
if (o && De.test(o.segment))
|
|
1378
|
+
return { from: o.index, to: o.index + o.segment.length };
|
|
1427
1379
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
(o = n[r]) && (i = (s ? o(t, e, i) : o(i)) || i);
|
|
1432
|
-
return s && i && he(t, e, i), i;
|
|
1433
|
-
};
|
|
1434
|
-
const de = 100;
|
|
1435
|
-
function ct(n) {
|
|
1380
|
+
return null;
|
|
1381
|
+
}
|
|
1382
|
+
function xt(r) {
|
|
1436
1383
|
const t = document.createElement("div");
|
|
1437
|
-
t.innerHTML =
|
|
1384
|
+
t.innerHTML = r;
|
|
1438
1385
|
const e = [];
|
|
1439
1386
|
let s = 0;
|
|
1440
|
-
function i(
|
|
1441
|
-
if (
|
|
1442
|
-
s +=
|
|
1387
|
+
function i(n) {
|
|
1388
|
+
if (n.nodeType === Node.TEXT_NODE) {
|
|
1389
|
+
s += n.length;
|
|
1443
1390
|
return;
|
|
1444
1391
|
}
|
|
1445
|
-
if (!(
|
|
1392
|
+
if (!(n instanceof HTMLElement))
|
|
1446
1393
|
return;
|
|
1447
|
-
const o =
|
|
1448
|
-
for (const l of
|
|
1394
|
+
const o = n.tagName === "SPAN" && n.className, a = s;
|
|
1395
|
+
for (const l of n.childNodes)
|
|
1449
1396
|
i(l);
|
|
1450
1397
|
o && s > a && e.push({
|
|
1451
1398
|
type: "mark",
|
|
1452
1399
|
from: a,
|
|
1453
1400
|
to: s,
|
|
1454
|
-
className:
|
|
1401
|
+
className: n.className
|
|
1455
1402
|
});
|
|
1456
1403
|
}
|
|
1457
|
-
for (const
|
|
1458
|
-
i(
|
|
1404
|
+
for (const n of t.childNodes)
|
|
1405
|
+
i(n);
|
|
1459
1406
|
return e;
|
|
1460
1407
|
}
|
|
1461
|
-
const
|
|
1408
|
+
const j = class j extends ct {
|
|
1462
1409
|
constructor() {
|
|
1463
|
-
super(...arguments), this.lineNumbers = !1, this.gutter = !1, this.wordWrap = !1, this.autoGrow = !1, this.
|
|
1410
|
+
super(...arguments), this.lineNumbers = !1, this.gutter = !1, this.wordWrap = !1, this.autoGrow = !1, this.lineDirection = "base", this._readOnly = !1, this._textareaAttributeObserver = null, this._value = "", this._initialValueResolved = !1, this._valueSetByHost = !1, this._document = null, this._$textareaRef = null, this._textareaController = new qt(this, {
|
|
1464
1411
|
selector: ":scope > textarea",
|
|
1465
1412
|
observe: !0,
|
|
1466
1413
|
onChange: (t, e) => this._setupTextarea(t, e),
|
|
1467
1414
|
onMissing: () => {
|
|
1468
1415
|
}
|
|
1469
|
-
}), this.
|
|
1416
|
+
}), this._flowController = new Wt(this), this._localeController = new Kt(this, {
|
|
1417
|
+
onChange: () => this._scheduleRender()
|
|
1418
|
+
}), this._pluginDecorations = /* @__PURE__ */ new Map(), this._patternDecorations = [], this._externalDecorations = [], this._patterns = /* @__PURE__ */ new Map(), this._plugin = null, this._pluginProperty = null, this._pluginApi = null, this._pluginSeq = 0, this._pluginSheets = /* @__PURE__ */ new Set(), this._savedSelection = null, this._rafHandle = null, this._composing = !1, this._contentAttributesPendingRender = !1, this._tabMovesFocus = !1, this._isRendering = !1, this._$activeLine = null, this._cursorCallbacks = /* @__PURE__ */ new Set(), this._docSelectionChangeHandler = () => {
|
|
1470
1419
|
document.activeElement === this && this._onSelectionChange();
|
|
1471
|
-
}, this._undoStack = [], this._undoIndex = -1, this._resizeObserver = null, this._gutterLabels = [], this._onTextareaInvalid = () => {
|
|
1420
|
+
}, this._undoStack = [], this._undoIndex = -1, this._resizeObserver = null, this._gutterBlockAxis = null, this._gutterLabels = [], this._accessibleGutterLines = /* @__PURE__ */ new Set(), this._foldedRanges = [], this._foldBounds = [], this._hiddenGutterLines = /* @__PURE__ */ new Set(), this._onTextareaInvalid = () => {
|
|
1472
1421
|
this._$editor && this._$editor.setAttribute("aria-invalid", "true");
|
|
1473
1422
|
}, this._onInputEvent = () => {
|
|
1474
1423
|
this._composing || this._onInput();
|
|
1475
1424
|
}, this._onBeforeInput = (t) => {
|
|
1476
|
-
|
|
1425
|
+
if (!(this.readOnly || this._isWidgetEvent(t))) {
|
|
1426
|
+
if (this._revealFoldForEdit(t.inputType)) {
|
|
1427
|
+
t.preventDefault();
|
|
1428
|
+
return;
|
|
1429
|
+
}
|
|
1430
|
+
!this._composing && !t.isComposing && (t.inputType === "insertParagraph" || t.inputType === "insertLineBreak") && (t.preventDefault(), this._insertText(`
|
|
1477
1431
|
`));
|
|
1432
|
+
}
|
|
1478
1433
|
}, this._onSelectionChange = () => {
|
|
1479
1434
|
if (!this._$editor)
|
|
1480
1435
|
return;
|
|
1481
|
-
const t =
|
|
1436
|
+
const t = E(this._$editor);
|
|
1482
1437
|
if (t) {
|
|
1483
|
-
this._savedSelection = t, this.
|
|
1438
|
+
if (this._savedSelection = t, t.anchorOffset === t.focusOffset && this._revealFoldAtOffset(t.focusOffset))
|
|
1439
|
+
return;
|
|
1440
|
+
this.dispatchEvent(
|
|
1484
1441
|
new CustomEvent("rc-textarea-select", {
|
|
1485
1442
|
bubbles: !0,
|
|
1486
1443
|
composed: !0,
|
|
@@ -1495,23 +1452,43 @@ const V = class V extends st {
|
|
|
1495
1452
|
i(e, s);
|
|
1496
1453
|
}
|
|
1497
1454
|
}, this._onKeyDown = (t) => {
|
|
1455
|
+
if (this.readOnly || this._isWidgetEvent(t))
|
|
1456
|
+
return;
|
|
1498
1457
|
if (t.key === "Enter" && !this._composing && !t.isComposing) {
|
|
1499
|
-
t.preventDefault(), this.
|
|
1458
|
+
if (t.preventDefault(), this._revealFoldForEdit("insertParagraph"))
|
|
1459
|
+
return;
|
|
1460
|
+
this._insertText(`
|
|
1500
1461
|
`);
|
|
1501
1462
|
return;
|
|
1502
1463
|
}
|
|
1503
|
-
if (t.key === "
|
|
1464
|
+
if (t.key === "Escape") {
|
|
1465
|
+
this._tabMovesFocus = !0;
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
const e = this._tabMovesFocus;
|
|
1469
|
+
if (this._tabMovesFocus = !1, t.key === "Tab" && !t.shiftKey && !t.ctrlKey && !t.metaKey && !t.altKey) {
|
|
1470
|
+
if (e || this._$editor?.querySelector(".widget:not([aria-hidden])"))
|
|
1471
|
+
return;
|
|
1504
1472
|
t.preventDefault(), this._insertText(" ");
|
|
1505
1473
|
return;
|
|
1506
1474
|
}
|
|
1507
|
-
const
|
|
1508
|
-
if (
|
|
1475
|
+
const s = (t.ctrlKey || t.metaKey) && t.key === "z" && !t.shiftKey, i = (t.ctrlKey || t.metaKey) && t.key === "y" || (t.ctrlKey || t.metaKey) && t.shiftKey && t.key === "z";
|
|
1476
|
+
if (s) {
|
|
1509
1477
|
t.preventDefault(), this._undo();
|
|
1510
1478
|
return;
|
|
1511
1479
|
}
|
|
1512
|
-
|
|
1480
|
+
i && (t.preventDefault(), this._redo());
|
|
1481
|
+
}, this._onCopy = (t) => {
|
|
1482
|
+
if (!this._$editor || this._isWidgetEvent(t) || !t.clipboardData || !this._$editor.querySelector(".widget") && this._foldedRanges.length === 0)
|
|
1483
|
+
return;
|
|
1484
|
+
const e = E(this._$editor);
|
|
1485
|
+
if (!e || e.anchorOffset === e.focusOffset)
|
|
1486
|
+
return;
|
|
1487
|
+
const s = Math.min(e.anchorOffset, e.focusOffset), i = Math.max(e.anchorOffset, e.focusOffset);
|
|
1488
|
+
t.clipboardData.setData("text/plain", J(this._$editor).slice(s, i)), t.preventDefault(), t.type === "cut" && !this.readOnly && this._insertText("");
|
|
1513
1489
|
}, this._onPaste = (t) => {
|
|
1514
|
-
t.preventDefault()
|
|
1490
|
+
if (this.readOnly || this._isWidgetEvent(t) || (t.preventDefault(), this._revealFoldForEdit("insertFromPaste")))
|
|
1491
|
+
return;
|
|
1515
1492
|
const e = t.clipboardData?.getData("text/plain") ?? "";
|
|
1516
1493
|
if (!e)
|
|
1517
1494
|
return;
|
|
@@ -1521,6 +1498,13 @@ const V = class V extends st {
|
|
|
1521
1498
|
this._insertText(s);
|
|
1522
1499
|
};
|
|
1523
1500
|
}
|
|
1501
|
+
/**
|
|
1502
|
+
* Whether the slotted `<textarea>` is `readonly`. The native control is the
|
|
1503
|
+
* source of truth; set `readonly` on it to change this state.
|
|
1504
|
+
*/
|
|
1505
|
+
get readOnly() {
|
|
1506
|
+
return this._readOnly;
|
|
1507
|
+
}
|
|
1524
1508
|
get plugin() {
|
|
1525
1509
|
return this._pluginProperty;
|
|
1526
1510
|
}
|
|
@@ -1551,20 +1535,88 @@ const V = class V extends st {
|
|
|
1551
1535
|
}
|
|
1552
1536
|
connectedCallback() {
|
|
1553
1537
|
super.connectedCallback(), this._pluginProperty && !this._plugin && this.usePlugin(this._pluginProperty), document.addEventListener("selectionchange", this._docSelectionChangeHandler);
|
|
1538
|
+
const t = this._$textareaRef?.deref();
|
|
1539
|
+
t && (this._observeTextarea(t), this._syncReadOnly(), this._syncContentAttributes());
|
|
1554
1540
|
}
|
|
1555
1541
|
disconnectedCallback() {
|
|
1556
|
-
super.disconnectedCallback(), document.removeEventListener("selectionchange", this._docSelectionChangeHandler), this._plugin?.destroy?.(), this._plugin = null, this._pluginApi = null, this._clearPluginSheets(), this._cursorCallbacks.clear(), this._resizeObserver?.disconnect(), this._$textareaRef?.deref()?.removeEventListener("invalid", this._onTextareaInvalid), this._rafHandle !== null && (cancelAnimationFrame(this._rafHandle), this._rafHandle = null);
|
|
1542
|
+
super.disconnectedCallback(), document.removeEventListener("selectionchange", this._docSelectionChangeHandler), this._plugin?.destroy?.(), this._plugin = null, this._pluginApi = null, this._clearPluginSheets(), this._cursorCallbacks.clear(), this._resizeObserver?.disconnect(), this._textareaAttributeObserver?.disconnect(), this._$textareaRef?.deref()?.removeEventListener("invalid", this._onTextareaInvalid), this._rafHandle !== null && (cancelAnimationFrame(this._rafHandle), this._rafHandle = null);
|
|
1557
1543
|
}
|
|
1558
1544
|
firstUpdated() {
|
|
1559
|
-
this._$editor && (this._document = new
|
|
1545
|
+
this._$editor && (this._document = new be(this._$editor), this._bindEditorEvents(this._$editor), this._syncLabel()), this._resizeObserver = new ResizeObserver(() => {
|
|
1560
1546
|
this._syncGutter(), this._syncGutterHeights();
|
|
1561
|
-
}), this._resizeObserver.observe(this), this._scheduleRender();
|
|
1547
|
+
}), this._resizeObserver.observe(this), this._syncReadOnly(), this._syncContentAttributes(), this._scheduleRender();
|
|
1562
1548
|
}
|
|
1563
1549
|
updated(t) {
|
|
1564
|
-
t.has("
|
|
1550
|
+
(t.has("lineNumbers") || t.has("gutter") || t.has("lineDirection")) && this._scheduleRender(), this._syncContentDirection();
|
|
1551
|
+
}
|
|
1552
|
+
_observeTextarea(t) {
|
|
1553
|
+
this._textareaAttributeObserver ??= new MutationObserver((e) => {
|
|
1554
|
+
this._syncReadOnly(), this._syncContentAttributes(), e.some((s) => s.attributeName === "lang" || s.attributeName === "dir") && (this._composing ? this._contentAttributesPendingRender = !0 : this._scheduleRender());
|
|
1555
|
+
}), this._textareaAttributeObserver.disconnect(), this._textareaAttributeObserver.observe(t, {
|
|
1556
|
+
attributes: !0,
|
|
1557
|
+
attributeFilter: ["readonly", "lang", "dir", "spellcheck"]
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Mirror the native textarea's content attributes onto the editor. `lang`
|
|
1562
|
+
* picks glyphs, the spelling dictionary and word boundaries; `spellcheck`
|
|
1563
|
+
* stays off unless the textarea sets it. The host's own `lang` is the
|
|
1564
|
+
* interface language and is never copied.
|
|
1565
|
+
*/
|
|
1566
|
+
_syncContentAttributes() {
|
|
1567
|
+
if (!this._$editor)
|
|
1568
|
+
return;
|
|
1569
|
+
const t = this._$textareaRef?.deref(), e = t?.getAttribute("lang") ?? null;
|
|
1570
|
+
e === null ? this._$editor.removeAttribute("lang") : this._$editor.getAttribute("lang") !== e && this._$editor.setAttribute("lang", e), this._$editor.spellcheck = t?.hasAttribute("spellcheck") ? t.spellcheck : !1, this._syncContentDirection();
|
|
1571
|
+
}
|
|
1572
|
+
/**
|
|
1573
|
+
* Set the editor's base direction from the textarea's `dir`. `auto` reads
|
|
1574
|
+
* the native control's directionality, including its LTR neutral fallback;
|
|
1575
|
+
* without `dir` the editor inherits. Composition keeps the current direction
|
|
1576
|
+
* so the IME session isn't disturbed.
|
|
1577
|
+
*/
|
|
1578
|
+
_syncContentDirection() {
|
|
1579
|
+
if (!this._$editor || this._composing)
|
|
1580
|
+
return;
|
|
1581
|
+
const t = this._$textareaRef?.deref(), e = t?.getAttribute("dir")?.toLowerCase();
|
|
1582
|
+
let s = null;
|
|
1583
|
+
e === "ltr" || e === "rtl" ? s = e : e === "auto" && t && (s = t.matches(":dir(rtl)") ? "rtl" : "ltr"), s === null ? this._$editor.removeAttribute("dir") : this._$editor.getAttribute("dir") !== s && this._$editor.setAttribute("dir", s);
|
|
1584
|
+
}
|
|
1585
|
+
/** The textarea's `lang`, or `''` when it sets none. */
|
|
1586
|
+
_contentLang() {
|
|
1587
|
+
return this._$textareaRef?.deref()?.getAttribute("lang") ?? "";
|
|
1588
|
+
}
|
|
1589
|
+
/** The editor's resolved base direction. */
|
|
1590
|
+
_contentDirection() {
|
|
1591
|
+
return V(this._$editor ?? this).rtl ? "rtl" : "ltr";
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* Mark lines with no strong character so `line-direction="auto"` holds them
|
|
1595
|
+
* to the base direction. Reads the model value, which composition text
|
|
1596
|
+
* doesn't reach until `compositionend`, so a composing line keeps its mark.
|
|
1597
|
+
*/
|
|
1598
|
+
_syncLineDirections(t) {
|
|
1599
|
+
if (!this._$editor)
|
|
1600
|
+
return;
|
|
1601
|
+
const e = this.lineDirection === "auto", s = t.split(`
|
|
1602
|
+
`), i = this._$editor.querySelectorAll(":scope > .line");
|
|
1603
|
+
for (const [n, o] of i.entries())
|
|
1604
|
+
o.classList.toggle(
|
|
1605
|
+
"line--neutral",
|
|
1606
|
+
e && yt(s[n] ?? "") === null
|
|
1607
|
+
);
|
|
1608
|
+
}
|
|
1609
|
+
/**
|
|
1610
|
+
* Mirror the native textarea's `readonly` attribute: the editor stays a
|
|
1611
|
+
* focusable, selectable textbox that announces `aria-readonly`, and edits
|
|
1612
|
+
* are blocked by the existing input guards.
|
|
1613
|
+
*/
|
|
1614
|
+
_syncReadOnly() {
|
|
1615
|
+
const t = this._$textareaRef?.deref()?.readOnly ?? !1, e = t !== this._readOnly;
|
|
1616
|
+
this._readOnly = t, this.toggleAttribute("data-readonly", t), this._$editor && (this._$editor.contentEditable = t ? "false" : "true", t ? (this._$editor.setAttribute("aria-readonly", "true"), this._$editor.tabIndex = 0) : (this._$editor.removeAttribute("aria-readonly"), this._$editor.removeAttribute("tabindex"))), e && this._scheduleRender(), this._$editor && V(this._$editor).block !== this._gutterBlockAxis && this._syncGutterHeights();
|
|
1565
1617
|
}
|
|
1566
1618
|
render() {
|
|
1567
|
-
return
|
|
1619
|
+
return Vt`
|
|
1568
1620
|
<div id="root" part="root">
|
|
1569
1621
|
<div id="gutter" part="gutter" aria-hidden="true">
|
|
1570
1622
|
<div id="gutter-cells" part="gutter-cells"></div>
|
|
@@ -1574,7 +1626,7 @@ const V = class V extends st {
|
|
|
1574
1626
|
<div
|
|
1575
1627
|
id="editor"
|
|
1576
1628
|
part="editor"
|
|
1577
|
-
contenteditable=${this.
|
|
1629
|
+
contenteditable=${this._readOnly ? "false" : "true"}
|
|
1578
1630
|
role="textbox"
|
|
1579
1631
|
aria-multiline="true"
|
|
1580
1632
|
spellcheck="false"
|
|
@@ -1591,8 +1643,8 @@ const V = class V extends st {
|
|
|
1591
1643
|
this._textareaController.sync();
|
|
1592
1644
|
}
|
|
1593
1645
|
_setupTextarea(t, e) {
|
|
1594
|
-
if (e && e !== t && e.removeEventListener("invalid", this._onTextareaInvalid), !t) {
|
|
1595
|
-
this._$textareaRef = null;
|
|
1646
|
+
if (e && e !== t && e.removeEventListener("invalid", this._onTextareaInvalid), this._textareaAttributeObserver?.disconnect(), !t) {
|
|
1647
|
+
this._$textareaRef = null, this._syncReadOnly(), this._syncContentAttributes(), this._scheduleRender();
|
|
1596
1648
|
return;
|
|
1597
1649
|
}
|
|
1598
1650
|
if (this._$textareaRef = new WeakRef(t), Object.assign(t.style, {
|
|
@@ -1612,14 +1664,14 @@ const V = class V extends st {
|
|
|
1612
1664
|
const s = t.getAttribute("placeholder");
|
|
1613
1665
|
s && this._$editor.setAttribute("aria-placeholder", s);
|
|
1614
1666
|
}
|
|
1615
|
-
this._initialValueResolved ? t.value = this._value : (this._value = t.value, this._initialValueResolved = !0), t.addEventListener("invalid", this._onTextareaInvalid), this._syncTypography(t), this._scheduleRender();
|
|
1667
|
+
this._initialValueResolved ? t.value = this._value : (this._value = t.value, this._initialValueResolved = !0), t.addEventListener("invalid", this._onTextareaInvalid), this._observeTextarea(t), this._syncReadOnly(), this._syncContentAttributes(), this._syncTypography(t), this._scheduleRender();
|
|
1616
1668
|
}
|
|
1617
1669
|
_bindEditorEvents(t) {
|
|
1618
1670
|
t.addEventListener("compositionstart", () => {
|
|
1619
1671
|
this._composing = !0;
|
|
1620
1672
|
}), t.addEventListener("compositionend", () => {
|
|
1621
|
-
this._composing = !1, this._onInput();
|
|
1622
|
-
}), t.addEventListener("beforeinput", this._onBeforeInput), t.addEventListener("input", this._onInputEvent), t.addEventListener("keydown", this._onKeyDown), t.addEventListener("paste", this._onPaste), t.addEventListener("focus", () => {
|
|
1673
|
+
this._composing = !1, this._onInput(), this._contentAttributesPendingRender && (this._contentAttributesPendingRender = !1, this._syncContentDirection(), this._scheduleRender());
|
|
1674
|
+
}), t.addEventListener("beforeinput", this._onBeforeInput), t.addEventListener("input", this._onInputEvent), t.addEventListener("keydown", this._onKeyDown), t.addEventListener("paste", this._onPaste), t.addEventListener("copy", this._onCopy), t.addEventListener("cut", this._onCopy), t.addEventListener("focus", () => {
|
|
1623
1675
|
this.dispatchEvent(
|
|
1624
1676
|
new CustomEvent("rc-textarea-focus", {
|
|
1625
1677
|
bubbles: !0,
|
|
@@ -1627,7 +1679,7 @@ const V = class V extends st {
|
|
|
1627
1679
|
})
|
|
1628
1680
|
);
|
|
1629
1681
|
}), t.addEventListener("blur", () => {
|
|
1630
|
-
this.dispatchEvent(
|
|
1682
|
+
this._tabMovesFocus = !1, this.dispatchEvent(
|
|
1631
1683
|
new CustomEvent("rc-textarea-blur", {
|
|
1632
1684
|
bubbles: !0,
|
|
1633
1685
|
composed: !0
|
|
@@ -1635,21 +1687,41 @@ const V = class V extends st {
|
|
|
1635
1687
|
), this._$activeLine?.classList.remove("line--active"), this._$activeLine = null;
|
|
1636
1688
|
});
|
|
1637
1689
|
}
|
|
1690
|
+
_revealFoldAtOffset(t) {
|
|
1691
|
+
for (const e of this._foldBounds)
|
|
1692
|
+
if (t >= e.from && t <= e.to)
|
|
1693
|
+
return e.reveal(), !0;
|
|
1694
|
+
return !1;
|
|
1695
|
+
}
|
|
1696
|
+
_revealFoldForEdit(t) {
|
|
1697
|
+
if (!this._$editor)
|
|
1698
|
+
return !1;
|
|
1699
|
+
const e = E(this._$editor) ?? this._savedSelection;
|
|
1700
|
+
if (!e)
|
|
1701
|
+
return !1;
|
|
1702
|
+
const s = Math.min(e.anchorOffset, e.focusOffset), i = Math.max(e.anchorOffset, e.focusOffset);
|
|
1703
|
+
for (const n of this._foldBounds) {
|
|
1704
|
+
const o = s < n.to && i > n.from, a = s === i && s >= n.from && s <= n.to, l = s === i && (t.endsWith("Forward") && s === n.anchorEnd || t.endsWith("Backward") && s === n.to + 1), c = s === i && s === n.anchorEnd && (t === "insertParagraph" || t === "insertLineBreak" || t === "insertFromPaste");
|
|
1705
|
+
if (o || a || l || c)
|
|
1706
|
+
return n.reveal(), !0;
|
|
1707
|
+
}
|
|
1708
|
+
return !1;
|
|
1709
|
+
}
|
|
1638
1710
|
_onInput() {
|
|
1639
1711
|
if (!this._$editor)
|
|
1640
1712
|
return;
|
|
1641
|
-
const t =
|
|
1713
|
+
const t = J(this._$editor);
|
|
1642
1714
|
if (t === this._value)
|
|
1643
1715
|
return;
|
|
1644
|
-
const e = this._value, s = this._savedSelection, i =
|
|
1716
|
+
const e = this._value, s = this._savedSelection, i = Q(
|
|
1645
1717
|
[...this._pluginDecorations.values()],
|
|
1646
1718
|
e,
|
|
1647
1719
|
t
|
|
1648
1720
|
);
|
|
1649
1721
|
this._pluginDecorations.clear();
|
|
1650
|
-
for (const
|
|
1651
|
-
this._pluginDecorations.set(
|
|
1652
|
-
this._value = t, this._syncTextareaValue(!0), this._savedSelection =
|
|
1722
|
+
for (const n of i)
|
|
1723
|
+
this._pluginDecorations.set(n.id, n);
|
|
1724
|
+
this._value = t, this._syncTextareaValue(!0), this._savedSelection = E(this._$editor), this._undoStack.length === 0 && (this._undoStack.push({
|
|
1653
1725
|
value: e,
|
|
1654
1726
|
anchorOffset: s?.anchorOffset ?? 0,
|
|
1655
1727
|
focusOffset: s?.focusOffset ?? 0
|
|
@@ -1658,19 +1730,15 @@ const V = class V extends st {
|
|
|
1658
1730
|
_updateActiveLine() {
|
|
1659
1731
|
if (!this._$editor)
|
|
1660
1732
|
return;
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
if (s instanceof HTMLElement && s.classList.contains("line")) {
|
|
1667
|
-
e = s;
|
|
1668
|
-
break;
|
|
1669
|
-
}
|
|
1670
|
-
s = s.parentNode;
|
|
1733
|
+
let t = null, e = ve(this._$editor);
|
|
1734
|
+
for (; e && e !== this._$editor; ) {
|
|
1735
|
+
if (e instanceof HTMLElement && e.classList.contains("line")) {
|
|
1736
|
+
t = e;
|
|
1737
|
+
break;
|
|
1671
1738
|
}
|
|
1739
|
+
e = e.parentNode;
|
|
1672
1740
|
}
|
|
1673
|
-
|
|
1741
|
+
t !== this._$activeLine && (this._$activeLine?.classList.remove("line--active"), this._$activeLine = t, this._$activeLine?.classList.add("line--active"), this._updateActiveGutterCell());
|
|
1674
1742
|
}
|
|
1675
1743
|
_updateActiveGutterCell() {
|
|
1676
1744
|
if (!this._$gutterCells)
|
|
@@ -1688,23 +1756,26 @@ const V = class V extends st {
|
|
|
1688
1756
|
}
|
|
1689
1757
|
}
|
|
1690
1758
|
}
|
|
1759
|
+
_isWidgetEvent(t) {
|
|
1760
|
+
return t.composedPath().some((e) => e instanceof HTMLElement && e.classList.contains("widget"));
|
|
1761
|
+
}
|
|
1691
1762
|
_insertText(t) {
|
|
1692
1763
|
if (this._$editor) {
|
|
1693
1764
|
if (t.includes(`
|
|
1694
|
-
`)) {
|
|
1695
|
-
const e =
|
|
1765
|
+
`) || t === "") {
|
|
1766
|
+
const e = E(this._$editor) ?? this._savedSelection, s = Math.min(e?.anchorOffset ?? 0, e?.focusOffset ?? 0), i = Math.max(e?.anchorOffset ?? 0, e?.focusOffset ?? 0), n = this._value, o = n.slice(0, s) + t + n.slice(i), a = s + t.length, l = Q(
|
|
1696
1767
|
[...this._pluginDecorations.values()],
|
|
1697
|
-
|
|
1768
|
+
n,
|
|
1698
1769
|
o
|
|
1699
1770
|
);
|
|
1700
1771
|
this._pluginDecorations.clear();
|
|
1701
|
-
for (const
|
|
1702
|
-
this._pluginDecorations.set(
|
|
1772
|
+
for (const c of l)
|
|
1773
|
+
this._pluginDecorations.set(c.id, c);
|
|
1703
1774
|
this._value = o, this._syncTextareaValue(!0), this._savedSelection = {
|
|
1704
1775
|
anchorOffset: a,
|
|
1705
1776
|
focusOffset: a
|
|
1706
1777
|
}, this._undoStack.length === 0 && (this._undoStack.push({
|
|
1707
|
-
value:
|
|
1778
|
+
value: n,
|
|
1708
1779
|
anchorOffset: e?.anchorOffset ?? 0,
|
|
1709
1780
|
focusOffset: e?.focusOffset ?? 0
|
|
1710
1781
|
}), this._undoIndex = 0), this._pushUndo(this._savedSelection), this._dispatchChange(o), this._scheduleRender();
|
|
@@ -1725,17 +1796,17 @@ const V = class V extends st {
|
|
|
1725
1796
|
wrapSelection(t, e) {
|
|
1726
1797
|
if (!this._$editor)
|
|
1727
1798
|
return;
|
|
1728
|
-
const s =
|
|
1799
|
+
const s = E(this._$editor) ?? this._savedSelection;
|
|
1729
1800
|
if (!s || s.anchorOffset === s.focusOffset)
|
|
1730
1801
|
return;
|
|
1731
|
-
const i = Math.min(s.anchorOffset, s.focusOffset),
|
|
1802
|
+
const i = Math.min(s.anchorOffset, s.focusOffset), n = Math.max(s.anchorOffset, s.focusOffset), o = this._value.slice(i, n), a = this._value, l = a.slice(0, i) + t + o + e + a.slice(n), c = Q(
|
|
1732
1803
|
[...this._pluginDecorations.values()],
|
|
1733
1804
|
a,
|
|
1734
1805
|
l
|
|
1735
1806
|
);
|
|
1736
1807
|
this._pluginDecorations.clear();
|
|
1737
|
-
for (const
|
|
1738
|
-
this._pluginDecorations.set(
|
|
1808
|
+
for (const h of c)
|
|
1809
|
+
this._pluginDecorations.set(h.id, h);
|
|
1739
1810
|
this._value = l, this._syncTextareaValue(!0), this._savedSelection = {
|
|
1740
1811
|
anchorOffset: i + t.length,
|
|
1741
1812
|
focusOffset: i + t.length + o.length
|
|
@@ -1758,13 +1829,15 @@ const V = class V extends st {
|
|
|
1758
1829
|
anchorOffset: t?.anchorOffset ?? 0,
|
|
1759
1830
|
focusOffset: t?.focusOffset ?? 0
|
|
1760
1831
|
};
|
|
1761
|
-
this._undoStack = this._undoStack.slice(0, this._undoIndex + 1), this._undoStack.push(e), this._undoStack.length >
|
|
1832
|
+
this._undoStack = this._undoStack.slice(0, this._undoIndex + 1), this._undoStack.push(e), this._undoStack.length > ke && this._undoStack.shift(), this._undoIndex = this._undoStack.length - 1;
|
|
1762
1833
|
}
|
|
1763
1834
|
_undo() {
|
|
1764
|
-
|
|
1835
|
+
const t = this._undoStack[this._undoIndex - 1];
|
|
1836
|
+
t && (this._undoIndex--, this._applyUndoEntry(t));
|
|
1765
1837
|
}
|
|
1766
1838
|
_redo() {
|
|
1767
|
-
|
|
1839
|
+
const t = this._undoStack[this._undoIndex + 1];
|
|
1840
|
+
t && (this._undoIndex++, this._applyUndoEntry(t));
|
|
1768
1841
|
}
|
|
1769
1842
|
_applyUndoEntry(t) {
|
|
1770
1843
|
this._value = t.value, this._savedSelection = {
|
|
@@ -1819,17 +1892,28 @@ const V = class V extends st {
|
|
|
1819
1892
|
return null;
|
|
1820
1893
|
}
|
|
1821
1894
|
},
|
|
1895
|
+
get contentDirection() {
|
|
1896
|
+
return t._contentDirection();
|
|
1897
|
+
},
|
|
1898
|
+
get contentLang() {
|
|
1899
|
+
return t._contentLang();
|
|
1900
|
+
},
|
|
1901
|
+
lineDirection(e) {
|
|
1902
|
+
const s = t._value.split(`
|
|
1903
|
+
`)[e - 1];
|
|
1904
|
+
return (t.lineDirection === "auto" && s !== void 0 ? yt(s) : null) ?? t._contentDirection();
|
|
1905
|
+
},
|
|
1822
1906
|
getWordAtCursor() {
|
|
1823
1907
|
const e = t._savedSelection?.focusOffset ?? 0, s = t._value;
|
|
1824
1908
|
if (!s)
|
|
1825
1909
|
return null;
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
return
|
|
1910
|
+
const i = s.lastIndexOf(`
|
|
1911
|
+
`, e - 1) + 1, n = s.indexOf(`
|
|
1912
|
+
`, e), o = s.slice(i, n === -1 ? void 0 : n), a = $e(o, e - i, t._contentLang());
|
|
1913
|
+
if (!a)
|
|
1914
|
+
return null;
|
|
1915
|
+
const l = i + a.from, c = i + a.to;
|
|
1916
|
+
return { word: s.slice(l, c), from: l, to: c };
|
|
1833
1917
|
},
|
|
1834
1918
|
onCursorMove(e) {
|
|
1835
1919
|
return t._cursorCallbacks.add(e), () => {
|
|
@@ -1837,7 +1921,7 @@ const V = class V extends st {
|
|
|
1837
1921
|
};
|
|
1838
1922
|
},
|
|
1839
1923
|
addDecoration(e) {
|
|
1840
|
-
return
|
|
1924
|
+
return bt(t._pluginDecorations, e);
|
|
1841
1925
|
},
|
|
1842
1926
|
removeDecoration(e) {
|
|
1843
1927
|
t._pluginDecorations.delete(e);
|
|
@@ -1846,7 +1930,7 @@ const V = class V extends st {
|
|
|
1846
1930
|
t._pluginDecorations.clear();
|
|
1847
1931
|
},
|
|
1848
1932
|
setDecorations(e) {
|
|
1849
|
-
|
|
1933
|
+
Ee(t._pluginDecorations, e);
|
|
1850
1934
|
},
|
|
1851
1935
|
getDecorations() {
|
|
1852
1936
|
return [...t._pluginDecorations.values()];
|
|
@@ -1867,16 +1951,16 @@ const V = class V extends st {
|
|
|
1867
1951
|
)), t._pluginSheets.delete(e);
|
|
1868
1952
|
},
|
|
1869
1953
|
parseDecorationsFromHtml(e) {
|
|
1870
|
-
return
|
|
1954
|
+
return xt(e);
|
|
1871
1955
|
},
|
|
1872
1956
|
decorationsFromTokens(e, s) {
|
|
1873
1957
|
const i = [];
|
|
1874
|
-
for (const
|
|
1875
|
-
const o = s[
|
|
1958
|
+
for (const n of e) {
|
|
1959
|
+
const o = s[n.type];
|
|
1876
1960
|
o && i.push({
|
|
1877
1961
|
type: "mark",
|
|
1878
|
-
from:
|
|
1879
|
-
to:
|
|
1962
|
+
from: n.from,
|
|
1963
|
+
to: n.to,
|
|
1880
1964
|
...o
|
|
1881
1965
|
});
|
|
1882
1966
|
}
|
|
@@ -1911,7 +1995,7 @@ const V = class V extends st {
|
|
|
1911
1995
|
* editor.removePattern(id);
|
|
1912
1996
|
*/
|
|
1913
1997
|
addPattern(t) {
|
|
1914
|
-
const e =
|
|
1998
|
+
const e = U();
|
|
1915
1999
|
return this._patterns.set(e, { ...t, id: e }), this._scheduleRender(), e;
|
|
1916
2000
|
}
|
|
1917
2001
|
/** Remove a previously registered pattern by the ID returned from `addPattern`. */
|
|
@@ -1935,39 +2019,59 @@ const V = class V extends st {
|
|
|
1935
2019
|
try {
|
|
1936
2020
|
let e = this._value;
|
|
1937
2021
|
if (this._plugin && this._pluginApi && this._plugin.transform && this.readOnly) {
|
|
1938
|
-
const
|
|
1939
|
-
typeof
|
|
2022
|
+
const l = this._plugin.transform(this._value, this._pluginApi);
|
|
2023
|
+
typeof l == "string" && (e = l);
|
|
1940
2024
|
}
|
|
1941
|
-
const { markDecorations: s, lineDecorations: i } =
|
|
2025
|
+
const { markDecorations: s, lineDecorations: i } = Ce(
|
|
1942
2026
|
e,
|
|
1943
2027
|
[...this._patterns.values()]
|
|
1944
2028
|
);
|
|
1945
2029
|
if (this._patternDecorations = [
|
|
1946
|
-
...s.map((
|
|
1947
|
-
...i.map((
|
|
2030
|
+
...s.map((l) => ({ ...l, id: U() })),
|
|
2031
|
+
...i.map((l) => ({ ...l, id: U() }))
|
|
1948
2032
|
], this._plugin && this._pluginApi) {
|
|
1949
|
-
const
|
|
1950
|
-
if (this._plugin.update && (await this._plugin.update(e,
|
|
2033
|
+
const l = this._pluginApi;
|
|
2034
|
+
if (this._plugin.update && (await this._plugin.update(e, l), t !== this._pluginSeq))
|
|
1951
2035
|
return;
|
|
1952
2036
|
if (this._plugin.highlight) {
|
|
1953
|
-
const
|
|
2037
|
+
const c = await this._plugin.highlight(e, l);
|
|
1954
2038
|
if (t !== this._pluginSeq)
|
|
1955
2039
|
return;
|
|
1956
|
-
if (typeof
|
|
1957
|
-
const
|
|
1958
|
-
for (const
|
|
1959
|
-
|
|
2040
|
+
if (typeof c == "string") {
|
|
2041
|
+
const h = xt(c);
|
|
2042
|
+
for (const u of h)
|
|
2043
|
+
bt(this._pluginDecorations, u);
|
|
1960
2044
|
}
|
|
1961
2045
|
}
|
|
1962
2046
|
}
|
|
1963
|
-
const
|
|
2047
|
+
const n = [
|
|
1964
2048
|
...this._pluginDecorations.values(),
|
|
1965
2049
|
...this._patternDecorations,
|
|
1966
|
-
...this._externalDecorations.map((
|
|
2050
|
+
...this._externalDecorations.map((l) => ({ ...l, id: U() }))
|
|
1967
2051
|
];
|
|
1968
|
-
if (
|
|
2052
|
+
if (this._foldedRanges = n.filter(
|
|
2053
|
+
(l) => l.type === "fold"
|
|
2054
|
+
), this._foldBounds = Se(e, this._foldedRanges), this._hiddenGutterLines = new Set(
|
|
2055
|
+
this._foldedRanges.flatMap(
|
|
2056
|
+
(l) => Array.from(
|
|
2057
|
+
{ length: Math.max(0, l.toLine - l.fromLine + 1) },
|
|
2058
|
+
(c, h) => l.fromLine + h
|
|
2059
|
+
)
|
|
2060
|
+
)
|
|
2061
|
+
), !this._$editor)
|
|
1969
2062
|
return;
|
|
1970
|
-
|
|
2063
|
+
const o = this.shadowRoot?.activeElement;
|
|
2064
|
+
let a = J(this._$editor) === e ? E(this._$editor) ?? this._savedSelection : this._savedSelection;
|
|
2065
|
+
if (a?.anchorOffset === a?.focusOffset) {
|
|
2066
|
+
const l = a?.focusOffset, c = this._foldBounds.filter(
|
|
2067
|
+
(h) => l !== void 0 && l >= h.from && l <= h.to
|
|
2068
|
+
);
|
|
2069
|
+
if (c.length > 0) {
|
|
2070
|
+
const h = Math.min(...c.map((u) => u.anchorEnd));
|
|
2071
|
+
a = { anchorOffset: h, focusOffset: h }, this._savedSelection = a;
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
this._syncContentDirection(), this._document.build(e, n), this._syncLineDirections(e), o instanceof HTMLElement && o !== this._$editor && o.isConnected && this.shadowRoot?.activeElement !== o && o.focus({ preventScroll: !0 }), a && this.shadowRoot?.activeElement === this._$editor && ye(this._$editor, a), this._$activeLine = null, this._updateActiveLine(), this._syncGutter(this._computeGutterLabels(n, e)), this._syncGutterHeights();
|
|
1971
2075
|
} finally {
|
|
1972
2076
|
this._isRendering = !1;
|
|
1973
2077
|
}
|
|
@@ -1983,43 +2087,52 @@ const V = class V extends st {
|
|
|
1983
2087
|
*/
|
|
1984
2088
|
_computeGutterLabels(t, e = this._value) {
|
|
1985
2089
|
const s = e.split(`
|
|
1986
|
-
`), i = /* @__PURE__ */ new Map();
|
|
1987
|
-
for (const
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
2090
|
+
`), i = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
|
|
2091
|
+
for (const l of t)
|
|
2092
|
+
l.type === "line" && l.gutterContent !== void 0 && (i.set(l.line, l.gutterContent), l.gutterAccessible ? n.add(l.line) : n.delete(l.line), l.gutterLineNumber ? o.add(l.line) : o.delete(l.line));
|
|
2093
|
+
this._accessibleGutterLines = n;
|
|
2094
|
+
const a = Gt(this._localeController.locale, { useGrouping: !1 });
|
|
2095
|
+
return s.map((l, c) => {
|
|
2096
|
+
const h = c + 1, u = i.get(h);
|
|
2097
|
+
return u !== void 0 ? this.lineNumbers && o.has(h) && u !== null ? { number: a.format(h), content: u } : u : this.lineNumbers ? a.format(h) : null;
|
|
1992
2098
|
});
|
|
1993
2099
|
}
|
|
1994
2100
|
/**
|
|
1995
|
-
* Synchronize the
|
|
2101
|
+
* Synchronize the block size of each gutter cell to match the
|
|
1996
2102
|
* corresponding `.line` element in the editor.
|
|
1997
2103
|
*
|
|
1998
|
-
* In non-word-wrap mode the gutter uses a uniform
|
|
1999
|
-
*
|
|
2000
|
-
*
|
|
2001
|
-
* Also copies the editor's computed `paddingTop`/`paddingBottom` to the
|
|
2104
|
+
* In non-word-wrap mode without block widgets the gutter uses a uniform
|
|
2105
|
+
* line height. Wrapped lines and block widgets use per-line heights instead.
|
|
2106
|
+
* Also copies the editor's computed block padding to the
|
|
2002
2107
|
* gutter to compensate for browser UA overrides on contenteditable.
|
|
2003
2108
|
*/
|
|
2004
2109
|
_syncGutterHeights() {
|
|
2005
2110
|
if (!this._$gutterCells || !this._$editor)
|
|
2006
2111
|
return;
|
|
2007
|
-
const t = getComputedStyle(this._$editor), e = t.
|
|
2008
|
-
this._$gutterCells.style.
|
|
2009
|
-
const i = this._$editor.querySelectorAll(".line"),
|
|
2010
|
-
if (!this.wordWrap) {
|
|
2112
|
+
const t = getComputedStyle(this._$editor), e = t.paddingBlockStart, s = t.paddingBlockEnd;
|
|
2113
|
+
this._$gutterCells.style.paddingBlockStart !== e && (this._$gutterCells.style.paddingBlockStart = e), this._$gutterCells.style.paddingBlockEnd !== s && (this._$gutterCells.style.paddingBlockEnd = s);
|
|
2114
|
+
const i = this._$editor.querySelectorAll(".line"), n = this._$gutterCells.children, o = V(this._$editor), a = this._$editor.getBoundingClientRect(), l = jt(this._$gutterCells);
|
|
2115
|
+
if (this._gutterBlockAxis = o.block, !this.wordWrap && !this._$editor.querySelector(".widget--block")) {
|
|
2011
2116
|
if (i.length > 0) {
|
|
2012
|
-
const
|
|
2013
|
-
|
|
2117
|
+
const h = `${ht(
|
|
2118
|
+
i[0].getBoundingClientRect(),
|
|
2119
|
+
a,
|
|
2120
|
+
o
|
|
2121
|
+
).blockSize / l}px`;
|
|
2122
|
+
this._$gutterCells.style.lineHeight !== h && (this._$gutterCells.style.lineHeight = h);
|
|
2014
2123
|
}
|
|
2015
|
-
for (let
|
|
2016
|
-
|
|
2124
|
+
for (let c = 0; c < n.length; c++)
|
|
2125
|
+
n[c].style.blockSize = "";
|
|
2017
2126
|
return;
|
|
2018
2127
|
}
|
|
2019
2128
|
this._$gutterCells.style.lineHeight && (this._$gutterCells.style.lineHeight = "");
|
|
2020
|
-
for (let
|
|
2021
|
-
const
|
|
2022
|
-
|
|
2129
|
+
for (let c = 0; c < i.length && c < n.length; c++) {
|
|
2130
|
+
const u = `${ht(
|
|
2131
|
+
i.item(c).getBoundingClientRect(),
|
|
2132
|
+
a,
|
|
2133
|
+
o
|
|
2134
|
+
).blockSize / l}px`, d = n[c];
|
|
2135
|
+
d.style.blockSize !== u && (d.style.blockSize = u);
|
|
2023
2136
|
}
|
|
2024
2137
|
}
|
|
2025
2138
|
/**
|
|
@@ -2032,16 +2145,29 @@ const V = class V extends st {
|
|
|
2032
2145
|
if (!this.lineNumbers && !this.gutter || !this._$gutterCells)
|
|
2033
2146
|
return;
|
|
2034
2147
|
t !== void 0 && (this._gutterLabels = t);
|
|
2035
|
-
const e = this._gutterLabels;
|
|
2036
|
-
for (; this._$gutterCells.children.length < e.length; ) {
|
|
2037
|
-
const
|
|
2038
|
-
|
|
2148
|
+
const e = this._gutterLabels, s = this._$gutterCells.parentElement;
|
|
2149
|
+
for (this._accessibleGutterLines.size > 0 ? s?.removeAttribute("aria-hidden") : s?.setAttribute("aria-hidden", "true"); this._$gutterCells.children.length < e.length; ) {
|
|
2150
|
+
const i = document.createElement("span");
|
|
2151
|
+
i.className = "gutter-cell", this._$gutterCells.appendChild(i);
|
|
2039
2152
|
}
|
|
2040
2153
|
for (; this._$gutterCells.children.length > e.length; )
|
|
2041
|
-
this._$gutterCells.
|
|
2042
|
-
for (let
|
|
2043
|
-
const
|
|
2044
|
-
|
|
2154
|
+
this._$gutterCells.lastChild?.remove();
|
|
2155
|
+
for (let i = 0; i < e.length; i++) {
|
|
2156
|
+
const n = e[i] ?? "", o = this._$gutterCells.children[i];
|
|
2157
|
+
if (o.setAttribute("aria-hidden", String(!this._accessibleGutterLines.has(i + 1))), o.hidden = this._hiddenGutterLines.has(i + 1), typeof n == "object" && n !== null && !(n instanceof HTMLElement)) {
|
|
2158
|
+
let a = o.firstElementChild;
|
|
2159
|
+
if (!a?.classList.contains("gutter-cell-composite")) {
|
|
2160
|
+
a = document.createElement("span"), a.className = "gutter-cell-composite";
|
|
2161
|
+
const h = document.createElement("span");
|
|
2162
|
+
h.className = "gutter-cell-number";
|
|
2163
|
+
const u = document.createElement("span");
|
|
2164
|
+
u.className = "gutter-cell-content", a.append(h, u), o.replaceChildren(a);
|
|
2165
|
+
}
|
|
2166
|
+
const l = a.querySelector(":scope > .gutter-cell-number"), c = a.querySelector(":scope > .gutter-cell-content");
|
|
2167
|
+
if (!l || !c)
|
|
2168
|
+
continue;
|
|
2169
|
+
l.textContent !== n.number && (l.textContent = n.number), n.content instanceof HTMLElement ? c.firstChild !== n.content && c.replaceChildren(n.content) : (c.textContent !== n.content || c.firstElementChild) && (c.textContent = n.content);
|
|
2170
|
+
} else n instanceof HTMLElement ? o.firstChild !== n && o.replaceChildren(n) : (o.textContent !== n || o.firstElementChild) && (o.textContent = n);
|
|
2045
2171
|
}
|
|
2046
2172
|
}
|
|
2047
2173
|
_syncLabel() {
|
|
@@ -2077,9 +2203,9 @@ const V = class V extends st {
|
|
|
2077
2203
|
"tabSize"
|
|
2078
2204
|
];
|
|
2079
2205
|
if (!window.getComputedStyle(this).getPropertyValue("--rc-textarea-font-family"))
|
|
2080
|
-
for (const
|
|
2081
|
-
const o = e[
|
|
2082
|
-
o && typeof o == "string" && (this._$editor.style[
|
|
2206
|
+
for (const n of s) {
|
|
2207
|
+
const o = e[n];
|
|
2208
|
+
o && typeof o == "string" && (this._$editor.style[n] = o);
|
|
2083
2209
|
}
|
|
2084
2210
|
}
|
|
2085
2211
|
_syncTextareaValue(t = !1) {
|
|
@@ -2096,86 +2222,87 @@ const V = class V extends st {
|
|
|
2096
2222
|
);
|
|
2097
2223
|
}
|
|
2098
2224
|
};
|
|
2099
|
-
|
|
2100
|
-
...
|
|
2225
|
+
j.styles = Ae, j.shadowRootOptions = {
|
|
2226
|
+
...ct.shadowRootOptions,
|
|
2101
2227
|
delegatesFocus: !0
|
|
2102
2228
|
};
|
|
2103
|
-
let
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
],
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
],
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
],
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
],
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
],
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
],
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
],
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
],
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
],
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
],
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
],
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
],
|
|
2140
|
-
function
|
|
2229
|
+
let b = j;
|
|
2230
|
+
v([
|
|
2231
|
+
N({ type: Boolean, attribute: "line-numbers", reflect: !0 })
|
|
2232
|
+
], b.prototype, "lineNumbers", 2);
|
|
2233
|
+
v([
|
|
2234
|
+
N({ type: Boolean, attribute: "gutter", reflect: !0 })
|
|
2235
|
+
], b.prototype, "gutter", 2);
|
|
2236
|
+
v([
|
|
2237
|
+
N({ type: Boolean, attribute: "word-wrap", reflect: !0 })
|
|
2238
|
+
], b.prototype, "wordWrap", 2);
|
|
2239
|
+
v([
|
|
2240
|
+
N({ type: Boolean, attribute: "auto-grow", reflect: !0 })
|
|
2241
|
+
], b.prototype, "autoGrow", 2);
|
|
2242
|
+
v([
|
|
2243
|
+
N({ attribute: "line-direction", reflect: !0 })
|
|
2244
|
+
], b.prototype, "lineDirection", 2);
|
|
2245
|
+
v([
|
|
2246
|
+
N({ attribute: !1 })
|
|
2247
|
+
], b.prototype, "plugin", 1);
|
|
2248
|
+
v([
|
|
2249
|
+
N({ attribute: !1 })
|
|
2250
|
+
], b.prototype, "decorations", 1);
|
|
2251
|
+
v([
|
|
2252
|
+
rt("#editor")
|
|
2253
|
+
], b.prototype, "_$editor", 2);
|
|
2254
|
+
v([
|
|
2255
|
+
rt("#gutter-cells")
|
|
2256
|
+
], b.prototype, "_$gutterCells", 2);
|
|
2257
|
+
v([
|
|
2258
|
+
rt("slot")
|
|
2259
|
+
], b.prototype, "_$slot", 2);
|
|
2260
|
+
v([
|
|
2261
|
+
N({ type: String })
|
|
2262
|
+
], b.prototype, "value", 1);
|
|
2263
|
+
v([
|
|
2264
|
+
N({ type: String, attribute: "default-value" })
|
|
2265
|
+
], b.prototype, "defaultValue", 1);
|
|
2266
|
+
function Ke(r, t = {}) {
|
|
2141
2267
|
const e = [];
|
|
2142
2268
|
return {
|
|
2143
2269
|
mount(s) {
|
|
2144
|
-
|
|
2270
|
+
r.styles && s.adoptStyleSheet(r.styles);
|
|
2145
2271
|
for (const i of t.watch ?? []) {
|
|
2146
|
-
const
|
|
2147
|
-
|
|
2272
|
+
const n = i(() => s.scheduleUpdate());
|
|
2273
|
+
n && e.push(n);
|
|
2148
2274
|
}
|
|
2149
2275
|
},
|
|
2150
2276
|
destroy() {
|
|
2151
|
-
for (const s of e)
|
|
2277
|
+
for (const s of e)
|
|
2278
|
+
s();
|
|
2152
2279
|
e.length = 0;
|
|
2153
2280
|
},
|
|
2154
2281
|
update(s, i) {
|
|
2155
|
-
const
|
|
2282
|
+
const n = s.split(`
|
|
2156
2283
|
`), o = [];
|
|
2157
2284
|
let a = 0;
|
|
2158
|
-
for (let l = 0; l <
|
|
2159
|
-
const
|
|
2160
|
-
for (const
|
|
2161
|
-
|
|
2162
|
-
...
|
|
2163
|
-
from: a +
|
|
2164
|
-
to: a +
|
|
2165
|
-
}) : o.push(
|
|
2166
|
-
a +=
|
|
2285
|
+
for (let l = 0; l < n.length; l++) {
|
|
2286
|
+
const c = n[l];
|
|
2287
|
+
for (const h of r.decorateLine(c, l))
|
|
2288
|
+
h.type === "mark" ? o.push({
|
|
2289
|
+
...h,
|
|
2290
|
+
from: a + h.from,
|
|
2291
|
+
to: a + h.to
|
|
2292
|
+
}) : o.push(h);
|
|
2293
|
+
a += c.length + 1;
|
|
2167
2294
|
}
|
|
2168
2295
|
t.extraDecorations && o.push(...t.extraDecorations(s)), i.setDecorations(o);
|
|
2169
2296
|
}
|
|
2170
2297
|
};
|
|
2171
2298
|
}
|
|
2172
|
-
const
|
|
2173
|
-
|
|
2299
|
+
const zt = new CSSStyleSheet();
|
|
2300
|
+
zt.replaceSync(`
|
|
2174
2301
|
.rc-line-actions {
|
|
2175
2302
|
display: inline-flex;
|
|
2176
2303
|
align-items: center;
|
|
2177
2304
|
gap: var(--rc-line-actions-gap, 2px);
|
|
2178
|
-
margin-
|
|
2305
|
+
margin-inline-start: var(--rc-line-actions-margin-start, 6px);
|
|
2179
2306
|
vertical-align: middle;
|
|
2180
2307
|
}
|
|
2181
2308
|
.rc-line-action-btn {
|
|
@@ -2200,7 +2327,7 @@ Et.replaceSync(`
|
|
|
2200
2327
|
color: var(--rc-line-action-hover-color, inherit);
|
|
2201
2328
|
}
|
|
2202
2329
|
`);
|
|
2203
|
-
const
|
|
2330
|
+
const wt = "rc-line-actions-popover-style", Ie = `
|
|
2204
2331
|
.rc-line-actions-popover {
|
|
2205
2332
|
position: fixed;
|
|
2206
2333
|
z-index: 9999;
|
|
@@ -2236,9 +2363,9 @@ const ht = "rc-line-actions-popover-style", fe = `
|
|
|
2236
2363
|
background: var(--rc-line-action-hover-bg, ButtonFace);
|
|
2237
2364
|
}
|
|
2238
2365
|
`;
|
|
2239
|
-
class
|
|
2366
|
+
class Ft {
|
|
2240
2367
|
constructor(t, e) {
|
|
2241
|
-
this._popover = null, this._lastActionsKey = "", this._api = t, this._options = e ?? {}, t.adoptStyleSheet(
|
|
2368
|
+
this._popover = null, this._lastActionsKey = "", this._api = t, this._options = e ?? {}, t.adoptStyleSheet(zt), this._blurHandler = () => this._hidePopover(), t.host.addEventListener("rc-textarea-blur", this._blurHandler);
|
|
2242
2369
|
}
|
|
2243
2370
|
/**
|
|
2244
2371
|
* Call from plugin's `update()`. Pass the line index, its actions, the full
|
|
@@ -2254,17 +2381,17 @@ class Ct {
|
|
|
2254
2381
|
return e.length === 0 ? this._hidePopover() : this._showPopover(e), [];
|
|
2255
2382
|
if (this._hidePopover(), e.length === 0)
|
|
2256
2383
|
return [];
|
|
2257
|
-
const
|
|
2384
|
+
const n = Ft._lineEndOffset(s, t), o = [...e], a = {
|
|
2258
2385
|
renderButton: this._options.renderButton,
|
|
2259
2386
|
createIcon: this._options.createIcon
|
|
2260
2387
|
};
|
|
2261
2388
|
return [
|
|
2262
2389
|
{
|
|
2263
2390
|
type: "widget",
|
|
2264
|
-
offset:
|
|
2391
|
+
offset: n,
|
|
2265
2392
|
side: "after",
|
|
2266
2393
|
create() {
|
|
2267
|
-
return
|
|
2394
|
+
return Pe(o, a);
|
|
2268
2395
|
}
|
|
2269
2396
|
}
|
|
2270
2397
|
];
|
|
@@ -2283,10 +2410,10 @@ class Ct {
|
|
|
2283
2410
|
return this.getDecorations(i, o, e, "popover");
|
|
2284
2411
|
}
|
|
2285
2412
|
this._hidePopover();
|
|
2286
|
-
const
|
|
2413
|
+
const n = [];
|
|
2287
2414
|
for (const [o, a] of t)
|
|
2288
|
-
a.length > 0 &&
|
|
2289
|
-
return
|
|
2415
|
+
a.length > 0 && n.push(...this.getDecorations(o, a, e, "inline"));
|
|
2416
|
+
return n;
|
|
2290
2417
|
}
|
|
2291
2418
|
/** Remove the floating panel and detach all listeners. Call from plugin `destroy()`. */
|
|
2292
2419
|
destroy() {
|
|
@@ -2305,17 +2432,17 @@ class Ct {
|
|
|
2305
2432
|
const s = t.split(`
|
|
2306
2433
|
`);
|
|
2307
2434
|
let i = 0;
|
|
2308
|
-
for (
|
|
2309
|
-
i +=
|
|
2310
|
-
return
|
|
2435
|
+
for (const n of s.slice(0, e))
|
|
2436
|
+
i += n.length + 1;
|
|
2437
|
+
return i + (s[e]?.length ?? 0);
|
|
2311
2438
|
}
|
|
2312
2439
|
_showPopover(t) {
|
|
2313
2440
|
const e = t.map((s) => s.id).join(",");
|
|
2314
|
-
if (!document.getElementById(
|
|
2441
|
+
if (!document.getElementById(wt)) {
|
|
2315
2442
|
const s = document.createElement("style");
|
|
2316
|
-
s.id =
|
|
2443
|
+
s.id = wt, s.textContent = Ie, document.head.appendChild(s);
|
|
2317
2444
|
}
|
|
2318
|
-
this._popover || (this._popover = document.createElement("div"), this._popover.className = "rc-line-actions-popover", this._popover.addEventListener("mousedown", (s) => s.preventDefault()), document.body.appendChild(this._popover)), e !== this._lastActionsKey && (this._lastActionsKey = e, this._popover.innerHTML = "",
|
|
2445
|
+
this._popover || (this._popover = document.createElement("div"), this._popover.className = "rc-line-actions-popover", this._popover.addEventListener("mousedown", (s) => s.preventDefault()), document.body.appendChild(this._popover)), e !== this._lastActionsKey && (this._lastActionsKey = e, this._popover.innerHTML = "", Me(this._popover, t, this._options)), this._positionPopover();
|
|
2319
2446
|
}
|
|
2320
2447
|
_positionPopover() {
|
|
2321
2448
|
if (!this._popover)
|
|
@@ -2323,40 +2450,40 @@ class Ct {
|
|
|
2323
2450
|
const t = this._api.getCursorRect(), e = this._api.host.getBoundingClientRect(), s = this._popover.offsetHeight || 32;
|
|
2324
2451
|
let i;
|
|
2325
2452
|
t ? (i = t.bottom + 4, i + s > window.innerHeight && (i = t.top - s - 4)) : i = e.bottom + 4;
|
|
2326
|
-
const
|
|
2327
|
-
let
|
|
2328
|
-
|
|
2453
|
+
const n = this._popover.offsetWidth || 120;
|
|
2454
|
+
let a = Xt("x", V(this._api.host)) ? e.right - n : e.left;
|
|
2455
|
+
a = Math.min(a, window.innerWidth - n - 8), a = Math.max(a, 8), this._popover.style.top = `${i}px`, this._popover.style.left = `${a}px`;
|
|
2329
2456
|
}
|
|
2330
2457
|
_hidePopover() {
|
|
2331
2458
|
this._popover && (this._popover.remove(), this._popover = null, this._lastActionsKey = "");
|
|
2332
2459
|
}
|
|
2333
2460
|
}
|
|
2334
|
-
function
|
|
2461
|
+
function Ht(r, t) {
|
|
2335
2462
|
const e = document.createElement("button");
|
|
2336
|
-
if (e.className = "rc-line-action-btn", e.type = "button", e.setAttribute("title",
|
|
2337
|
-
t.renderButton(
|
|
2338
|
-
else if (
|
|
2339
|
-
const s = t.createIcon?.(
|
|
2340
|
-
s ? (e.setAttribute("aria-label",
|
|
2463
|
+
if (e.className = "rc-line-action-btn", e.type = "button", e.setAttribute("title", r.label), t.renderButton)
|
|
2464
|
+
t.renderButton(r, e);
|
|
2465
|
+
else if (r.iconName) {
|
|
2466
|
+
const s = t.createIcon?.(r.iconName) ?? null;
|
|
2467
|
+
s ? (e.setAttribute("aria-label", r.label), e.appendChild(s)) : (e.dataset.icon = r.iconName, e.setAttribute("aria-label", r.label));
|
|
2341
2468
|
} else
|
|
2342
|
-
e.textContent =
|
|
2343
|
-
return e.addEventListener("mousedown", (s) => s.preventDefault()), e.addEventListener("click", () =>
|
|
2469
|
+
e.textContent = r.label;
|
|
2470
|
+
return e.addEventListener("mousedown", (s) => s.preventDefault()), e.addEventListener("click", () => r.onClick()), e;
|
|
2344
2471
|
}
|
|
2345
|
-
function
|
|
2472
|
+
function Pe(r, t) {
|
|
2346
2473
|
const e = document.createElement("span");
|
|
2347
2474
|
e.className = "rc-line-actions";
|
|
2348
|
-
for (const s of
|
|
2349
|
-
e.appendChild(
|
|
2475
|
+
for (const s of r)
|
|
2476
|
+
e.appendChild(Ht(s, t));
|
|
2350
2477
|
return e;
|
|
2351
2478
|
}
|
|
2352
|
-
function
|
|
2479
|
+
function Me(r, t, e) {
|
|
2353
2480
|
for (const s of t)
|
|
2354
|
-
|
|
2481
|
+
r.appendChild(Ht(s, e));
|
|
2355
2482
|
}
|
|
2356
2483
|
export {
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2484
|
+
Ft as L,
|
|
2485
|
+
b as R,
|
|
2486
|
+
Ke as c,
|
|
2487
|
+
Ce as m
|
|
2361
2488
|
};
|
|
2362
|
-
//# sourceMappingURL=line-actions-controller-
|
|
2489
|
+
//# sourceMappingURL=line-actions-controller-DUdXQxMA.js.map
|