@rcarls/rc-textarea 0.3.1 → 0.4.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.
@@ -1,175 +1,6 @@
1
- import { css as Ot, LitElement as st, html as Tt } from "lit";
2
- import { property as y, query as tt } from "lit/decorators.js";
1
+ import { css as Lt, LitElement as it, html as Tt } from "lit";
2
+ import { property as y, query as et } from "lit/decorators.js";
3
3
  import { NativeChildController as kt } from "@rcarls/rc-common";
4
- const Bt = Ot`
5
- :host {
6
- display: block;
7
- box-sizing: border-box;
8
- color-scheme: inherit;
9
- }
10
-
11
- :host([hidden]) {
12
- display: none;
13
- }
14
-
15
- #root {
16
- display: flex;
17
- align-items: stretch;
18
- border: var(--rc-textarea-border, 1px solid ButtonBorder);
19
- border-radius: var(--rc-textarea-border-radius, 2px);
20
- background: var(--rc-textarea-background, Field);
21
- color: var(--rc-textarea-color, var(--rc-text, FieldText));
22
- overflow: hidden;
23
- min-height: var(--_rc-textarea-min-height, auto);
24
- }
25
-
26
- #gutter {
27
- display: none;
28
- flex-shrink: 0;
29
- background: var(--rc-textarea-gutter-bg, Canvas);
30
- color: var(--rc-textarea-gutter-color, GrayText);
31
- border-right: var(--rc-textarea-gutter-border, 1px solid ButtonBorder);
32
- overflow: hidden;
33
- user-select: none;
34
- }
35
-
36
- :host([line-numbers]) #gutter,
37
- :host([list-numbers]) #gutter,
38
- :host([gutter]) #gutter {
39
- display: block;
40
- }
41
-
42
- #gutter-cells {
43
- padding: var(--rc-textarea-padding, 0.5em);
44
- padding-inline-end: var(--rc-textarea-gutter-padding-inline-end, 0.75em);
45
- font-family: var(--rc-textarea-font-family, monospace);
46
- font-size: var(--rc-textarea-font-size, 1em);
47
- line-height: var(--rc-textarea-line-height, 1.5);
48
- text-align: right;
49
- min-width: 2.5ch;
50
- }
51
-
52
- .gutter-cell {
53
- display: block;
54
- white-space: pre;
55
- }
56
-
57
- .gutter-cell--active {
58
- color: var(--rc-textarea-color, var(--rc-text, FieldText));
59
- }
60
-
61
- #editor-area {
62
- position: relative;
63
- flex: 1;
64
- min-width: 0;
65
- overflow: hidden;
66
- }
67
-
68
- #editor {
69
- position: relative;
70
- z-index: 1;
71
- width: 100%;
72
- min-height: 100%;
73
- box-sizing: border-box;
74
- padding: var(--rc-textarea-padding, 0.5em);
75
- font-family: var(--rc-textarea-font-family, monospace);
76
- font-size: var(--rc-textarea-font-size, 1em);
77
- line-height: var(--rc-textarea-line-height, 1.5);
78
- color: var(--rc-textarea-color, var(--rc-text, FieldText));
79
- caret-color: var(--rc-textarea-caret-color, var(--rc-textarea-color, FieldText));
80
- background: transparent;
81
- outline: none;
82
- overflow: auto;
83
- resize: none;
84
- white-space: pre;
85
- word-break: normal;
86
- overflow-wrap: normal;
87
- tab-size: 4;
88
- word-break: normal;
89
- /* Prevent contenteditable from injecting <div> wrappers on Enter in some browsers */
90
- -webkit-user-modify: read-write-plaintext-only;
91
- }
92
-
93
- :host([word-wrap]) #editor {
94
- white-space: pre-wrap;
95
- overflow-wrap: break-word;
96
- word-break: normal;
97
- }
98
-
99
- :host([auto-grow]) #editor {
100
- overflow: visible;
101
- height: auto;
102
- }
103
-
104
- :host([auto-grow]) #root {
105
- height: auto;
106
- }
107
-
108
- :host([read-only]) #root {
109
- border: none;
110
- background: transparent;
111
- border-radius: 0;
112
- }
113
-
114
- :host([read-only]) #editor {
115
- cursor: default;
116
- padding: 0;
117
- -webkit-user-modify: read-only;
118
- }
119
-
120
- /* Focus ring on the root when editor is focused */
121
- #root:has(#editor:focus) {
122
- outline: var(--rc-textarea-focus-outline, 2px solid Highlight);
123
- outline-offset: -1px;
124
- }
125
-
126
- /* Slotted textarea is hidden on host upgrade */
127
- ::slotted(textarea) {
128
- position: absolute !important;
129
- width: 1px !important;
130
- height: 1px !important;
131
- padding: 0 !important;
132
- margin: -1px !important;
133
- overflow: hidden !important;
134
- clip: rect(0, 0, 0, 0) !important;
135
- border: 0 !important;
136
- opacity: 0 !important;
137
- pointer-events: none !important;
138
- }
139
-
140
- .line {
141
- position: relative;
142
- display: block;
143
- }
144
-
145
- /* Active line highlight — opt-in via CSS custom property. */
146
- .line--active {
147
- background: var(--rc-textarea-active-line-bg, transparent);
148
- }
149
-
150
- /* Error-lens -style end-of-line diagnostic message */
151
- .line[data-message]::after {
152
- content: attr(data-message);
153
- display: inline;
154
- margin-left: 4ch;
155
- white-space: nowrap;
156
- pointer-events: none;
157
- font-size: 0.875em;
158
- opacity: 0.8;
159
- font-style: italic;
160
- }
161
-
162
- .mark {
163
- border-radius: 2px;
164
- }
165
-
166
- .widget {
167
- display: inline-block;
168
- user-select: none;
169
- cursor: default;
170
- vertical-align: middle;
171
- }
172
- `;
173
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 || {});
174
5
  class T {
175
6
  constructor(t, e, s = {}) {
@@ -197,12 +28,12 @@ class T {
197
28
  return this.canAdd(t, e) && e ? e : "";
198
29
  }
199
30
  }
200
- class L extends Error {
31
+ class O extends Error {
201
32
  constructor(t) {
202
33
  t = "[Parchment] " + t, super(t), this.message = t, this.name = this.constructor.name;
203
34
  }
204
35
  }
205
- const ut = class X {
36
+ const ut = class Y {
206
37
  constructor() {
207
38
  this.attributes = {}, this.classes = {}, this.tags = {}, this.types = {};
208
39
  }
@@ -225,15 +56,15 @@ const ut = class X {
225
56
  create(t, e, s) {
226
57
  const i = this.query(e);
227
58
  if (i == null)
228
- throw new L(`Unable to create ${e} blot`);
59
+ throw new O(`Unable to create ${e} blot`);
229
60
  const r = i, o = (
230
61
  // @ts-expect-error Fix me later
231
62
  e instanceof Node || e.nodeType === Node.TEXT_NODE ? e : r.create(s)
232
63
  ), a = new r(t, o, s);
233
- return X.blots.set(a.domNode, a), a;
64
+ return Y.blots.set(a.domNode, a), a;
234
65
  }
235
66
  find(t, e = !1) {
236
- return X.find(t, e);
67
+ return Y.find(t, e);
237
68
  }
238
69
  query(t, e = d.ANY) {
239
70
  let s;
@@ -243,9 +74,9 @@ const ut = class X {
243
74
  return t.map((e) => {
244
75
  const s = "blotName" in e, i = "attrName" in e;
245
76
  if (!s && !i)
246
- throw new L("Invalid definition");
77
+ throw new O("Invalid definition");
247
78
  if (s && e.blotName === "abstract")
248
- throw new L("Cannot register abstract class");
79
+ throw new O("Cannot register abstract class");
249
80
  const r = s ? e.blotName : i ? e.attrName : void 0;
250
81
  return this.types[r] = 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) => {
251
82
  (this.tags[o] == null || e.className == null) && (this.tags[o] = e);
@@ -254,11 +85,11 @@ const ut = class X {
254
85
  }
255
86
  };
256
87
  ut.blots = /* @__PURE__ */ new WeakMap();
257
- let M = ut;
258
- function it(n, t) {
88
+ let z = ut;
89
+ function rt(n, t) {
259
90
  return (n.getAttribute("class") || "").split(/\s+/).filter((e) => e.indexOf(`${t}-`) === 0);
260
91
  }
261
- class Dt extends T {
92
+ class Bt extends T {
262
93
  static keys(t) {
263
94
  return (t.getAttribute("class") || "").split(/\s+/).map((e) => e.split("-").slice(0, -1).join("-"));
264
95
  }
@@ -266,37 +97,37 @@ class Dt extends T {
266
97
  return this.canAdd(t, e) ? (this.remove(t), t.classList.add(`${this.keyName}-${e}`), !0) : !1;
267
98
  }
268
99
  remove(t) {
269
- it(t, this.keyName).forEach((e) => {
100
+ rt(t, this.keyName).forEach((e) => {
270
101
  t.classList.remove(e);
271
102
  }), t.classList.length === 0 && t.removeAttribute("class");
272
103
  }
273
104
  value(t) {
274
- const e = (it(t, this.keyName)[0] || "").slice(this.keyName.length + 1);
105
+ const e = (rt(t, this.keyName)[0] || "").slice(this.keyName.length + 1);
275
106
  return this.canAdd(t, e) ? e : "";
276
107
  }
277
108
  }
278
- const It = Dt;
279
- function F(n) {
109
+ const Dt = Bt;
110
+ function W(n) {
280
111
  const t = n.split("-"), e = t.slice(1).map((s) => s[0].toUpperCase() + s.slice(1)).join("");
281
112
  return t[0] + e;
282
113
  }
283
- class $t extends T {
114
+ class It extends T {
284
115
  static keys(t) {
285
116
  return (t.getAttribute("style") || "").split(";").map((e) => e.split(":")[0].trim());
286
117
  }
287
118
  add(t, e) {
288
- return this.canAdd(t, e) ? (t.style[F(this.keyName)] = e, !0) : !1;
119
+ return this.canAdd(t, e) ? (t.style[W(this.keyName)] = e, !0) : !1;
289
120
  }
290
121
  remove(t) {
291
- t.style[F(this.keyName)] = "", t.getAttribute("style") || t.removeAttribute("style");
122
+ t.style[W(this.keyName)] = "", t.getAttribute("style") || t.removeAttribute("style");
292
123
  }
293
124
  value(t) {
294
- const e = t.style[F(this.keyName)];
125
+ const e = t.style[W(this.keyName)];
295
126
  return this.canAdd(t, e) ? e : "";
296
127
  }
297
128
  }
298
- const Rt = $t;
299
- class Pt {
129
+ const Rt = It;
130
+ class $t {
300
131
  constructor(t) {
301
132
  this.attributes = {}, this.domNode = t, this.build();
302
133
  }
@@ -305,10 +136,10 @@ class Pt {
305
136
  }
306
137
  build() {
307
138
  this.attributes = {};
308
- const t = M.find(this.domNode);
139
+ const t = z.find(this.domNode);
309
140
  if (t == null)
310
141
  return;
311
- const e = T.keys(this.domNode), s = It.keys(this.domNode), i = Rt.keys(this.domNode);
142
+ const e = T.keys(this.domNode), s = Dt.keys(this.domNode), i = Rt.keys(this.domNode);
312
143
  e.concat(s).concat(i).forEach((r) => {
313
144
  const o = t.scroll.query(r, d.ATTRIBUTE);
314
145
  o instanceof T && (this.attributes[o.attrName] = o);
@@ -332,13 +163,13 @@ class Pt {
332
163
  );
333
164
  }
334
165
  }
335
- const dt = Pt, ft = class {
166
+ const dt = $t, ft = class {
336
167
  constructor(t, e) {
337
- this.scroll = t, this.domNode = e, M.blots.set(e, this), this.prev = null, this.next = null;
168
+ this.scroll = t, this.domNode = e, z.blots.set(e, this), this.prev = null, this.next = null;
338
169
  }
339
170
  static create(t) {
340
171
  if (this.tagName == null)
341
- throw new L("Blot definition missing tagName");
172
+ throw new O("Blot definition missing tagName");
342
173
  let e, s;
343
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;
344
175
  }
@@ -353,7 +184,7 @@ const dt = Pt, ft = class {
353
184
  return this.scroll.create(t);
354
185
  }
355
186
  detach() {
356
- this.parent != null && this.parent.removeChild(this), M.blots.delete(this.domNode);
187
+ this.parent != null && this.parent.removeChild(this), z.blots.delete(this.domNode);
357
188
  }
358
189
  deleteAt(t, e) {
359
190
  this.isolate(t, e).remove();
@@ -401,7 +232,7 @@ const dt = Pt, ft = class {
401
232
  wrap(t, e) {
402
233
  const s = typeof t == "string" ? this.scroll.create(t, e) : t;
403
234
  if (this.parent != null && this.parent.insertBefore(s, this.next || void 0), typeof s.appendChild != "function")
404
- throw new L(`Cannot wrap ${t}`);
235
+ throw new O(`Cannot wrap ${t}`);
405
236
  return s.appendChild(this), s;
406
237
  }
407
238
  };
@@ -443,9 +274,9 @@ const mt = class extends pt {
443
274
  }
444
275
  };
445
276
  mt.scope = d.INLINE_BLOT;
446
- let Mt = mt;
447
- const V = Mt;
448
- class zt {
277
+ let Pt = mt;
278
+ const q = Pt;
279
+ class Mt {
449
280
  constructor() {
450
281
  this.head = null, this.tail = null, this.length = 0;
451
282
  }
@@ -547,7 +378,7 @@ class zt {
547
378
  return e;
548
379
  }
549
380
  }
550
- function rt(n, t) {
381
+ function nt(n, t) {
551
382
  const e = t.find(n);
552
383
  if (e)
553
384
  return e;
@@ -579,12 +410,12 @@ const gt = class N extends pt {
579
410
  * Called during construction, should fill its own children LinkedList.
580
411
  */
581
412
  build() {
582
- this.children = new zt(), Array.from(this.domNode.childNodes).filter((t) => t !== this.uiNode).reverse().forEach((t) => {
413
+ this.children = new Mt(), Array.from(this.domNode.childNodes).filter((t) => t !== this.uiNode).reverse().forEach((t) => {
583
414
  try {
584
- const e = rt(t, this.scroll);
415
+ const e = nt(t, this.scroll);
585
416
  this.insertBefore(e, this.children.head || void 0);
586
417
  } catch (e) {
587
- if (e instanceof L)
418
+ if (e instanceof O)
588
419
  return;
589
420
  throw e;
590
421
  }
@@ -707,15 +538,15 @@ const gt = class N extends pt {
707
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) => {
708
539
  let o = null;
709
540
  r.nextSibling != null && (o = this.scroll.find(r.nextSibling));
710
- const a = rt(r, this.scroll);
541
+ const a = nt(r, this.scroll);
711
542
  (a.next !== o || a.next == null) && (a.parent != null && a.parent.removeChild(this), this.insertBefore(a, o || void 0));
712
543
  }), this.enforceAllowedChildren();
713
544
  }
714
545
  };
715
546
  gt.uiClass = "";
716
- let Ut = gt;
717
- const O = Ut;
718
- function Ht(n, t) {
547
+ let zt = gt;
548
+ const L = zt;
549
+ function Ut(n, t) {
719
550
  if (Object.keys(n).length !== Object.keys(t).length)
720
551
  return !1;
721
552
  for (const e in n)
@@ -723,7 +554,7 @@ function Ht(n, t) {
723
554
  return !1;
724
555
  return !0;
725
556
  }
726
- const E = class C extends O {
557
+ const E = class C extends L {
727
558
  static create(t) {
728
559
  return super.create(t);
729
560
  }
@@ -764,7 +595,7 @@ const E = class C extends O {
764
595
  if (Object.keys(e).length === 0)
765
596
  return this.unwrap();
766
597
  const s = this.next;
767
- s instanceof C && s.prev === this && Ht(e, s.formats()) && (s.moveChildren(this), s.remove());
598
+ s instanceof C && s.prev === this && Ut(e, s.formats()) && (s.moveChildren(this), s.remove());
768
599
  }
769
600
  replaceWith(t, e) {
770
601
  const s = super.replaceWith(t, e);
@@ -780,14 +611,14 @@ const E = class C extends O {
780
611
  return s instanceof C && this.attributes.move(s), s;
781
612
  }
782
613
  };
783
- E.allowedChildren = [E, V], E.blotName = "inline", E.scope = d.INLINE_BLOT, E.tagName = "SPAN";
784
- let Kt = E;
785
- const _t = Kt, A = class Y extends O {
614
+ E.allowedChildren = [E, q], E.blotName = "inline", E.scope = d.INLINE_BLOT, E.tagName = "SPAN";
615
+ let Ht = E;
616
+ const _t = Ht, A = class Z extends L {
786
617
  static create(t) {
787
618
  return super.create(t);
788
619
  }
789
620
  static formats(t, e) {
790
- const s = e.query(Y.blotName);
621
+ const s = e.query(Z.blotName);
791
622
  if (!(s != null && t.tagName === s.tagName)) {
792
623
  if (typeof this.tagName == "string")
793
624
  return !0;
@@ -800,7 +631,7 @@ const _t = Kt, A = class Y extends O {
800
631
  }
801
632
  format(t, e) {
802
633
  const s = this.scroll.query(t, d.BLOCK);
803
- 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));
634
+ s != null && (s instanceof T ? this.attributes.attribute(s, e) : t === this.statics.blotName && !e ? this.replaceWith(Z.blotName) : e && (t !== this.statics.blotName || this.formats()[t] !== e) && this.replaceWith(t, e));
804
635
  }
805
636
  formats() {
806
637
  const t = this.attributes.values(), e = this.statics.formats(this.domNode, this.scroll);
@@ -834,10 +665,10 @@ const _t = Kt, A = class Y extends O {
834
665
  A.blotName = "block", A.scope = d.BLOCK_BLOT, A.tagName = "P", A.allowedChildren = [
835
666
  _t,
836
667
  A,
837
- V
668
+ q
838
669
  ];
839
- let Vt = A;
840
- const Z = Vt, J = class extends O {
670
+ let Kt = A;
671
+ const J = Kt, Q = class extends L {
841
672
  checkMerge() {
842
673
  return this.next !== null && this.next.statics.blotName === this.statics.blotName;
843
674
  }
@@ -854,10 +685,10 @@ const Z = Vt, J = class extends O {
854
685
  super.optimize(t), this.children.length > 0 && this.next != null && this.checkMerge() && (this.next.moveChildren(this), this.next.remove());
855
686
  }
856
687
  };
857
- J.blotName = "container", J.scope = d.BLOCK_BLOT;
858
- let qt = J;
859
- const Ft = qt;
860
- class Wt extends V {
688
+ Q.blotName = "container", Q.scope = d.BLOCK_BLOT;
689
+ let Vt = Q;
690
+ const qt = Vt;
691
+ class Ft extends q {
861
692
  static formats(t, e) {
862
693
  }
863
694
  format(t, e) {
@@ -870,17 +701,17 @@ class Wt extends V {
870
701
  return this.statics.formats(this.domNode, this.scroll);
871
702
  }
872
703
  }
873
- const Gt = Wt, jt = {
704
+ const Wt = Ft, Gt = {
874
705
  attributes: !0,
875
706
  characterData: !0,
876
707
  characterDataOldValue: !0,
877
708
  childList: !0,
878
709
  subtree: !0
879
- }, Xt = 100, S = class extends O {
710
+ }, jt = 100, S = class extends L {
880
711
  constructor(t, e) {
881
712
  super(null, e), this.registry = t, this.scroll = this, this.build(), this.observer = new MutationObserver((s) => {
882
713
  this.update(s);
883
- }), this.observer.observe(this.domNode, jt), this.attach();
714
+ }), this.observer.observe(this.domNode, Gt), this.attach();
884
715
  }
885
716
  create(t, e) {
886
717
  return this.registry.create(this, t, e);
@@ -921,17 +752,17 @@ const Gt = Wt, jt = {
921
752
  const r = (l, h = !0) => {
922
753
  l == null || l === this || l.domNode.parentNode != null && (s.has(l.domNode) || s.set(l.domNode, []), h && r(l.parent));
923
754
  }, o = (l) => {
924
- s.has(l.domNode) && (l instanceof O && l.children.forEach(o), s.delete(l.domNode), l.optimize(e));
755
+ s.has(l.domNode) && (l instanceof L && l.children.forEach(o), s.delete(l.domNode), l.optimize(e));
925
756
  };
926
757
  let a = t;
927
758
  for (let l = 0; a.length > 0; l += 1) {
928
- if (l >= Xt)
759
+ if (l >= jt)
929
760
  throw new Error("[Parchment] Maximum optimize iterations reached");
930
761
  for (a.forEach((h) => {
931
762
  const c = this.find(h.target, !0);
932
763
  c != null && (c.domNode === h.target && (h.type === "childList" ? (r(this.find(h.previousSibling, !1)), Array.from(h.addedNodes).forEach((f) => {
933
764
  const g = this.find(f, !1);
934
- r(g, !1), g instanceof O && g.children.forEach((u) => {
765
+ r(g, !1), g instanceof L && g.children.forEach((u) => {
935
766
  r(u, !1);
936
767
  });
937
768
  })) : h.type === "attributes" && r(c.prev)), r(c));
@@ -950,9 +781,9 @@ const Gt = Wt, jt = {
950
781
  }), e.mutationsMap = s, s.has(this.domNode) && super.update(s.get(this.domNode), e), this.optimize(t, e);
951
782
  }
952
783
  };
953
- S.blotName = "scroll", S.defaultChild = Z, S.allowedChildren = [Z, Ft], S.scope = d.BLOCK_BLOT, S.tagName = "DIV";
954
- let Yt = S;
955
- const Zt = Yt, nt = class vt extends V {
784
+ S.blotName = "scroll", S.defaultChild = J, S.allowedChildren = [J, qt], S.scope = d.BLOCK_BLOT, S.tagName = "DIV";
785
+ let Xt = S;
786
+ const Yt = Xt, ot = class vt extends q {
956
787
  static create(t) {
957
788
  return document.createTextNode(t);
958
789
  }
@@ -997,8 +828,8 @@ const Zt = Yt, nt = class vt extends V {
997
828
  return this.text;
998
829
  }
999
830
  };
1000
- nt.blotName = "text", nt.scope = d.INLINE_BLOT;
1001
- const et = class et extends Zt {
831
+ ot.blotName = "text", ot.scope = d.INLINE_BLOT;
832
+ const st = class st extends Yt {
1002
833
  constructor(t, e) {
1003
834
  super(t, e), this.observer.disconnect();
1004
835
  }
@@ -1008,39 +839,39 @@ const et = class et extends Zt {
1008
839
  optimize(t, e) {
1009
840
  }
1010
841
  };
1011
- et.blotName = "rc-scroll";
1012
- let Q = et;
1013
- const B = class B extends Z {
842
+ st.blotName = "rc-scroll";
843
+ let tt = st;
844
+ const B = class B extends J {
1014
845
  };
1015
846
  B.blotName = "rc-block", B.tagName = "DIV", B.className = "line";
1016
- let z = B;
847
+ let U = B;
1017
848
  const D = class D extends _t {
1018
849
  static create(t) {
1019
850
  const e = super.create();
1020
- return t && Jt(e, t), e;
851
+ return t && Zt(e, t), e;
1021
852
  }
1022
853
  };
1023
854
  D.blotName = "rc-inline", D.tagName = "SPAN", D.className = "mark";
1024
- let U = D;
1025
- function Jt(n, t) {
855
+ let H = D;
856
+ function Zt(n, t) {
1026
857
  if (t.className)
1027
858
  for (const e of t.className.split(/\s+/).filter(Boolean))
1028
859
  n.classList.add(e);
1029
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));
1030
861
  }
1031
- const I = class I extends Gt {
862
+ const I = class I extends Wt {
1032
863
  static create() {
1033
864
  const t = super.create();
1034
865
  return t.contentEditable = "false", t.setAttribute("aria-hidden", "true"), t;
1035
866
  }
1036
867
  };
1037
868
  I.blotName = "rc-widget", I.tagName = "SPAN", I.className = "widget";
1038
- let H = I;
1039
- function Qt() {
1040
- const n = new M();
1041
- return n.register(z, U, H), n;
869
+ let K = I;
870
+ function Jt() {
871
+ const n = new z();
872
+ return n.register(U, H, K), n;
1042
873
  }
1043
- function te(n, t, e, s, i) {
874
+ function Qt(n, t, e, s, i) {
1044
875
  if (t.length === 0) {
1045
876
  n.appendChild(document.createElement("br"));
1046
877
  return;
@@ -1056,7 +887,7 @@ function te(n, t, e, s, i) {
1056
887
  for (let a = 0; a < o.length - 1; a++) {
1057
888
  const l = o[a], h = o[a + 1];
1058
889
  for (const u of i)
1059
- u.offset - e === l && (u.side ?? "before") === "before" && n.appendChild(W(u));
890
+ u.offset - e === l && (u.side ?? "before") === "before" && n.appendChild(G(u));
1060
891
  const c = t.slice(l, h);
1061
892
  if (!c)
1062
893
  continue;
@@ -1069,7 +900,7 @@ function te(n, t, e, s, i) {
1069
900
  }
1070
901
  }
1071
902
  if (f) {
1072
- const u = U.create(f);
903
+ const u = H.create(f);
1073
904
  if (f.attributes)
1074
905
  for (const [m, p] of Object.entries(f.attributes))
1075
906
  u.setAttribute(m, p);
@@ -1077,19 +908,19 @@ function te(n, t, e, s, i) {
1077
908
  } else
1078
909
  n.appendChild(document.createTextNode(c));
1079
910
  for (const u of i)
1080
- u.offset - e === h && u.side === "after" && n.appendChild(W(u));
911
+ u.offset - e === h && u.side === "after" && n.appendChild(G(u));
1081
912
  }
1082
913
  for (const a of i)
1083
- a.offset - e === t.length && (a.side ?? "before") === "before" && n.appendChild(W(a));
914
+ a.offset - e === t.length && (a.side ?? "before") === "before" && n.appendChild(G(a));
1084
915
  }
1085
- function W(n) {
1086
- const t = H.create();
916
+ function G(n) {
917
+ const t = K.create();
1087
918
  return t.appendChild(n.create()), t;
1088
919
  }
1089
- class ee {
920
+ class te {
1090
921
  constructor(t) {
1091
- const e = Qt();
1092
- this.scroll = new Q(e, t);
922
+ const e = Jt();
923
+ this.scroll = new tt(e, t);
1093
924
  }
1094
925
  /**
1095
926
  * Rebuild the document tree.
@@ -1116,7 +947,7 @@ class ee {
1116
947
  for (p.className = "line"; p.firstChild; )
1117
948
  p.removeChild(p.firstChild);
1118
949
  } else
1119
- p = z.create(), s.appendChild(p);
950
+ p = U.create(), s.appendChild(p);
1120
951
  const k = o.get(g) ?? [];
1121
952
  for (const v of k) {
1122
953
  if (v.className)
@@ -1126,13 +957,13 @@ class ee {
1126
957
  for (const [x, w] of Object.entries(v.attributes))
1127
958
  p.setAttribute(x, w);
1128
959
  }
1129
- const St = a.filter((v) => v.from < m && v.to > u), Lt = l.filter((v) => v.offset >= u && v.offset <= m);
1130
- te(p, f, u, St, Lt);
1131
- const q = k.filter((v) => v.message);
1132
- if (q.length > 0) {
1133
- const v = q.map((w) => w.message).join(" · "), x = [
960
+ const St = a.filter((v) => v.from < m && v.to > u), Ot = l.filter((v) => v.offset >= u && v.offset <= m);
961
+ Qt(p, f, u, St, Ot);
962
+ const F = k.filter((v) => v.message);
963
+ if (F.length > 0) {
964
+ const v = F.map((w) => w.message).join(" · "), x = [
1134
965
  ...new Set(
1135
- q.flatMap(
966
+ F.flatMap(
1136
967
  (w) => w.messageClassName ? w.messageClassName.split(/\s+/).filter(Boolean) : []
1137
968
  )
1138
969
  )
@@ -1150,12 +981,12 @@ class ee {
1150
981
  t.removeChild(t.firstChild);
1151
982
  }
1152
983
  }
1153
- function se(n) {
984
+ function ee(n) {
1154
985
  const t = Array.from(n.querySelectorAll(".line"));
1155
- return t.length > 0 ? t.map((e) => ie(e)).join(`
986
+ return t.length > 0 ? t.map((e) => se(e)).join(`
1156
987
  `) : yt(n);
1157
988
  }
1158
- function ie(n) {
989
+ function se(n) {
1159
990
  let t = "";
1160
991
  for (const e of n.childNodes)
1161
992
  t += bt(e);
@@ -1189,17 +1020,17 @@ function yt(n) {
1189
1020
  }
1190
1021
  return t;
1191
1022
  }
1192
- function $(n) {
1023
+ function R(n) {
1193
1024
  if (n.nodeType === Node.TEXT_NODE)
1194
1025
  return n.length;
1195
1026
  if (!(n instanceof Element) || n.classList.contains("widget") || n.tagName === "BR")
1196
1027
  return 0;
1197
1028
  let t = 0;
1198
1029
  for (const e of n.childNodes)
1199
- t += $(e);
1030
+ t += R(e);
1200
1031
  return t;
1201
1032
  }
1202
- function ot(n, t, e) {
1033
+ function $(n, t, e) {
1203
1034
  const s = Array.from(n.querySelectorAll(".line"));
1204
1035
  let i = 0;
1205
1036
  for (let r = 0; r < s.length; r++) {
@@ -1207,7 +1038,7 @@ function ot(n, t, e) {
1207
1038
  const o = s[r], a = Nt(o, t, e, i);
1208
1039
  if (a.found)
1209
1040
  return a.offset;
1210
- i += $(o);
1041
+ i += R(o);
1211
1042
  }
1212
1043
  return i;
1213
1044
  }
@@ -1218,7 +1049,7 @@ function Nt(n, t, e, s) {
1218
1049
  const i = Array.from(n.childNodes);
1219
1050
  let r = s;
1220
1051
  for (let o = 0; o < e && o < i.length; o++)
1221
- r += $(i[o]);
1052
+ r += R(i[o]);
1222
1053
  return { found: !0, offset: r };
1223
1054
  }
1224
1055
  if (n.nodeType === Node.TEXT_NODE)
@@ -1248,7 +1079,7 @@ function at(n, t) {
1248
1079
  return { node: e[r], offset: 0 };
1249
1080
  s--;
1250
1081
  }
1251
- const o = e[r], a = $(o);
1082
+ const o = e[r], a = R(o);
1252
1083
  if (s <= a) {
1253
1084
  const l = xt(o, s);
1254
1085
  return l || { node: o, offset: o.childNodes.length };
@@ -1268,7 +1099,7 @@ function xt(n, t) {
1268
1099
  return null;
1269
1100
  let e = 0;
1270
1101
  for (const s of n.childNodes) {
1271
- const i = $(s);
1102
+ const i = R(s);
1272
1103
  if (t <= i) {
1273
1104
  const r = xt(s, t);
1274
1105
  return r || { node: n, offset: e + 1 };
@@ -1278,17 +1109,27 @@ function xt(n, t) {
1278
1109
  }
1279
1110
  return null;
1280
1111
  }
1281
- function R(n) {
1282
- const e = n.getRootNode().getSelection?.() ?? window.getSelection();
1283
- if (!e || e.rangeCount === 0)
1284
- return null;
1285
- const s = e.getRangeAt(0);
1286
- if (!n.contains(s.commonAncestorContainer))
1112
+ function P(n) {
1113
+ const t = n.getRootNode(), e = t.getSelection, s = e?.call(t) ?? window.getSelection();
1114
+ if (!s || s.rangeCount === 0)
1287
1115
  return null;
1288
- const i = ot(n, s.startContainer, s.startOffset), r = ot(n, s.endContainer, s.endOffset);
1289
- return { anchorOffset: i, focusOffset: r };
1116
+ const i = s.getRangeAt(0);
1117
+ if (n.contains(i.commonAncestorContainer))
1118
+ return {
1119
+ anchorOffset: $(n, i.startContainer, i.startOffset),
1120
+ focusOffset: $(n, i.endContainer, i.endOffset)
1121
+ };
1122
+ if (!e && t instanceof ShadowRoot && typeof s.getComposedRanges == "function") {
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;
1290
1131
  }
1291
- function re(n, t) {
1132
+ function ie(n, t) {
1292
1133
  const e = at(n, t.anchorOffset), s = at(n, t.focusOffset);
1293
1134
  if (!(!e || !s))
1294
1135
  try {
@@ -1300,7 +1141,7 @@ function re(n, t) {
1300
1141
  } catch {
1301
1142
  }
1302
1143
  }
1303
- function P() {
1144
+ function M() {
1304
1145
  return crypto.randomUUID();
1305
1146
  }
1306
1147
  function wt(n, t) {
@@ -1324,15 +1165,15 @@ function lt(n, t, e) {
1324
1165
  );
1325
1166
  return r >= o ? null : { from: r, to: o };
1326
1167
  }
1327
- function ne(n, t) {
1168
+ function re(n, t) {
1328
1169
  let e = 0;
1329
1170
  for (let s = 0; s < t && s < n.length; s++)
1330
1171
  n[s] === `
1331
1172
  ` && e++;
1332
1173
  return e;
1333
1174
  }
1334
- function oe(n, t, e) {
1335
- 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 = ne(t, s.start) + 1, f = c + a, g = [];
1175
+ function ne(n, t, e) {
1176
+ 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 = [];
1336
1177
  for (const u of n)
1337
1178
  if (u.type === "mark") {
1338
1179
  const m = lt(u.from, u.to, s);
@@ -1345,28 +1186,28 @@ function oe(n, t, e) {
1345
1186
  }
1346
1187
  return g;
1347
1188
  }
1348
- function ae(n, t) {
1189
+ function oe(n, t) {
1349
1190
  if (n.length === 0)
1350
1191
  return !1;
1351
1192
  const e = Math.max(t.removed, t.inserted);
1352
1193
  return e > 50 && e > n.length * 0.5;
1353
1194
  }
1354
- function G(n, t, e) {
1195
+ function j(n, t, e) {
1355
1196
  const s = wt(t, e);
1356
- return ae(t, s) ? [] : oe(n, t, e);
1197
+ return oe(t, s) ? [] : ne(n, t, e);
1357
1198
  }
1358
1199
  function ct(n, t) {
1359
1200
  const e = crypto.randomUUID();
1360
1201
  return n.set(e, { ...t, id: e }), e;
1361
1202
  }
1362
- function le(n, t) {
1203
+ function ae(n, t) {
1363
1204
  n.clear();
1364
1205
  for (const e of t) {
1365
1206
  const s = crypto.randomUUID();
1366
1207
  n.set(s, { ...e, id: s });
1367
1208
  }
1368
1209
  }
1369
- function ce(n, t) {
1210
+ function le(n, t) {
1370
1211
  const e = [], s = [];
1371
1212
  for (const i of t) {
1372
1213
  let r = i.pattern.flags.includes("g") ? i.pattern.flags : i.pattern.flags + "g";
@@ -1417,13 +1258,182 @@ function ce(n, t) {
1417
1258
  }
1418
1259
  return { markDecorations: e, lineDecorations: s };
1419
1260
  }
1261
+ const ce = Lt`
1262
+ :host {
1263
+ display: block;
1264
+ box-sizing: border-box;
1265
+ color-scheme: inherit;
1266
+ }
1267
+
1268
+ :host([hidden]) {
1269
+ display: none;
1270
+ }
1271
+
1272
+ #root {
1273
+ display: flex;
1274
+ align-items: stretch;
1275
+ border: var(--rc-textarea-border, 1px solid ButtonBorder);
1276
+ border-radius: var(--rc-textarea-border-radius, 2px);
1277
+ background: var(--rc-textarea-background, Field);
1278
+ color: var(--rc-textarea-color, var(--rc-text, FieldText));
1279
+ overflow: hidden;
1280
+ min-height: var(--_rc-textarea-min-height, auto);
1281
+ }
1282
+
1283
+ #gutter {
1284
+ display: none;
1285
+ flex-shrink: 0;
1286
+ background: var(--rc-textarea-gutter-bg, Canvas);
1287
+ color: var(--rc-textarea-gutter-color, GrayText);
1288
+ border-right: var(--rc-textarea-gutter-border, 1px solid ButtonBorder);
1289
+ overflow: hidden;
1290
+ user-select: none;
1291
+ }
1292
+
1293
+ :host([line-numbers]) #gutter,
1294
+ :host([list-numbers]) #gutter,
1295
+ :host([gutter]) #gutter {
1296
+ display: block;
1297
+ }
1298
+
1299
+ #gutter-cells {
1300
+ padding: var(--rc-textarea-padding, 0.5em);
1301
+ padding-inline-end: var(--rc-textarea-gutter-padding-inline-end, 0.75em);
1302
+ font-family: var(--rc-textarea-gutter-font-family, var(--rc-textarea-font-family, monospace));
1303
+ font-size: var(--rc-textarea-font-size, 1em);
1304
+ line-height: var(--rc-textarea-line-height, 1.5);
1305
+ text-align: right;
1306
+ min-width: 2.5ch;
1307
+ }
1308
+
1309
+ .gutter-cell {
1310
+ display: block;
1311
+ white-space: pre;
1312
+ }
1313
+
1314
+ .gutter-cell--active {
1315
+ color: var(--rc-textarea-color, var(--rc-text, FieldText));
1316
+ }
1317
+
1318
+ #editor-area {
1319
+ position: relative;
1320
+ flex: 1;
1321
+ min-width: 0;
1322
+ overflow: hidden;
1323
+ }
1324
+
1325
+ #editor {
1326
+ position: relative;
1327
+ z-index: 1;
1328
+ width: 100%;
1329
+ min-height: 100%;
1330
+ box-sizing: border-box;
1331
+ padding: var(--rc-textarea-padding, 0.5em);
1332
+ font-family: var(--rc-textarea-font-family, monospace);
1333
+ font-size: var(--rc-textarea-font-size, 1em);
1334
+ line-height: var(--rc-textarea-line-height, 1.5);
1335
+ color: var(--rc-textarea-color, var(--rc-text, FieldText));
1336
+ caret-color: var(--rc-textarea-caret-color, var(--rc-textarea-color, FieldText));
1337
+ background: transparent;
1338
+ outline: none;
1339
+ overflow: auto;
1340
+ resize: none;
1341
+ white-space: pre;
1342
+ word-break: normal;
1343
+ overflow-wrap: normal;
1344
+ tab-size: 4;
1345
+ word-break: normal;
1346
+ /* Prevent contenteditable from injecting <div> wrappers on Enter in some browsers */
1347
+ -webkit-user-modify: read-write-plaintext-only;
1348
+ }
1349
+
1350
+ :host([word-wrap]) #editor {
1351
+ white-space: pre-wrap;
1352
+ overflow-wrap: break-word;
1353
+ word-break: normal;
1354
+ }
1355
+
1356
+ :host([auto-grow]) #editor {
1357
+ overflow: visible;
1358
+ height: auto;
1359
+ }
1360
+
1361
+ :host([auto-grow]) #root {
1362
+ height: auto;
1363
+ }
1364
+
1365
+ :host([read-only]) #root {
1366
+ border: none;
1367
+ background: transparent;
1368
+ border-radius: 0;
1369
+ }
1370
+
1371
+ :host([read-only]) #editor {
1372
+ cursor: default;
1373
+ padding: 0;
1374
+ -webkit-user-modify: read-only;
1375
+ }
1376
+
1377
+ /* Focus ring on the root when editor is focused */
1378
+ #root:has(#editor:focus) {
1379
+ outline: var(--rc-textarea-focus-outline, 2px solid Highlight);
1380
+ outline-offset: -1px;
1381
+ }
1382
+
1383
+ /* Slotted textarea is hidden on host upgrade */
1384
+ ::slotted(textarea) {
1385
+ position: absolute !important;
1386
+ width: 1px !important;
1387
+ height: 1px !important;
1388
+ padding: 0 !important;
1389
+ margin: -1px !important;
1390
+ overflow: hidden !important;
1391
+ clip: rect(0, 0, 0, 0) !important;
1392
+ border: 0 !important;
1393
+ opacity: 0 !important;
1394
+ pointer-events: none !important;
1395
+ }
1396
+
1397
+ .line {
1398
+ position: relative;
1399
+ display: block;
1400
+ }
1401
+
1402
+ /* Active line highlight — opt-in via CSS custom property. */
1403
+ .line--active {
1404
+ background: var(--rc-textarea-active-line-bg, transparent);
1405
+ }
1406
+
1407
+ /* Error-lens -style end-of-line diagnostic message */
1408
+ .line[data-message]::after {
1409
+ content: attr(data-message);
1410
+ display: inline;
1411
+ margin-left: 4ch;
1412
+ white-space: nowrap;
1413
+ pointer-events: none;
1414
+ font-size: 0.875em;
1415
+ opacity: 0.8;
1416
+ font-style: italic;
1417
+ }
1418
+
1419
+ .mark {
1420
+ border-radius: 2px;
1421
+ }
1422
+
1423
+ .widget {
1424
+ display: inline-block;
1425
+ user-select: none;
1426
+ cursor: default;
1427
+ vertical-align: middle;
1428
+ }
1429
+ `;
1420
1430
  var he = Object.defineProperty, ue = Object.getOwnPropertyDescriptor, b = (n, t, e, s) => {
1421
1431
  for (var i = s > 1 ? void 0 : s ? ue(t, e) : t, r = n.length - 1, o; r >= 0; r--)
1422
1432
  (o = n[r]) && (i = (s ? o(t, e, i) : o(i)) || i);
1423
1433
  return s && i && he(t, e, i), i;
1424
1434
  };
1425
1435
  const de = 100;
1426
- function j(n) {
1436
+ function X(n) {
1427
1437
  const t = document.createElement("div");
1428
1438
  t.innerHTML = n;
1429
1439
  const e = [];
@@ -1449,7 +1459,7 @@ function j(n) {
1449
1459
  i(r);
1450
1460
  return e;
1451
1461
  }
1452
- const K = class K extends st {
1462
+ const V = class V extends it {
1453
1463
  constructor() {
1454
1464
  super(...arguments), this.lineNumbers = !1, this._listNumbers = !1, this.gutter = !1, this.wordWrap = !1, this.autoGrow = !1, this.readOnly = !1, this._label = null, this._value = "", this._initialValueResolved = !1, this._valueSetByHost = !1, this._document = null, this._$textareaRef = null, this._textareaController = new kt(this, {
1455
1465
  selector: ":scope > textarea",
@@ -1463,10 +1473,13 @@ const K = class K extends st {
1463
1473
  this._$editor && this._$editor.setAttribute("aria-invalid", "true");
1464
1474
  }, this._onInputEvent = () => {
1465
1475
  this._composing || this._onInput();
1476
+ }, this._onBeforeInput = (t) => {
1477
+ !this._composing && !t.isComposing && (t.inputType === "insertParagraph" || t.inputType === "insertLineBreak") && (t.preventDefault(), this._insertText(`
1478
+ `));
1466
1479
  }, this._onSelectionChange = () => {
1467
1480
  if (!this._$editor)
1468
1481
  return;
1469
- const t = R(this._$editor);
1482
+ const t = P(this._$editor);
1470
1483
  if (t) {
1471
1484
  this._savedSelection = t, this.dispatchEvent(
1472
1485
  new CustomEvent("rc-textarea-select", {
@@ -1483,6 +1496,11 @@ const K = class K extends st {
1483
1496
  i(e, s);
1484
1497
  }
1485
1498
  }, this._onKeyDown = (t) => {
1499
+ if (t.key === "Enter" && !this._composing && !t.isComposing) {
1500
+ t.preventDefault(), this._insertText(`
1501
+ `);
1502
+ return;
1503
+ }
1486
1504
  if (t.key === "Tab" && !t.ctrlKey && !t.metaKey && !t.altKey) {
1487
1505
  t.preventDefault(), this._insertText(" ");
1488
1506
  return;
@@ -1530,7 +1548,7 @@ const K = class K extends st {
1530
1548
  /** Declarative plugin hook for framework integrations. */
1531
1549
  set plugin(t) {
1532
1550
  const e = this._pluginProperty;
1533
- t !== e && (this._pluginProperty = t, t ? this.usePlugin(t) : this.removePlugin(), this.requestUpdate("plugin", e));
1551
+ t !== e && (this._pluginProperty = t, t && this.isConnected ? this.usePlugin(t) : t || this.removePlugin(), this.requestUpdate("plugin", e));
1534
1552
  }
1535
1553
  get decorations() {
1536
1554
  return this._externalDecorations;
@@ -1553,13 +1571,13 @@ const K = class K extends st {
1553
1571
  this._defaultValue = t, !this._valueSetByHost && !this._initialValueResolved && t !== void 0 && (this._value = t, this._initialValueResolved = !0, this._syncTextareaValue(), this._scheduleRender()), this.requestUpdate("defaultValue", e);
1554
1572
  }
1555
1573
  connectedCallback() {
1556
- super.connectedCallback(), document.addEventListener("selectionchange", this._docSelectionChangeHandler);
1574
+ super.connectedCallback(), this._pluginProperty && !this._plugin && this.usePlugin(this._pluginProperty), document.addEventListener("selectionchange", this._docSelectionChangeHandler);
1557
1575
  }
1558
1576
  disconnectedCallback() {
1559
1577
  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);
1560
1578
  }
1561
1579
  firstUpdated() {
1562
- this._$editor && (this._document = new ee(this._$editor), this._bindEditorEvents(this._$editor)), this._resizeObserver = new ResizeObserver(() => {
1580
+ this._$editor && (this._document = new te(this._$editor), this._bindEditorEvents(this._$editor)), this._resizeObserver = new ResizeObserver(() => {
1563
1581
  this._syncGutter(), this._syncGutterHeights();
1564
1582
  }), this._resizeObserver.observe(this), this._scheduleRender();
1565
1583
  }
@@ -1622,7 +1640,7 @@ const K = class K extends st {
1622
1640
  this._composing = !0;
1623
1641
  }), t.addEventListener("compositionend", () => {
1624
1642
  this._composing = !1, this._onInput();
1625
- }), t.addEventListener("input", this._onInputEvent), t.addEventListener("keydown", this._onKeyDown), t.addEventListener("paste", this._onPaste), t.addEventListener("focus", () => {
1643
+ }), t.addEventListener("beforeinput", this._onBeforeInput), t.addEventListener("input", this._onInputEvent), t.addEventListener("keydown", this._onKeyDown), t.addEventListener("paste", this._onPaste), t.addEventListener("focus", () => {
1626
1644
  this.dispatchEvent(
1627
1645
  new CustomEvent("rc-textarea-focus", {
1628
1646
  bubbles: !0,
@@ -1641,10 +1659,10 @@ const K = class K extends st {
1641
1659
  _onInput() {
1642
1660
  if (!this._$editor)
1643
1661
  return;
1644
- const t = se(this._$editor);
1662
+ const t = ee(this._$editor);
1645
1663
  if (t === this._value)
1646
1664
  return;
1647
- const e = this._value, s = this._savedSelection, i = G(
1665
+ const e = this._value, s = this._savedSelection, i = j(
1648
1666
  [...this._pluginDecorations.values()],
1649
1667
  e,
1650
1668
  t
@@ -1652,7 +1670,7 @@ const K = class K extends st {
1652
1670
  this._pluginDecorations.clear();
1653
1671
  for (const r of i)
1654
1672
  this._pluginDecorations.set(r.id, r);
1655
- this._value = t, this._syncTextareaValue(!0), this._savedSelection = R(this._$editor), this._undoStack.length === 0 && (this._undoStack.push({
1673
+ this._value = t, this._syncTextareaValue(!0), this._savedSelection = P(this._$editor), this._undoStack.length === 0 && (this._undoStack.push({
1656
1674
  value: e,
1657
1675
  anchorOffset: s?.anchorOffset ?? 0,
1658
1676
  focusOffset: s?.focusOffset ?? 0
@@ -1695,7 +1713,7 @@ const K = class K extends st {
1695
1713
  if (this._$editor) {
1696
1714
  if (t.includes(`
1697
1715
  `)) {
1698
- const e = R(this._$editor) ?? this._savedSelection, s = Math.min(e?.anchorOffset ?? 0, e?.focusOffset ?? 0), i = Math.max(e?.anchorOffset ?? 0, e?.focusOffset ?? 0), r = this._value, o = r.slice(0, s) + t + r.slice(i), a = s + t.length, l = G(
1716
+ const e = P(this._$editor) ?? this._savedSelection, s = Math.min(e?.anchorOffset ?? 0, e?.focusOffset ?? 0), i = Math.max(e?.anchorOffset ?? 0, e?.focusOffset ?? 0), r = this._value, o = r.slice(0, s) + t + r.slice(i), a = s + t.length, l = j(
1699
1717
  [...this._pluginDecorations.values()],
1700
1718
  r,
1701
1719
  o
@@ -1728,10 +1746,10 @@ const K = class K extends st {
1728
1746
  wrapSelection(t, e) {
1729
1747
  if (!this._$editor)
1730
1748
  return;
1731
- const s = R(this._$editor) ?? this._savedSelection;
1749
+ const s = P(this._$editor) ?? this._savedSelection;
1732
1750
  if (!s || s.anchorOffset === s.focusOffset)
1733
1751
  return;
1734
- const i = Math.min(s.anchorOffset, s.focusOffset), r = Math.max(s.anchorOffset, s.focusOffset), o = this._value.slice(i, r), a = this._value, l = a.slice(0, i) + t + o + e + a.slice(r), h = G(
1752
+ const i = Math.min(s.anchorOffset, s.focusOffset), r = Math.max(s.anchorOffset, s.focusOffset), o = this._value.slice(i, r), a = this._value, l = a.slice(0, i) + t + o + e + a.slice(r), h = j(
1735
1753
  [...this._pluginDecorations.values()],
1736
1754
  a,
1737
1755
  l
@@ -1849,7 +1867,7 @@ const K = class K extends st {
1849
1867
  t._pluginDecorations.clear();
1850
1868
  },
1851
1869
  setDecorations(e) {
1852
- le(t._pluginDecorations, e);
1870
+ ae(t._pluginDecorations, e);
1853
1871
  },
1854
1872
  getDecorations() {
1855
1873
  return [...t._pluginDecorations.values()];
@@ -1870,11 +1888,11 @@ const K = class K extends st {
1870
1888
  )), t._pluginSheets.delete(e);
1871
1889
  },
1872
1890
  parseDecorationsFromHtml(e) {
1873
- return j(e);
1891
+ return X(e);
1874
1892
  },
1875
1893
  /** @deprecated Use `parseDecorationsFromHtml` instead. */
1876
1894
  decorationsFromHtml(e) {
1877
- return j(e);
1895
+ return X(e);
1878
1896
  },
1879
1897
  decorationsFromTokens(e, s) {
1880
1898
  const i = [];
@@ -1911,9 +1929,14 @@ const K = class K extends st {
1911
1929
  /**
1912
1930
  * Register a text pattern that generates decorations on every render pass.
1913
1931
  * Returns the pattern ID, which can be passed to `removePattern` to unregister it.
1932
+ *
1933
+ * @example
1934
+ * const id = editor.addPattern({ pattern: /TODO/g, className: 'highlight-todo' });
1935
+ * // Later:
1936
+ * editor.removePattern(id);
1914
1937
  */
1915
1938
  addPattern(t) {
1916
- const e = P();
1939
+ const e = M();
1917
1940
  return this._patterns.set(e, { ...t, id: e }), this._scheduleRender(), e;
1918
1941
  }
1919
1942
  /** Remove a previously registered pattern by the ID returned from `addPattern`. */
@@ -1940,13 +1963,13 @@ const K = class K extends st {
1940
1963
  const o = this._plugin.transform(this._value, this._pluginApi);
1941
1964
  typeof o == "string" && (e = o);
1942
1965
  }
1943
- const { markDecorations: s, lineDecorations: i } = ce(
1966
+ const { markDecorations: s, lineDecorations: i } = le(
1944
1967
  e,
1945
1968
  [...this._patterns.values()]
1946
1969
  );
1947
1970
  if (this._patternDecorations = [
1948
- ...s.map((o) => ({ ...o, id: P() })),
1949
- ...i.map((o) => ({ ...o, id: P() }))
1971
+ ...s.map((o) => ({ ...o, id: M() })),
1972
+ ...i.map((o) => ({ ...o, id: M() }))
1950
1973
  ], this._plugin && this._pluginApi) {
1951
1974
  const o = this._pluginApi;
1952
1975
  if (this._plugin.update && (await this._plugin.update(e, o), t !== this._pluginSeq))
@@ -1956,7 +1979,7 @@ const K = class K extends st {
1956
1979
  if (t !== this._pluginSeq)
1957
1980
  return;
1958
1981
  if (typeof a == "string") {
1959
- const l = j(a);
1982
+ const l = X(a);
1960
1983
  for (const h of l)
1961
1984
  ct(this._pluginDecorations, h);
1962
1985
  }
@@ -1965,11 +1988,11 @@ const K = class K extends st {
1965
1988
  const r = [
1966
1989
  ...this._pluginDecorations.values(),
1967
1990
  ...this._patternDecorations,
1968
- ...this._externalDecorations.map((o) => ({ ...o, id: P() }))
1991
+ ...this._externalDecorations.map((o) => ({ ...o, id: M() }))
1969
1992
  ];
1970
1993
  if (!this._$editor)
1971
1994
  return;
1972
- this._document.build(e, r), this._savedSelection && re(this._$editor, this._savedSelection), this._$activeLine = null, this._updateActiveLine(), this._syncGutter(this._computeGutterLabels(r, e)), this._syncGutterHeights();
1995
+ this._document.build(e, r), this._savedSelection && ie(this._$editor, this._savedSelection), this._$activeLine = null, this._updateActiveLine(), this._syncGutter(this._computeGutterLabels(r, e)), this._syncGutterHeights();
1973
1996
  } finally {
1974
1997
  this._isRendering = !1;
1975
1998
  }
@@ -2103,11 +2126,11 @@ const K = class K extends st {
2103
2126
  );
2104
2127
  }
2105
2128
  };
2106
- K.styles = Bt, K.shadowRootOptions = {
2107
- ...st.shadowRootOptions,
2129
+ V.styles = ce, V.shadowRootOptions = {
2130
+ ...it.shadowRootOptions,
2108
2131
  delegatesFocus: !0
2109
2132
  };
2110
- let _ = K;
2133
+ let _ = V;
2111
2134
  b([
2112
2135
  y({ type: Boolean, attribute: "line-numbers", reflect: !0 })
2113
2136
  ], _.prototype, "lineNumbers", 2);
@@ -2136,19 +2159,19 @@ b([
2136
2159
  y({ attribute: !1 })
2137
2160
  ], _.prototype, "decorations", 1);
2138
2161
  b([
2139
- tt("#editor")
2162
+ et("#editor")
2140
2163
  ], _.prototype, "_$editor", 2);
2141
2164
  b([
2142
- tt("#gutter-cells")
2165
+ et("#gutter-cells")
2143
2166
  ], _.prototype, "_$gutterCells", 2);
2144
2167
  b([
2145
- tt("slot")
2168
+ et("slot")
2146
2169
  ], _.prototype, "_$slot", 2);
2147
2170
  b([
2148
2171
  y({ type: String })
2149
2172
  ], _.prototype, "value", 1);
2150
2173
  b([
2151
- y({ type: String })
2174
+ y({ type: String, attribute: "default-value" })
2152
2175
  ], _.prototype, "defaultValue", 1);
2153
2176
  function we(n, t = {}) {
2154
2177
  const e = [];
@@ -2370,6 +2393,6 @@ export {
2370
2393
  Ct as L,
2371
2394
  _ as R,
2372
2395
  we as c,
2373
- ce as m
2396
+ le as m
2374
2397
  };
2375
- //# sourceMappingURL=line-actions-controller-x4P2Yjd4.js.map
2398
+ //# sourceMappingURL=line-actions-controller-TP6g5HYk.js.map