@rcarls/rc-textarea 0.4.2 → 0.6.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 +28 -0
- package/README.md +2 -3
- package/dist/custom-elements.json +26 -78
- package/dist/{line-actions-controller-TP6g5HYk.js → line-actions-controller-BcsnmSPS.js} +118 -149
- package/dist/line-actions-controller-BcsnmSPS.js.map +1 -0
- package/dist/rc-textarea-define.js +2 -2
- 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 +2 -2
- package/dist/types/packages/rc-textarea/src/document.d.ts +1 -1
- package/dist/types/packages/rc-textarea/src/index.d.ts +7 -7
- package/dist/types/packages/rc-textarea/src/line-actions-controller.d.ts +1 -1
- 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 +6 -25
- package/dist/types/packages/rc-textarea/src/types.d.ts +0 -4
- package/package.json +2 -2
- package/dist/line-actions-controller-TP6g5HYk.js.map +0 -1
- package/dist/types/packages/rc-textarea/src/decoration.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.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,5 +1,5 @@
|
|
|
1
|
-
import { css as Lt, LitElement as
|
|
2
|
-
import { property as
|
|
1
|
+
import { css as Lt, LitElement as st, html as Tt } from "lit";
|
|
2
|
+
import { property as b, query as tt } from "lit/decorators.js";
|
|
3
3
|
import { NativeChildController as kt } from "@rcarls/rc-common";
|
|
4
4
|
var d = /* @__PURE__ */ ((n) => (n[n.TYPE = 3] = "TYPE", n[n.LEVEL = 12] = "LEVEL", n[n.ATTRIBUTE = 13] = "ATTRIBUTE", n[n.BLOT = 14] = "BLOT", n[n.INLINE = 7] = "INLINE", n[n.BLOCK = 11] = "BLOCK", n[n.BLOCK_BLOT = 10] = "BLOCK_BLOT", n[n.INLINE_BLOT = 6] = "INLINE_BLOT", n[n.BLOCK_ATTRIBUTE = 9] = "BLOCK_ATTRIBUTE", n[n.INLINE_ATTRIBUTE = 5] = "INLINE_ATTRIBUTE", n[n.ANY = 15] = "ANY", n))(d || {});
|
|
5
5
|
class T {
|
|
@@ -33,7 +33,7 @@ class O extends Error {
|
|
|
33
33
|
t = "[Parchment] " + t, super(t), this.message = t, this.name = this.constructor.name;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const ut = class
|
|
36
|
+
const ut = class X {
|
|
37
37
|
constructor() {
|
|
38
38
|
this.attributes = {}, this.classes = {}, this.tags = {}, this.types = {};
|
|
39
39
|
}
|
|
@@ -61,10 +61,10 @@ const ut = class Y {
|
|
|
61
61
|
// @ts-expect-error Fix me later
|
|
62
62
|
e instanceof Node || e.nodeType === Node.TEXT_NODE ? e : r.create(s)
|
|
63
63
|
), a = new r(t, o, s);
|
|
64
|
-
return
|
|
64
|
+
return X.blots.set(a.domNode, a), a;
|
|
65
65
|
}
|
|
66
66
|
find(t, e = !1) {
|
|
67
|
-
return
|
|
67
|
+
return X.find(t, e);
|
|
68
68
|
}
|
|
69
69
|
query(t, e = d.ANY) {
|
|
70
70
|
let s;
|
|
@@ -86,7 +86,7 @@ const ut = class Y {
|
|
|
86
86
|
};
|
|
87
87
|
ut.blots = /* @__PURE__ */ new WeakMap();
|
|
88
88
|
let z = ut;
|
|
89
|
-
function
|
|
89
|
+
function it(n, t) {
|
|
90
90
|
return (n.getAttribute("class") || "").split(/\s+/).filter((e) => e.indexOf(`${t}-`) === 0);
|
|
91
91
|
}
|
|
92
92
|
class Bt extends T {
|
|
@@ -97,17 +97,17 @@ 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
|
+
it(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 = (it(t, this.keyName)[0] || "").slice(this.keyName.length + 1);
|
|
106
106
|
return this.canAdd(t, e) ? e : "";
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
const Dt = Bt;
|
|
110
|
-
function
|
|
110
|
+
function F(n) {
|
|
111
111
|
const t = n.split("-"), e = t.slice(1).map((s) => s[0].toUpperCase() + s.slice(1)).join("");
|
|
112
112
|
return t[0] + e;
|
|
113
113
|
}
|
|
@@ -116,13 +116,13 @@ class It extends 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[F(this.keyName)] = e, !0) : !1;
|
|
120
120
|
}
|
|
121
121
|
remove(t) {
|
|
122
|
-
t.style[
|
|
122
|
+
t.style[F(this.keyName)] = "", t.getAttribute("style") || t.removeAttribute("style");
|
|
123
123
|
}
|
|
124
124
|
value(t) {
|
|
125
|
-
const e = t.style[
|
|
125
|
+
const e = t.style[F(this.keyName)];
|
|
126
126
|
return this.canAdd(t, e) ? e : "";
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -378,7 +378,7 @@ class Mt {
|
|
|
378
378
|
return e;
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
|
-
function
|
|
381
|
+
function rt(n, t) {
|
|
382
382
|
const e = t.find(n);
|
|
383
383
|
if (e)
|
|
384
384
|
return e;
|
|
@@ -412,7 +412,7 @@ const gt = class N extends pt {
|
|
|
412
412
|
build() {
|
|
413
413
|
this.children = new Mt(), Array.from(this.domNode.childNodes).filter((t) => t !== this.uiNode).reverse().forEach((t) => {
|
|
414
414
|
try {
|
|
415
|
-
const e =
|
|
415
|
+
const e = rt(t, this.scroll);
|
|
416
416
|
this.insertBefore(e, this.children.head || void 0);
|
|
417
417
|
} catch (e) {
|
|
418
418
|
if (e instanceof O)
|
|
@@ -538,7 +538,7 @@ const gt = class N extends pt {
|
|
|
538
538
|
}), s.filter((r) => r.parentNode === this.domNode && r !== this.uiNode).sort((r, o) => r === o ? 0 : r.compareDocumentPosition(o) & Node.DOCUMENT_POSITION_FOLLOWING ? 1 : -1).forEach((r) => {
|
|
539
539
|
let o = null;
|
|
540
540
|
r.nextSibling != null && (o = this.scroll.find(r.nextSibling));
|
|
541
|
-
const a =
|
|
541
|
+
const a = rt(r, 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
|
}
|
|
@@ -613,12 +613,12 @@ const E = class C extends L {
|
|
|
613
613
|
};
|
|
614
614
|
E.allowedChildren = [E, q], E.blotName = "inline", E.scope = d.INLINE_BLOT, E.tagName = "SPAN";
|
|
615
615
|
let Ht = E;
|
|
616
|
-
const _t = Ht, A = class
|
|
616
|
+
const _t = Ht, A = class Y extends L {
|
|
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(Y.blotName);
|
|
622
622
|
if (!(s != null && t.tagName === s.tagName)) {
|
|
623
623
|
if (typeof this.tagName == "string")
|
|
624
624
|
return !0;
|
|
@@ -631,7 +631,7 @@ const _t = Ht, A = class Z extends L {
|
|
|
631
631
|
}
|
|
632
632
|
format(t, e) {
|
|
633
633
|
const s = this.scroll.query(t, d.BLOCK);
|
|
634
|
-
s != null && (s instanceof T ? this.attributes.attribute(s, e) : t === this.statics.blotName && !e ? this.replaceWith(
|
|
634
|
+
s != null && (s instanceof T ? this.attributes.attribute(s, e) : t === this.statics.blotName && !e ? this.replaceWith(Y.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);
|
|
@@ -668,7 +668,7 @@ A.blotName = "block", A.scope = d.BLOCK_BLOT, A.tagName = "P", A.allowedChildren
|
|
|
668
668
|
q
|
|
669
669
|
];
|
|
670
670
|
let Kt = A;
|
|
671
|
-
const
|
|
671
|
+
const Z = Kt, J = class extends L {
|
|
672
672
|
checkMerge() {
|
|
673
673
|
return this.next !== null && this.next.statics.blotName === this.statics.blotName;
|
|
674
674
|
}
|
|
@@ -685,10 +685,10 @@ const J = Kt, Q = 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 Vt =
|
|
688
|
+
J.blotName = "container", J.scope = d.BLOCK_BLOT;
|
|
689
|
+
let Vt = J;
|
|
690
690
|
const qt = Vt;
|
|
691
|
-
class
|
|
691
|
+
class Wt extends q {
|
|
692
692
|
static formats(t, e) {
|
|
693
693
|
}
|
|
694
694
|
format(t, e) {
|
|
@@ -701,7 +701,7 @@ class Ft extends q {
|
|
|
701
701
|
return this.statics.formats(this.domNode, this.scroll);
|
|
702
702
|
}
|
|
703
703
|
}
|
|
704
|
-
const
|
|
704
|
+
const Ft = Wt, Gt = {
|
|
705
705
|
attributes: !0,
|
|
706
706
|
characterData: !0,
|
|
707
707
|
characterDataOldValue: !0,
|
|
@@ -781,9 +781,9 @@ const Wt = Ft, Gt = {
|
|
|
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
|
-
S.blotName = "scroll", S.defaultChild =
|
|
784
|
+
S.blotName = "scroll", S.defaultChild = Z, S.allowedChildren = [Z, qt], S.scope = d.BLOCK_BLOT, S.tagName = "DIV";
|
|
785
785
|
let Xt = S;
|
|
786
|
-
const Yt = Xt,
|
|
786
|
+
const Yt = Xt, nt = class vt extends q {
|
|
787
787
|
static create(t) {
|
|
788
788
|
return document.createTextNode(t);
|
|
789
789
|
}
|
|
@@ -828,8 +828,8 @@ const Yt = Xt, ot = class vt extends q {
|
|
|
828
828
|
return this.text;
|
|
829
829
|
}
|
|
830
830
|
};
|
|
831
|
-
|
|
832
|
-
const
|
|
831
|
+
nt.blotName = "text", nt.scope = d.INLINE_BLOT;
|
|
832
|
+
const et = class et extends Yt {
|
|
833
833
|
constructor(t, e) {
|
|
834
834
|
super(t, e), this.observer.disconnect();
|
|
835
835
|
}
|
|
@@ -839,9 +839,9 @@ const st = class st extends Yt {
|
|
|
839
839
|
optimize(t, e) {
|
|
840
840
|
}
|
|
841
841
|
};
|
|
842
|
-
|
|
843
|
-
let
|
|
844
|
-
const B = class B extends
|
|
842
|
+
et.blotName = "rc-scroll";
|
|
843
|
+
let Q = et;
|
|
844
|
+
const B = class B extends Z {
|
|
845
845
|
};
|
|
846
846
|
B.blotName = "rc-block", B.tagName = "DIV", B.className = "line";
|
|
847
847
|
let U = B;
|
|
@@ -859,7 +859,7 @@ function Zt(n, t) {
|
|
|
859
859
|
n.classList.add(e);
|
|
860
860
|
t.bold && (n.style.fontWeight = "bold"), t.italic && (n.style.fontStyle = "italic"), t.color && (n.style.color = t.color), t.background && (n.style.backgroundColor = t.background), t.underline && (n.style.textDecoration = `${t.underline} underline`, t.underlineColor && (n.style.textDecorationColor = t.underlineColor));
|
|
861
861
|
}
|
|
862
|
-
const I = class I extends
|
|
862
|
+
const I = class I extends Ft {
|
|
863
863
|
static create() {
|
|
864
864
|
const t = super.create();
|
|
865
865
|
return t.contentEditable = "false", t.setAttribute("aria-hidden", "true"), t;
|
|
@@ -920,7 +920,7 @@ function G(n) {
|
|
|
920
920
|
class te {
|
|
921
921
|
constructor(t) {
|
|
922
922
|
const e = Jt();
|
|
923
|
-
this.scroll = new
|
|
923
|
+
this.scroll = new Q(e, t);
|
|
924
924
|
}
|
|
925
925
|
/**
|
|
926
926
|
* Rebuild the document tree.
|
|
@@ -949,26 +949,26 @@ class te {
|
|
|
949
949
|
} else
|
|
950
950
|
p = U.create(), s.appendChild(p);
|
|
951
951
|
const k = o.get(g) ?? [];
|
|
952
|
-
for (const
|
|
953
|
-
if (
|
|
954
|
-
for (const x of
|
|
952
|
+
for (const _ of k) {
|
|
953
|
+
if (_.className)
|
|
954
|
+
for (const x of _.className.split(/\s+/).filter(Boolean))
|
|
955
955
|
p.classList.add(x);
|
|
956
|
-
if (
|
|
957
|
-
for (const [x, w] of Object.entries(
|
|
956
|
+
if (_.attributes)
|
|
957
|
+
for (const [x, w] of Object.entries(_.attributes))
|
|
958
958
|
p.setAttribute(x, w);
|
|
959
959
|
}
|
|
960
|
-
const St = a.filter((
|
|
960
|
+
const St = a.filter((_) => _.from < m && _.to > u), Ot = l.filter((_) => _.offset >= u && _.offset <= m);
|
|
961
961
|
Qt(p, f, u, St, Ot);
|
|
962
|
-
const
|
|
963
|
-
if (
|
|
964
|
-
const
|
|
962
|
+
const W = k.filter((_) => _.message);
|
|
963
|
+
if (W.length > 0) {
|
|
964
|
+
const _ = W.map((w) => w.message).join(" · "), x = [
|
|
965
965
|
...new Set(
|
|
966
|
-
|
|
966
|
+
W.flatMap(
|
|
967
967
|
(w) => w.messageClassName ? w.messageClassName.split(/\s+/).filter(Boolean) : []
|
|
968
968
|
)
|
|
969
969
|
)
|
|
970
970
|
];
|
|
971
|
-
p.dataset.message =
|
|
971
|
+
p.dataset.message = _, p.title = _, x.length > 0 && (p.dataset.messageClass = x.join(" "));
|
|
972
972
|
}
|
|
973
973
|
h += f.length + 1;
|
|
974
974
|
}
|
|
@@ -984,25 +984,25 @@ class te {
|
|
|
984
984
|
function ee(n) {
|
|
985
985
|
const t = Array.from(n.querySelectorAll(".line"));
|
|
986
986
|
return t.length > 0 ? t.map((e) => se(e)).join(`
|
|
987
|
-
`) :
|
|
987
|
+
`) : bt(n);
|
|
988
988
|
}
|
|
989
989
|
function se(n) {
|
|
990
990
|
let t = "";
|
|
991
991
|
for (const e of n.childNodes)
|
|
992
|
-
t +=
|
|
992
|
+
t += yt(e);
|
|
993
993
|
return t;
|
|
994
994
|
}
|
|
995
|
-
function
|
|
995
|
+
function yt(n) {
|
|
996
996
|
if (n.nodeType === Node.TEXT_NODE)
|
|
997
997
|
return n.data;
|
|
998
998
|
if (!(n instanceof Element) || n.classList.contains("widget") || n.classList.contains("line-message") || n.tagName === "BR")
|
|
999
999
|
return "";
|
|
1000
1000
|
let t = "";
|
|
1001
1001
|
for (const e of n.childNodes)
|
|
1002
|
-
t +=
|
|
1002
|
+
t += yt(e);
|
|
1003
1003
|
return t;
|
|
1004
1004
|
}
|
|
1005
|
-
function
|
|
1005
|
+
function bt(n) {
|
|
1006
1006
|
let t = "", e = !0;
|
|
1007
1007
|
for (const s of n.childNodes)
|
|
1008
1008
|
if (s.nodeType === Node.TEXT_NODE)
|
|
@@ -1016,7 +1016,7 @@ function yt(n) {
|
|
|
1016
1016
|
if (s.classList.contains("widget"))
|
|
1017
1017
|
continue;
|
|
1018
1018
|
(s.tagName === "DIV" || s.tagName === "P") && !e && (t += `
|
|
1019
|
-
`), e = !1, t +=
|
|
1019
|
+
`), e = !1, t += bt(s);
|
|
1020
1020
|
}
|
|
1021
1021
|
return t;
|
|
1022
1022
|
}
|
|
@@ -1070,7 +1070,7 @@ function Nt(n, t, e, s) {
|
|
|
1070
1070
|
}
|
|
1071
1071
|
return { found: !1, offset: s };
|
|
1072
1072
|
}
|
|
1073
|
-
function
|
|
1073
|
+
function ot(n, t) {
|
|
1074
1074
|
const e = Array.from(n.querySelectorAll(".line"));
|
|
1075
1075
|
let s = t;
|
|
1076
1076
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -1123,14 +1123,18 @@ function P(n) {
|
|
|
1123
1123
|
const [r] = s.getComposedRanges({ shadowRoots: [t] });
|
|
1124
1124
|
if (r && n.contains(r.startContainer) && n.contains(r.endContainer))
|
|
1125
1125
|
return {
|
|
1126
|
-
anchorOffset: $(
|
|
1126
|
+
anchorOffset: $(
|
|
1127
|
+
n,
|
|
1128
|
+
r.startContainer,
|
|
1129
|
+
r.startOffset
|
|
1130
|
+
),
|
|
1127
1131
|
focusOffset: $(n, r.endContainer, r.endOffset)
|
|
1128
1132
|
};
|
|
1129
1133
|
}
|
|
1130
1134
|
return null;
|
|
1131
1135
|
}
|
|
1132
1136
|
function ie(n, t) {
|
|
1133
|
-
const e =
|
|
1137
|
+
const e = ot(n, t.anchorOffset), s = ot(n, t.focusOffset);
|
|
1134
1138
|
if (!(!e || !s))
|
|
1135
1139
|
try {
|
|
1136
1140
|
const i = window.getSelection();
|
|
@@ -1153,7 +1157,7 @@ function wt(n, t) {
|
|
|
1153
1157
|
s--, i--;
|
|
1154
1158
|
return { start: e, removed: s - e, inserted: i - e };
|
|
1155
1159
|
}
|
|
1156
|
-
function
|
|
1160
|
+
function at(n, t, e) {
|
|
1157
1161
|
const s = e.start + e.removed, i = e.inserted - e.removed;
|
|
1158
1162
|
if (t <= e.start)
|
|
1159
1163
|
return { from: n, to: t };
|
|
@@ -1176,12 +1180,12 @@ function ne(n, t, e) {
|
|
|
1176
1180
|
const s = wt(t, e), i = s.start + s.removed, r = t.slice(s.start, i), o = e.slice(s.start, s.start + s.inserted), a = (r.match(/\n/g) ?? []).length, h = (o.match(/\n/g) ?? []).length - a, c = re(t, s.start) + 1, f = c + a, g = [];
|
|
1177
1181
|
for (const u of n)
|
|
1178
1182
|
if (u.type === "mark") {
|
|
1179
|
-
const m =
|
|
1183
|
+
const m = at(u.from, u.to, s);
|
|
1180
1184
|
m && g.push({ ...u, from: m.from, to: m.to });
|
|
1181
1185
|
} else if (u.type === "line")
|
|
1182
1186
|
u.line < c ? g.push(u) : u.line <= f || g.push({ ...u, line: u.line + h });
|
|
1183
1187
|
else {
|
|
1184
|
-
const m =
|
|
1188
|
+
const m = at(u.offset, u.offset + 1, s);
|
|
1185
1189
|
m && g.push({ ...u, offset: m.from });
|
|
1186
1190
|
}
|
|
1187
1191
|
return g;
|
|
@@ -1196,7 +1200,7 @@ function j(n, t, e) {
|
|
|
1196
1200
|
const s = wt(t, e);
|
|
1197
1201
|
return oe(t, s) ? [] : ne(n, t, e);
|
|
1198
1202
|
}
|
|
1199
|
-
function
|
|
1203
|
+
function lt(n, t) {
|
|
1200
1204
|
const e = crypto.randomUUID();
|
|
1201
1205
|
return n.set(e, { ...t, id: e }), e;
|
|
1202
1206
|
}
|
|
@@ -1262,6 +1266,7 @@ const ce = Lt`
|
|
|
1262
1266
|
:host {
|
|
1263
1267
|
display: block;
|
|
1264
1268
|
box-sizing: border-box;
|
|
1269
|
+
min-inline-size: 0;
|
|
1265
1270
|
color-scheme: inherit;
|
|
1266
1271
|
}
|
|
1267
1272
|
|
|
@@ -1291,7 +1296,6 @@ const ce = Lt`
|
|
|
1291
1296
|
}
|
|
1292
1297
|
|
|
1293
1298
|
:host([line-numbers]) #gutter,
|
|
1294
|
-
:host([list-numbers]) #gutter,
|
|
1295
1299
|
:host([gutter]) #gutter {
|
|
1296
1300
|
display: block;
|
|
1297
1301
|
}
|
|
@@ -1427,13 +1431,13 @@ const ce = Lt`
|
|
|
1427
1431
|
vertical-align: middle;
|
|
1428
1432
|
}
|
|
1429
1433
|
`;
|
|
1430
|
-
var he = Object.defineProperty, ue = Object.getOwnPropertyDescriptor,
|
|
1434
|
+
var he = Object.defineProperty, ue = Object.getOwnPropertyDescriptor, y = (n, t, e, s) => {
|
|
1431
1435
|
for (var i = s > 1 ? void 0 : s ? ue(t, e) : t, r = n.length - 1, o; r >= 0; r--)
|
|
1432
1436
|
(o = n[r]) && (i = (s ? o(t, e, i) : o(i)) || i);
|
|
1433
1437
|
return s && i && he(t, e, i), i;
|
|
1434
1438
|
};
|
|
1435
1439
|
const de = 100;
|
|
1436
|
-
function
|
|
1440
|
+
function ct(n) {
|
|
1437
1441
|
const t = document.createElement("div");
|
|
1438
1442
|
t.innerHTML = n;
|
|
1439
1443
|
const e = [];
|
|
@@ -1459,9 +1463,9 @@ function X(n) {
|
|
|
1459
1463
|
i(r);
|
|
1460
1464
|
return e;
|
|
1461
1465
|
}
|
|
1462
|
-
const V = class V extends
|
|
1466
|
+
const V = class V extends st {
|
|
1463
1467
|
constructor() {
|
|
1464
|
-
super(...arguments), this.lineNumbers = !1, this.
|
|
1468
|
+
super(...arguments), this.lineNumbers = !1, this.gutter = !1, this.wordWrap = !1, this.autoGrow = !1, this.readOnly = !1, this._value = "", this._initialValueResolved = !1, this._valueSetByHost = !1, this._document = null, this._$textareaRef = null, this._textareaController = new kt(this, {
|
|
1465
1469
|
selector: ":scope > textarea",
|
|
1466
1470
|
observe: !0,
|
|
1467
1471
|
onChange: (t, e) => this._setupTextarea(t, e),
|
|
@@ -1522,26 +1526,6 @@ const V = class V extends it {
|
|
|
1522
1526
|
this._insertText(s);
|
|
1523
1527
|
};
|
|
1524
1528
|
}
|
|
1525
|
-
get listNumbers() {
|
|
1526
|
-
return this._listNumbers;
|
|
1527
|
-
}
|
|
1528
|
-
set listNumbers(t) {
|
|
1529
|
-
t && console.warn(
|
|
1530
|
-
"[rc-textarea] `listNumbers` / `list-numbers` is deprecated and will be removed before v1.0. Use a plugin with `LineDecoration.gutterContent` to implement sparse line numbering."
|
|
1531
|
-
);
|
|
1532
|
-
const e = this._listNumbers;
|
|
1533
|
-
this._listNumbers = t, this.requestUpdate("listNumbers", e);
|
|
1534
|
-
}
|
|
1535
|
-
get label() {
|
|
1536
|
-
return this._label;
|
|
1537
|
-
}
|
|
1538
|
-
set label(t) {
|
|
1539
|
-
t && console.warn(
|
|
1540
|
-
"[rc-textarea] `label` is deprecated and will be removed before v1.0. Set `aria-label` on the slotted `<textarea>`, or associate a `<label>` element via its `for`/`id` pair instead."
|
|
1541
|
-
);
|
|
1542
|
-
const e = this._label;
|
|
1543
|
-
this._label = t, this.requestUpdate("label", e);
|
|
1544
|
-
}
|
|
1545
1529
|
get plugin() {
|
|
1546
1530
|
return this._pluginProperty;
|
|
1547
1531
|
}
|
|
@@ -1577,12 +1561,12 @@ const V = class V extends it {
|
|
|
1577
1561
|
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);
|
|
1578
1562
|
}
|
|
1579
1563
|
firstUpdated() {
|
|
1580
|
-
this._$editor && (this._document = new te(this._$editor), this._bindEditorEvents(this._$editor)), this._resizeObserver = new ResizeObserver(() => {
|
|
1564
|
+
this._$editor && (this._document = new te(this._$editor), this._bindEditorEvents(this._$editor), this._syncLabel()), this._resizeObserver = new ResizeObserver(() => {
|
|
1581
1565
|
this._syncGutter(), this._syncGutterHeights();
|
|
1582
1566
|
}), this._resizeObserver.observe(this), this._scheduleRender();
|
|
1583
1567
|
}
|
|
1584
1568
|
updated(t) {
|
|
1585
|
-
t.has("readOnly") && (this._$editor && (this._$editor.contentEditable = this.readOnly ? "false" : "true"), this._syncGutterHeights(), this._textareaController.sync())
|
|
1569
|
+
t.has("readOnly") && (this._$editor && (this._$editor.contentEditable = this.readOnly ? "false" : "true"), this._syncGutterHeights(), this._textareaController.sync());
|
|
1586
1570
|
}
|
|
1587
1571
|
render() {
|
|
1588
1572
|
return Tt`
|
|
@@ -1858,7 +1842,7 @@ const V = class V extends it {
|
|
|
1858
1842
|
};
|
|
1859
1843
|
},
|
|
1860
1844
|
addDecoration(e) {
|
|
1861
|
-
return
|
|
1845
|
+
return lt(t._pluginDecorations, e);
|
|
1862
1846
|
},
|
|
1863
1847
|
removeDecoration(e) {
|
|
1864
1848
|
t._pluginDecorations.delete(e);
|
|
@@ -1888,11 +1872,7 @@ const V = class V extends it {
|
|
|
1888
1872
|
)), t._pluginSheets.delete(e);
|
|
1889
1873
|
},
|
|
1890
1874
|
parseDecorationsFromHtml(e) {
|
|
1891
|
-
return
|
|
1892
|
-
},
|
|
1893
|
-
/** @deprecated Use `parseDecorationsFromHtml` instead. */
|
|
1894
|
-
decorationsFromHtml(e) {
|
|
1895
|
-
return X(e);
|
|
1875
|
+
return ct(e);
|
|
1896
1876
|
},
|
|
1897
1877
|
decorationsFromTokens(e, s) {
|
|
1898
1878
|
const i = [];
|
|
@@ -1979,9 +1959,9 @@ const V = class V extends it {
|
|
|
1979
1959
|
if (t !== this._pluginSeq)
|
|
1980
1960
|
return;
|
|
1981
1961
|
if (typeof a == "string") {
|
|
1982
|
-
const l =
|
|
1962
|
+
const l = ct(a);
|
|
1983
1963
|
for (const h of l)
|
|
1984
|
-
|
|
1964
|
+
lt(this._pluginDecorations, h);
|
|
1985
1965
|
}
|
|
1986
1966
|
}
|
|
1987
1967
|
}
|
|
@@ -1999,7 +1979,7 @@ const V = class V extends it {
|
|
|
1999
1979
|
}
|
|
2000
1980
|
/**
|
|
2001
1981
|
* Compute the label string for each gutter cell based on the current gutter
|
|
2002
|
-
* mode (`lineNumbers`, `
|
|
1982
|
+
* mode (`lineNumbers`, `gutter`) and any
|
|
2003
1983
|
* `LineDecoration.gutterContent` overrides in `allDecorations`.
|
|
2004
1984
|
*
|
|
2005
1985
|
* Returns one entry per line (same length as `value.split('\n')`):
|
|
@@ -2009,12 +1989,11 @@ const V = class V extends it {
|
|
|
2009
1989
|
_computeGutterLabels(t, e = this._value) {
|
|
2010
1990
|
const s = e.split(`
|
|
2011
1991
|
`), i = /* @__PURE__ */ new Map();
|
|
2012
|
-
for (const
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
return i.has(l) ? i.get(l) : this.lineNumbers ? String(l) : this.listNumbers ? o.trim() === "" ? null : (r++, `${r}.`) : null;
|
|
1992
|
+
for (const r of t)
|
|
1993
|
+
r.type === "line" && r.gutterContent !== void 0 && i.set(r.line, r.gutterContent);
|
|
1994
|
+
return s.map((r, o) => {
|
|
1995
|
+
const a = o + 1;
|
|
1996
|
+
return i.has(a) ? i.get(a) : this.lineNumbers ? String(a) : null;
|
|
2018
1997
|
});
|
|
2019
1998
|
}
|
|
2020
1999
|
/**
|
|
@@ -2055,7 +2034,7 @@ const V = class V extends it {
|
|
|
2055
2034
|
* (called by the `ResizeObserver` without a new render pass).
|
|
2056
2035
|
*/
|
|
2057
2036
|
_syncGutter(t) {
|
|
2058
|
-
if (!this.lineNumbers && !this.
|
|
2037
|
+
if (!this.lineNumbers && !this.gutter || !this._$gutterCells)
|
|
2059
2038
|
return;
|
|
2060
2039
|
t !== void 0 && (this._gutterLabels = t);
|
|
2061
2040
|
const e = this._gutterLabels;
|
|
@@ -2085,10 +2064,6 @@ const V = class V extends it {
|
|
|
2085
2064
|
return;
|
|
2086
2065
|
}
|
|
2087
2066
|
}
|
|
2088
|
-
if (this._label) {
|
|
2089
|
-
this._$editor.setAttribute("aria-label", this._label);
|
|
2090
|
-
return;
|
|
2091
|
-
}
|
|
2092
2067
|
this._$editor.removeAttribute("aria-label");
|
|
2093
2068
|
}
|
|
2094
2069
|
_syncTypography(t) {
|
|
@@ -2127,52 +2102,46 @@ const V = class V extends it {
|
|
|
2127
2102
|
}
|
|
2128
2103
|
};
|
|
2129
2104
|
V.styles = ce, V.shadowRootOptions = {
|
|
2130
|
-
...
|
|
2105
|
+
...st.shadowRootOptions,
|
|
2131
2106
|
delegatesFocus: !0
|
|
2132
2107
|
};
|
|
2133
|
-
let
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
],
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
],
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
],
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
],
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
],
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
],
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
],
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
],
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
],
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
],
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
],
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
],
|
|
2170
|
-
b([
|
|
2171
|
-
y({ type: String })
|
|
2172
|
-
], _.prototype, "value", 1);
|
|
2173
|
-
b([
|
|
2174
|
-
y({ type: String, attribute: "default-value" })
|
|
2175
|
-
], _.prototype, "defaultValue", 1);
|
|
2108
|
+
let v = V;
|
|
2109
|
+
y([
|
|
2110
|
+
b({ type: Boolean, attribute: "line-numbers", reflect: !0 })
|
|
2111
|
+
], v.prototype, "lineNumbers", 2);
|
|
2112
|
+
y([
|
|
2113
|
+
b({ type: Boolean, attribute: "gutter", reflect: !0 })
|
|
2114
|
+
], v.prototype, "gutter", 2);
|
|
2115
|
+
y([
|
|
2116
|
+
b({ type: Boolean, attribute: "word-wrap", reflect: !0 })
|
|
2117
|
+
], v.prototype, "wordWrap", 2);
|
|
2118
|
+
y([
|
|
2119
|
+
b({ type: Boolean, attribute: "auto-grow", reflect: !0 })
|
|
2120
|
+
], v.prototype, "autoGrow", 2);
|
|
2121
|
+
y([
|
|
2122
|
+
b({ type: Boolean, attribute: "read-only", reflect: !0 })
|
|
2123
|
+
], v.prototype, "readOnly", 2);
|
|
2124
|
+
y([
|
|
2125
|
+
b({ attribute: !1 })
|
|
2126
|
+
], v.prototype, "plugin", 1);
|
|
2127
|
+
y([
|
|
2128
|
+
b({ attribute: !1 })
|
|
2129
|
+
], v.prototype, "decorations", 1);
|
|
2130
|
+
y([
|
|
2131
|
+
tt("#editor")
|
|
2132
|
+
], v.prototype, "_$editor", 2);
|
|
2133
|
+
y([
|
|
2134
|
+
tt("#gutter-cells")
|
|
2135
|
+
], v.prototype, "_$gutterCells", 2);
|
|
2136
|
+
y([
|
|
2137
|
+
tt("slot")
|
|
2138
|
+
], v.prototype, "_$slot", 2);
|
|
2139
|
+
y([
|
|
2140
|
+
b({ type: String })
|
|
2141
|
+
], v.prototype, "value", 1);
|
|
2142
|
+
y([
|
|
2143
|
+
b({ type: String, attribute: "default-value" })
|
|
2144
|
+
], v.prototype, "defaultValue", 1);
|
|
2176
2145
|
function we(n, t = {}) {
|
|
2177
2146
|
const e = [];
|
|
2178
2147
|
return {
|
|
@@ -2391,8 +2360,8 @@ function me(n, t, e) {
|
|
|
2391
2360
|
}
|
|
2392
2361
|
export {
|
|
2393
2362
|
Ct as L,
|
|
2394
|
-
|
|
2363
|
+
v as R,
|
|
2395
2364
|
we as c,
|
|
2396
2365
|
le as m
|
|
2397
2366
|
};
|
|
2398
|
-
//# sourceMappingURL=line-actions-controller-
|
|
2367
|
+
//# sourceMappingURL=line-actions-controller-BcsnmSPS.js.map
|