@markput/react 0.3.0 → 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.
- package/README.md +5 -2
- package/index.js +408 -388
- package/package.json +15 -15
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./index.css";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { jsxs as Z, jsx as f, Fragment as wt } from "react/jsx-runtime";
|
|
3
|
+
import { useState as P, useEffect as M, useImperativeHandle as St, createContext as at, useContext as ct, memo as O, useRef as $, useCallback as k, useMemo as S, useLayoutEffect as Ct } from "react";
|
|
4
4
|
function bt(s) {
|
|
5
5
|
if (s == null) throw new Error("Value must be a non nullable!");
|
|
6
6
|
}
|
|
@@ -16,8 +16,8 @@ function Nt(...s) {
|
|
|
16
16
|
const t = Object.assign({}, ...s.filter(Boolean));
|
|
17
17
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
18
18
|
}
|
|
19
|
-
var
|
|
20
|
-
const It = "@", Pt = "@[__value__](__meta__)",
|
|
19
|
+
var v = /* @__PURE__ */ ((s) => (s.UP = "ArrowUp", s.DOWN = "ArrowDown", s.LEFT = "ArrowLeft", s.RIGHT = "ArrowRight", s.END = "End", s.HOME = "Home", s.PAGE_DOWN = "PageDown", s.PAGE_UP = "PageUp", s.ENTER = "Enter", s.TAB = "Tab", s.SPACE = " ", s.BACKSPACE = "Backspace", s.DELETE = "Delete", s.COMMA = ",", s.ESC = "Escape", s))(v || {});
|
|
20
|
+
const It = "@", Pt = "@[__value__](__meta__)", x = {
|
|
21
21
|
Value: "__value__",
|
|
22
22
|
Meta: "__meta__",
|
|
23
23
|
Nested: "__nested__"
|
|
@@ -69,22 +69,22 @@ function Lt(s) {
|
|
|
69
69
|
}
|
|
70
70
|
function At(s, t) {
|
|
71
71
|
const e = [
|
|
72
|
-
{ count: s.value, max: 2, name:
|
|
73
|
-
{ count: s.meta, max: 1, name:
|
|
74
|
-
{ count: s.nested, max: 1, name:
|
|
72
|
+
{ count: s.value, max: 2, name: x.Value },
|
|
73
|
+
{ count: s.meta, max: 1, name: x.Meta },
|
|
74
|
+
{ count: s.nested, max: 1, name: x.Nested }
|
|
75
75
|
];
|
|
76
76
|
for (const { count: n, max: r, name: o } of e)
|
|
77
77
|
if (n > r)
|
|
78
78
|
throw new Error(`Invalid markup: "${t}". Max ${r} "${o}" placeholders, got ${n}`);
|
|
79
79
|
if (s.value === 0 && s.nested === 0)
|
|
80
80
|
throw new Error(
|
|
81
|
-
`Invalid markup: "${t}". Need at least one "${
|
|
81
|
+
`Invalid markup: "${t}". Need at least one "${x.Value}" or "${x.Nested}"`
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
const nt = {
|
|
85
|
-
[N.Value]:
|
|
86
|
-
[N.Meta]:
|
|
87
|
-
[N.Nested]:
|
|
85
|
+
[N.Value]: x.Value,
|
|
86
|
+
[N.Meta]: x.Meta,
|
|
87
|
+
[N.Nested]: x.Nested
|
|
88
88
|
};
|
|
89
89
|
function Ot(s, t, e) {
|
|
90
90
|
if (e.length !== 2)
|
|
@@ -97,10 +97,10 @@ function Ot(s, t, e) {
|
|
|
97
97
|
c && l && o.push(g(c, l, s[r + 2]));
|
|
98
98
|
const d = t.filter((u) => u !== N.Value);
|
|
99
99
|
return { segments: o, gapTypes: d };
|
|
100
|
-
function g(u, h,
|
|
101
|
-
if (!
|
|
102
|
-
const C =
|
|
103
|
-
return [u, h,
|
|
100
|
+
function g(u, h, m) {
|
|
101
|
+
if (!m) return [u, h, ""];
|
|
102
|
+
const C = m.charAt(0), y = C && !h.includes(C) && !m.startsWith(u) ? C : "";
|
|
103
|
+
return [u, h, y];
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
class Dt {
|
|
@@ -168,7 +168,7 @@ function lt(s, t) {
|
|
|
168
168
|
e = e * 33 ^ t.charCodeAt(n);
|
|
169
169
|
return e = e >>> 0, s * 1e6 + (e & 1048575);
|
|
170
170
|
}
|
|
171
|
-
class
|
|
171
|
+
class Rt {
|
|
172
172
|
constructor(t, e) {
|
|
173
173
|
if (this.descriptor = t, this.expectedSegmentIndex = 1, this.start = e.start, this.end = e.end, t.segments.length === 1 && (this.expectedSegmentIndex = NaN, this.gaps.value = { start: this.start, end: this.end }), t.hasTwoValues && e.captured) {
|
|
174
174
|
this.captured = e.captured;
|
|
@@ -237,7 +237,7 @@ class _t {
|
|
|
237
237
|
return !t || this.start >= t.end ? !1 : !t.descriptor.hasNested || t.gaps.nested === void 0 ? !0 : !(this.start >= t.gaps.nested.start && this.end <= t.gaps.nested.end);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
class
|
|
240
|
+
class _t {
|
|
241
241
|
constructor(t) {
|
|
242
242
|
this.registry = t;
|
|
243
243
|
}
|
|
@@ -266,7 +266,7 @@ class Rt {
|
|
|
266
266
|
}
|
|
267
267
|
tryStartNewStates(t) {
|
|
268
268
|
this.registry.firstSegmentIndexMap.get(t.index)?.forEach((e) => {
|
|
269
|
-
const n = new
|
|
269
|
+
const n = new Rt(e, t);
|
|
270
270
|
if (!n.isInvalid) {
|
|
271
271
|
if (n.isCompleted) return this.addToCompleted(n);
|
|
272
272
|
this.addToWaiting(n);
|
|
@@ -312,11 +312,11 @@ class Rt {
|
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
const A = (s) => s.replace(/[.*+?^${}()|[\]\\\\]/g, "\\$&");
|
|
315
|
-
function
|
|
315
|
+
function Bt(s, t, e) {
|
|
316
316
|
const n = A(s), r = A(t), o = A(t + e);
|
|
317
317
|
return `${n}([^${o}]+?)${r}`;
|
|
318
318
|
}
|
|
319
|
-
class
|
|
319
|
+
class Vt {
|
|
320
320
|
staticRegex;
|
|
321
321
|
staticToIndex;
|
|
322
322
|
dynamicRegex;
|
|
@@ -342,7 +342,7 @@ class $t {
|
|
|
342
342
|
else {
|
|
343
343
|
const [l, d, g] = a;
|
|
344
344
|
o.add(c);
|
|
345
|
-
const h =
|
|
345
|
+
const h = Bt(l, d, g).replace("(", `(?<content${c}>`);
|
|
346
346
|
i.push({ index: c, pattern: h, definition: a });
|
|
347
347
|
}
|
|
348
348
|
}), i.sort((a, c) => {
|
|
@@ -395,7 +395,7 @@ const dt = (s, t = 0, e = s.length) => ({
|
|
|
395
395
|
content: s.substring(t, e),
|
|
396
396
|
position: { start: t, end: e }
|
|
397
397
|
});
|
|
398
|
-
class
|
|
398
|
+
class $t {
|
|
399
399
|
// Instance fields - only what's needed for single pass
|
|
400
400
|
input;
|
|
401
401
|
// ===== PUBLIC API =====
|
|
@@ -528,9 +528,24 @@ class Ht {
|
|
|
528
528
|
};
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
|
+
function J(s, t) {
|
|
532
|
+
let e = "";
|
|
533
|
+
for (const n of s)
|
|
534
|
+
if (n.type === "text")
|
|
535
|
+
e += n.content;
|
|
536
|
+
else if (n.children.length > 0) {
|
|
537
|
+
const r = J(n.children, t), o = {
|
|
538
|
+
...n,
|
|
539
|
+
value: r
|
|
540
|
+
};
|
|
541
|
+
e += t(o);
|
|
542
|
+
} else
|
|
543
|
+
e += t(n);
|
|
544
|
+
return e;
|
|
545
|
+
}
|
|
531
546
|
function j(s, t) {
|
|
532
547
|
let e = s;
|
|
533
|
-
return t.value !== void 0 && (e = e.replaceAll(
|
|
548
|
+
return t.value !== void 0 && (e = e.replaceAll(x.Value, t.value)), t.meta !== void 0 && (e = e.replaceAll(x.Meta, t.meta)), t.nested !== void 0 && (e = e.replaceAll(x.Nested, t.nested)), e;
|
|
534
549
|
}
|
|
535
550
|
function I(s) {
|
|
536
551
|
let t = "";
|
|
@@ -539,7 +554,7 @@ function I(s) {
|
|
|
539
554
|
t += e.content;
|
|
540
555
|
continue;
|
|
541
556
|
}
|
|
542
|
-
const n = e.descriptor.markup, r = n.includes(
|
|
557
|
+
const n = e.descriptor.markup, r = n.includes(x.Nested) ? e.children.length > 0 ? I(e.children) : e.nested?.content : void 0;
|
|
543
558
|
t += j(n, {
|
|
544
559
|
value: e.value,
|
|
545
560
|
meta: e.meta,
|
|
@@ -548,22 +563,7 @@ function I(s) {
|
|
|
548
563
|
}
|
|
549
564
|
return t;
|
|
550
565
|
}
|
|
551
|
-
|
|
552
|
-
let e = "";
|
|
553
|
-
for (const n of s)
|
|
554
|
-
if (n.type === "text")
|
|
555
|
-
e += n.content;
|
|
556
|
-
else if (n.children.length > 0) {
|
|
557
|
-
const r = J(n.children, t), o = {
|
|
558
|
-
...n,
|
|
559
|
-
value: r
|
|
560
|
-
};
|
|
561
|
-
e += t(o);
|
|
562
|
-
} else
|
|
563
|
-
e += t(n);
|
|
564
|
-
return e;
|
|
565
|
-
}
|
|
566
|
-
class B {
|
|
566
|
+
class H {
|
|
567
567
|
registry;
|
|
568
568
|
segmentMatcher;
|
|
569
569
|
patternMatcher;
|
|
@@ -588,7 +588,7 @@ class B {
|
|
|
588
588
|
* ```
|
|
589
589
|
*/
|
|
590
590
|
constructor(t) {
|
|
591
|
-
this.registry = new Dt(t), this.segmentMatcher = new
|
|
591
|
+
this.registry = new Dt(t), this.segmentMatcher = new Vt(this.registry.segments), this.patternMatcher = new _t(this.registry), this.treeBuilder = new $t();
|
|
592
592
|
}
|
|
593
593
|
/**
|
|
594
594
|
* Parses text into tokens (static convenience method)
|
|
@@ -606,7 +606,7 @@ class B {
|
|
|
606
606
|
*/
|
|
607
607
|
static parse(t, e) {
|
|
608
608
|
const n = e?.markup;
|
|
609
|
-
return !n || n.length === 0 ? [dt(t)] : new
|
|
609
|
+
return !n || n.length === 0 ? [dt(t)] : new H(n).parse(t);
|
|
610
610
|
}
|
|
611
611
|
/**
|
|
612
612
|
* Converts tokens back to text (static convenience method)
|
|
@@ -738,9 +738,9 @@ class B {
|
|
|
738
738
|
return t.replaceAll(/\\(.)/g, "$1");
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
|
-
function
|
|
741
|
+
function He(s, t, e) {
|
|
742
742
|
if (!e.length) return s;
|
|
743
|
-
const n = new
|
|
743
|
+
const n = new H(e).parse(s);
|
|
744
744
|
return J(n, t);
|
|
745
745
|
}
|
|
746
746
|
function z(s, t, e = 0, n) {
|
|
@@ -752,7 +752,7 @@ function z(s, t, e = 0, n) {
|
|
|
752
752
|
}
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
|
-
function
|
|
755
|
+
function Ht(s = "", t = "") {
|
|
756
756
|
if (s === t) return {};
|
|
757
757
|
let e;
|
|
758
758
|
for (let r = 0; r < s.length; r++)
|
|
@@ -784,7 +784,7 @@ function Ft(s) {
|
|
|
784
784
|
return r.length === 1 ? n : n.toSpliced(t.index, 1, ...r);
|
|
785
785
|
}
|
|
786
786
|
function Wt(s) {
|
|
787
|
-
const t = s.state.value.get(), e = Gt(s), n =
|
|
787
|
+
const t = s.state.value.get(), e = Gt(s), n = Ht(s.state.previousValue.get(), t);
|
|
788
788
|
if (!n.left && !n.right)
|
|
789
789
|
return s.state.previousValue.set(t), s.state.tokens.get();
|
|
790
790
|
s.state.previousValue.set(t);
|
|
@@ -803,7 +803,7 @@ function Wt(s) {
|
|
|
803
803
|
return i.length === 1 ? r : r.toSpliced(o, 1, ...i);
|
|
804
804
|
}
|
|
805
805
|
default:
|
|
806
|
-
return
|
|
806
|
+
return R(s, t ?? "");
|
|
807
807
|
}
|
|
808
808
|
}
|
|
809
809
|
function G(s, ...t) {
|
|
@@ -813,7 +813,7 @@ function G(s, ...t) {
|
|
|
813
813
|
const o = n[r];
|
|
814
814
|
e += o.content;
|
|
815
815
|
}
|
|
816
|
-
return
|
|
816
|
+
return R(s, e);
|
|
817
817
|
}
|
|
818
818
|
function Gt(s) {
|
|
819
819
|
let t = 0;
|
|
@@ -822,7 +822,7 @@ function Gt(s) {
|
|
|
822
822
|
return t += r, t - r;
|
|
823
823
|
}) ?? [];
|
|
824
824
|
}
|
|
825
|
-
function
|
|
825
|
+
function R(s, t) {
|
|
826
826
|
const e = s.state.parser.get();
|
|
827
827
|
return e ? e.parse(t) : [
|
|
828
828
|
{
|
|
@@ -833,30 +833,30 @@ function _(s, t) {
|
|
|
833
833
|
];
|
|
834
834
|
}
|
|
835
835
|
const Ut = (s, t) => s === t;
|
|
836
|
-
class
|
|
837
|
-
#
|
|
838
|
-
#
|
|
836
|
+
class _ {
|
|
837
|
+
#e;
|
|
838
|
+
#t = /* @__PURE__ */ new Set();
|
|
839
839
|
#n;
|
|
840
840
|
constructor(t, e) {
|
|
841
|
-
this.#
|
|
841
|
+
this.#e = t, this.#n = e?.equals ?? Ut;
|
|
842
842
|
}
|
|
843
843
|
static event() {
|
|
844
|
-
return new
|
|
844
|
+
return new _(void 0, { equals: !1 });
|
|
845
845
|
}
|
|
846
846
|
get value() {
|
|
847
|
-
return this.#
|
|
847
|
+
return this.#e;
|
|
848
848
|
}
|
|
849
849
|
set value(t) {
|
|
850
|
-
(this.#n === !1 || !this.#n(this.#
|
|
850
|
+
(this.#n === !1 || !this.#n(this.#e, t)) && (this.#e = t, this.#t.forEach((e) => e(t)));
|
|
851
851
|
}
|
|
852
852
|
on(t) {
|
|
853
|
-
return this.#
|
|
853
|
+
return this.#t.add(t), () => this.#t.delete(t);
|
|
854
854
|
}
|
|
855
855
|
emit(t) {
|
|
856
|
-
arguments.length > 0 && (this.#
|
|
856
|
+
arguments.length > 0 && (this.#e = t), this.#t.forEach((e) => e(this.#e));
|
|
857
857
|
}
|
|
858
858
|
get() {
|
|
859
|
-
return this.#
|
|
859
|
+
return this.#e;
|
|
860
860
|
}
|
|
861
861
|
set(t) {
|
|
862
862
|
this.value = t;
|
|
@@ -869,7 +869,7 @@ function jt(s, t) {
|
|
|
869
869
|
function zt(s, t) {
|
|
870
870
|
const e = /* @__PURE__ */ new Map();
|
|
871
871
|
for (const n in s)
|
|
872
|
-
e.set(n, new
|
|
872
|
+
e.set(n, new _(s[n]));
|
|
873
873
|
return new Proxy(s, {
|
|
874
874
|
get(n, r) {
|
|
875
875
|
if (r === "set")
|
|
@@ -892,19 +892,19 @@ function qt(s) {
|
|
|
892
892
|
function Xt(s) {
|
|
893
893
|
const t = [], e = /* @__PURE__ */ new Map();
|
|
894
894
|
for (const n of t)
|
|
895
|
-
e.set(n,
|
|
895
|
+
e.set(n, _.event());
|
|
896
896
|
return new Proxy({}, {
|
|
897
897
|
get(n, r) {
|
|
898
898
|
let o = e.get(r);
|
|
899
|
-
return o || (o =
|
|
899
|
+
return o || (o = _.event(), e.set(r, o)), qt(o);
|
|
900
900
|
}
|
|
901
901
|
});
|
|
902
902
|
}
|
|
903
903
|
class Zt {
|
|
904
|
-
#
|
|
905
|
-
#
|
|
904
|
+
#e = 1;
|
|
905
|
+
#t = /* @__PURE__ */ new WeakMap();
|
|
906
906
|
get(t) {
|
|
907
|
-
return this.#
|
|
907
|
+
return this.#t.has(t) ? this.#t.get(t) : (this.#t.set(t, this.#e), this.#e++);
|
|
908
908
|
}
|
|
909
909
|
}
|
|
910
910
|
class w {
|
|
@@ -1046,20 +1046,20 @@ class Q {
|
|
|
1046
1046
|
return new RegExp(e);
|
|
1047
1047
|
}
|
|
1048
1048
|
}
|
|
1049
|
-
class
|
|
1050
|
-
#t;
|
|
1049
|
+
class B {
|
|
1051
1050
|
#e;
|
|
1051
|
+
#t;
|
|
1052
1052
|
get target() {
|
|
1053
|
-
return this.#
|
|
1053
|
+
return this.#e;
|
|
1054
1054
|
}
|
|
1055
1055
|
set target(t) {
|
|
1056
|
-
this.#
|
|
1056
|
+
this.#e = t;
|
|
1057
1057
|
}
|
|
1058
1058
|
get next() {
|
|
1059
|
-
return new
|
|
1059
|
+
return new B(this.target?.nextSibling, this.#t);
|
|
1060
1060
|
}
|
|
1061
1061
|
get prev() {
|
|
1062
|
-
return new
|
|
1062
|
+
return new B(this.target?.previousSibling, this.#t);
|
|
1063
1063
|
}
|
|
1064
1064
|
get isSpan() {
|
|
1065
1065
|
return this.index % 2 === 0;
|
|
@@ -1095,16 +1095,16 @@ class V {
|
|
|
1095
1095
|
this.target && (this.target.textContent = t ?? "");
|
|
1096
1096
|
}
|
|
1097
1097
|
get head() {
|
|
1098
|
-
return this.#
|
|
1098
|
+
return this.#t.refs.container?.firstChild;
|
|
1099
1099
|
}
|
|
1100
1100
|
get tail() {
|
|
1101
|
-
return this.#
|
|
1101
|
+
return this.#t.refs.container?.lastChild;
|
|
1102
1102
|
}
|
|
1103
1103
|
get isFocused() {
|
|
1104
1104
|
return this.target === document.activeElement;
|
|
1105
1105
|
}
|
|
1106
1106
|
constructor(t, e) {
|
|
1107
|
-
this.target = t, this.#
|
|
1107
|
+
this.target = t, this.#t = e;
|
|
1108
1108
|
}
|
|
1109
1109
|
setCaretToEnd() {
|
|
1110
1110
|
w.setCaretToEnd(this.target);
|
|
@@ -1145,16 +1145,16 @@ class Kt {
|
|
|
1145
1145
|
constructor(t) {
|
|
1146
1146
|
this.store = t;
|
|
1147
1147
|
}
|
|
1148
|
-
#t;
|
|
1149
1148
|
#e;
|
|
1149
|
+
#t;
|
|
1150
1150
|
#n;
|
|
1151
1151
|
enable() {
|
|
1152
|
-
this.#
|
|
1152
|
+
this.#e || (this.#e = this.store.events.change.on(() => {
|
|
1153
1153
|
const t = this.store.state.onChange.get();
|
|
1154
1154
|
if (!this.store.nodes.focus.target) return;
|
|
1155
1155
|
const e = this.store.state.tokens.get(), n = e[this.store.nodes.focus.index];
|
|
1156
1156
|
n.type === "text" ? n.content = this.store.nodes.focus.content : n.type === "mark" && (n.value = this.store.nodes.focus.content), t?.(I(e)), this.store.events.parse();
|
|
1157
|
-
}), this.#
|
|
1157
|
+
}), this.#t = this.store.events.delete.on((t) => {
|
|
1158
1158
|
if (!t) return;
|
|
1159
1159
|
const { token: e } = t, n = this.store.state.onChange.get(), r = this.store.state.tokens.get(), o = r.indexOf(e);
|
|
1160
1160
|
this.store.state.tokens.set(r.toSpliced(o, 1)), n?.(I(this.store.state.tokens.get()));
|
|
@@ -1184,80 +1184,31 @@ class Kt {
|
|
|
1184
1184
|
}));
|
|
1185
1185
|
}
|
|
1186
1186
|
disable() {
|
|
1187
|
-
this.#
|
|
1187
|
+
this.#e?.(), this.#t?.(), this.#n?.(), this.#e = void 0, this.#t = void 0, this.#n = void 0;
|
|
1188
1188
|
}
|
|
1189
1189
|
}
|
|
1190
1190
|
class Yt {
|
|
1191
1191
|
constructor(t) {
|
|
1192
1192
|
this.store = t;
|
|
1193
1193
|
}
|
|
1194
|
-
#t;
|
|
1195
1194
|
#e;
|
|
1196
|
-
#n;
|
|
1197
|
-
#s;
|
|
1198
|
-
#r;
|
|
1199
|
-
#o;
|
|
1200
|
-
#i;
|
|
1201
|
-
#a;
|
|
1202
|
-
enableTrigger(t, e) {
|
|
1203
|
-
if (this.#t) return;
|
|
1204
|
-
this.#t = this.store.events.clearOverlay.on(() => {
|
|
1205
|
-
e(void 0);
|
|
1206
|
-
}), this.#e = this.store.events.checkOverlay.on(() => {
|
|
1207
|
-
const r = Q.find(this.store.state.options.get(), t);
|
|
1208
|
-
e(r);
|
|
1209
|
-
}), this.#n = this.store.events.change.on(() => {
|
|
1210
|
-
const r = this.store.state.showOverlayOn.get(), o = "change";
|
|
1211
|
-
(r === o || Array.isArray(r) && r.includes(o)) && this.store.events.checkOverlay();
|
|
1212
|
-
}), this.#s = () => {
|
|
1213
|
-
const r = this.store.state.showOverlayOn.get(), o = "selectionChange";
|
|
1214
|
-
(r === o || Array.isArray(r) && r.includes(o)) && this.store.events.checkOverlay();
|
|
1215
|
-
}, this.#r = () => {
|
|
1216
|
-
document.addEventListener("selectionchange", this.#s);
|
|
1217
|
-
}, this.#o = () => {
|
|
1218
|
-
document.removeEventListener("selectionchange", this.#s);
|
|
1219
|
-
};
|
|
1220
|
-
const n = this.store.refs.container;
|
|
1221
|
-
n && (n.addEventListener("focusin", this.#r), n.addEventListener("focusout", this.#o));
|
|
1222
|
-
}
|
|
1223
|
-
enableClose() {
|
|
1224
|
-
this.#i || (this.#i = (t) => {
|
|
1225
|
-
t.key === x.ESC && this.store.events.clearOverlay();
|
|
1226
|
-
}, this.#a = (t) => {
|
|
1227
|
-
const e = t.target;
|
|
1228
|
-
this.store.refs.overlay?.contains(e) || this.store.refs.container?.contains(e) || this.store.events.clearOverlay();
|
|
1229
|
-
}, window.addEventListener("keydown", this.#i), document.addEventListener("click", this.#a, !0));
|
|
1230
|
-
}
|
|
1231
|
-
disableClose() {
|
|
1232
|
-
this.#i && (window.removeEventListener("keydown", this.#i), document.removeEventListener("click", this.#a, !0), this.#i = void 0, this.#a = void 0);
|
|
1233
|
-
}
|
|
1234
|
-
disable() {
|
|
1235
|
-
const t = this.store.refs.container;
|
|
1236
|
-
t && this.#r && (t.removeEventListener("focusin", this.#r), t.removeEventListener("focusout", this.#o)), this.#s && document.removeEventListener("selectionchange", this.#s), this.disableClose(), this.#t?.(), this.#e?.(), this.#n?.(), this.#t = void 0, this.#e = void 0, this.#n = void 0, this.#s = void 0, this.#r = void 0, this.#o = void 0;
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
class te {
|
|
1240
|
-
constructor(t) {
|
|
1241
|
-
this.store = t;
|
|
1242
|
-
}
|
|
1243
1195
|
#t;
|
|
1244
|
-
#e;
|
|
1245
1196
|
#n;
|
|
1246
1197
|
enable() {
|
|
1247
|
-
if (this.#
|
|
1198
|
+
if (this.#e) return;
|
|
1248
1199
|
const t = this.store.refs.container;
|
|
1249
|
-
t && (this.#
|
|
1200
|
+
t && (this.#e = (e) => {
|
|
1250
1201
|
this.store.nodes.focus.target = e.target;
|
|
1251
|
-
}, this.#
|
|
1202
|
+
}, this.#t = () => {
|
|
1252
1203
|
this.store.nodes.focus.target = void 0;
|
|
1253
1204
|
}, this.#n = () => {
|
|
1254
1205
|
const e = this.store.state.tokens.get();
|
|
1255
1206
|
e.length === 1 && e[0].type === "text" && e[0].content === "" && this.store.refs.container?.firstElementChild?.focus();
|
|
1256
|
-
}, t.addEventListener("focusin", this.#
|
|
1207
|
+
}, t.addEventListener("focusin", this.#e), t.addEventListener("focusout", this.#t), t.addEventListener("click", this.#n));
|
|
1257
1208
|
}
|
|
1258
1209
|
disable() {
|
|
1259
1210
|
const t = this.store.refs.container;
|
|
1260
|
-
!t || !this.#
|
|
1211
|
+
!t || !this.#e || (t.removeEventListener("focusin", this.#e), t.removeEventListener("focusout", this.#t), t.removeEventListener("click", this.#n), this.#e = void 0, this.#t = void 0, this.#n = void 0);
|
|
1261
1212
|
}
|
|
1262
1213
|
recover() {
|
|
1263
1214
|
const t = this.store.state.recovery.get();
|
|
@@ -1281,20 +1232,36 @@ class te {
|
|
|
1281
1232
|
this.store.nodes.focus.caret = n, this.store.state.recovery.set(void 0);
|
|
1282
1233
|
}
|
|
1283
1234
|
}
|
|
1284
|
-
|
|
1235
|
+
function te(s, t) {
|
|
1236
|
+
const { focus: e } = s.nodes;
|
|
1237
|
+
if (e.isMark && !e.isEditable || e.isCaretAtBeginning) {
|
|
1238
|
+
const n = e.prev;
|
|
1239
|
+
return n.focus(), n.isFocused || (n.prev.focus(), t.preventDefault()), e.setCaretToEnd(), !0;
|
|
1240
|
+
}
|
|
1241
|
+
return !1;
|
|
1242
|
+
}
|
|
1243
|
+
function ee(s, t) {
|
|
1244
|
+
const { focus: e } = s.nodes;
|
|
1245
|
+
if (e.isMark && !e.isEditable || e.isCaretAtEnd) {
|
|
1246
|
+
const n = e.next;
|
|
1247
|
+
return n.focus(), n.isFocused || (n.next.focus(), t.preventDefault()), !0;
|
|
1248
|
+
}
|
|
1249
|
+
return !1;
|
|
1250
|
+
}
|
|
1251
|
+
class ne {
|
|
1285
1252
|
constructor(t) {
|
|
1286
1253
|
this.store = t;
|
|
1287
1254
|
}
|
|
1288
|
-
#t;
|
|
1289
1255
|
#e;
|
|
1256
|
+
#t;
|
|
1290
1257
|
#n;
|
|
1291
1258
|
#s;
|
|
1292
1259
|
#r = null;
|
|
1293
1260
|
#o = !1;
|
|
1294
1261
|
enable() {
|
|
1295
|
-
this.#
|
|
1262
|
+
this.#e || (this.#e = (t) => {
|
|
1296
1263
|
this.#r = t.target, this.#o = !0;
|
|
1297
|
-
}, this.#
|
|
1264
|
+
}, this.#t = (t) => {
|
|
1298
1265
|
const e = this.#o, n = !this.store.refs.container?.contains(this.#r) || this.#r !== t.target, r = window.getSelection()?.containsNode(this.store.refs.container, !0);
|
|
1299
1266
|
e && n && r && this.store.state.selecting.set("drag");
|
|
1300
1267
|
}, this.#n = () => {
|
|
@@ -1303,13 +1270,13 @@ class ee {
|
|
|
1303
1270
|
if (this.store.state.selecting.get() !== "drag") return;
|
|
1304
1271
|
const t = [...this.store.refs.container.children], e = t.map((n) => n.contentEditable);
|
|
1305
1272
|
t.forEach((n) => n.contentEditable = "false"), t.forEach((n, r) => n.contentEditable = e[r]);
|
|
1306
|
-
}, document.addEventListener("mousedown", this.#
|
|
1273
|
+
}, document.addEventListener("mousedown", this.#e), document.addEventListener("mousemove", this.#t), document.addEventListener("mouseup", this.#n), document.addEventListener("selectionchange", this.#s));
|
|
1307
1274
|
}
|
|
1308
1275
|
disable() {
|
|
1309
|
-
this.#
|
|
1276
|
+
this.#e && (document.removeEventListener("mousedown", this.#e), document.removeEventListener("mousemove", this.#t), document.removeEventListener("mouseup", this.#n), document.removeEventListener("selectionchange", this.#s), this.#e = void 0, this.#t = void 0, this.#n = void 0, this.#s = void 0), this.#r = null, this.#o = !1;
|
|
1310
1277
|
}
|
|
1311
1278
|
}
|
|
1312
|
-
function
|
|
1279
|
+
function se(s, t) {
|
|
1313
1280
|
if ((t.ctrlKey || t.metaKey) && t.code === "KeyA") {
|
|
1314
1281
|
t.preventDefault();
|
|
1315
1282
|
const e = window.getSelection(), n = s.refs.container?.firstChild, r = s.refs.container?.lastChild;
|
|
@@ -1317,65 +1284,90 @@ function ne(s, t) {
|
|
|
1317
1284
|
e.setBaseAndExtent(n, 0, r, 1), s.state.selecting.set("all");
|
|
1318
1285
|
}
|
|
1319
1286
|
}
|
|
1320
|
-
|
|
1321
|
-
const { focus: e } = s.nodes;
|
|
1322
|
-
if (e.isMark && !e.isEditable || e.isCaretAtBeginning) {
|
|
1323
|
-
const n = e.prev;
|
|
1324
|
-
return n.focus(), n.isFocused || (n.prev.focus(), t.preventDefault()), e.setCaretToEnd(), !0;
|
|
1325
|
-
}
|
|
1326
|
-
return !1;
|
|
1327
|
-
}
|
|
1328
|
-
function re(s, t) {
|
|
1329
|
-
const { focus: e } = s.nodes;
|
|
1330
|
-
if (e.isMark && !e.isEditable || e.isCaretAtEnd) {
|
|
1331
|
-
const n = e.next;
|
|
1332
|
-
return n.focus(), n.isFocused || (n.next.focus(), t.preventDefault()), !0;
|
|
1333
|
-
}
|
|
1334
|
-
return !1;
|
|
1335
|
-
}
|
|
1336
|
-
class oe {
|
|
1287
|
+
class re {
|
|
1337
1288
|
constructor(t) {
|
|
1338
1289
|
this.store = t;
|
|
1339
1290
|
}
|
|
1340
|
-
#t;
|
|
1341
1291
|
#e;
|
|
1292
|
+
#t;
|
|
1342
1293
|
#n;
|
|
1343
1294
|
enable() {
|
|
1344
|
-
if (this.#
|
|
1295
|
+
if (this.#e) return;
|
|
1345
1296
|
const t = this.store.refs.container;
|
|
1346
|
-
t && (this.#
|
|
1347
|
-
e.key ===
|
|
1348
|
-
}, this.#
|
|
1297
|
+
t && (this.#e = (e) => {
|
|
1298
|
+
e.key === v.LEFT ? te(this.store, e) : e.key === v.RIGHT && ee(this.store, e), this.#s(e), se(this.store, e);
|
|
1299
|
+
}, this.#t = (e) => {
|
|
1349
1300
|
ae(this.store, e);
|
|
1350
1301
|
}, this.#n = (e) => {
|
|
1351
|
-
|
|
1352
|
-
}, t.addEventListener("keydown", this.#
|
|
1302
|
+
oe(this.store, e);
|
|
1303
|
+
}, t.addEventListener("keydown", this.#e), t.addEventListener("paste", this.#t), t.addEventListener("beforeinput", this.#n, !0));
|
|
1353
1304
|
}
|
|
1354
1305
|
disable() {
|
|
1355
1306
|
const t = this.store.refs.container;
|
|
1356
|
-
!t || !this.#
|
|
1307
|
+
!t || !this.#e || (t.removeEventListener("keydown", this.#e), t.removeEventListener("paste", this.#t), t.removeEventListener("beforeinput", this.#n, !0), this.#e = void 0, this.#t = void 0, this.#n = void 0);
|
|
1357
1308
|
}
|
|
1358
1309
|
#s(t) {
|
|
1359
1310
|
const { focus: e } = this.store.nodes;
|
|
1360
|
-
if (t.key ===
|
|
1311
|
+
if (t.key === v.DELETE || t.key === v.BACKSPACE) {
|
|
1361
1312
|
if (e.isMark) {
|
|
1313
|
+
if (e.isEditable && (t.key === v.BACKSPACE && !e.isCaretAtBeginning || t.key === v.DELETE && !e.isCaretAtEnd))
|
|
1314
|
+
return;
|
|
1362
1315
|
t.preventDefault(), U("self", this.store);
|
|
1363
1316
|
return;
|
|
1364
1317
|
}
|
|
1365
|
-
t.key ===
|
|
1318
|
+
t.key === v.BACKSPACE && e.isSpan && e.isCaretAtBeginning && e.prev.target && (t.preventDefault(), U("prev", this.store)), t.key === v.DELETE && e.isSpan && e.isCaretAtEnd && e.next.target && (t.preventDefault(), U("next", this.store));
|
|
1366
1319
|
}
|
|
1367
1320
|
}
|
|
1368
1321
|
}
|
|
1369
|
-
function
|
|
1322
|
+
function oe(s, t) {
|
|
1370
1323
|
const e = s.state.selecting.get();
|
|
1371
|
-
if (e
|
|
1372
|
-
|
|
1324
|
+
if (e === "all" && ut(s)) {
|
|
1325
|
+
if (t.inputType === "insertFromPaste") {
|
|
1326
|
+
t.preventDefault();
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1329
|
+
t.preventDefault();
|
|
1330
|
+
const r = t.inputType.startsWith("delete") ? "" : t.data ?? "";
|
|
1331
|
+
ht(s, r);
|
|
1373
1332
|
return;
|
|
1374
1333
|
}
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1334
|
+
e === "all" && s.state.selecting.set(void 0);
|
|
1335
|
+
const { focus: n } = s.nodes;
|
|
1336
|
+
!n.target || !n.isEditable || ie(n, t) && s.events.change();
|
|
1337
|
+
}
|
|
1338
|
+
function ie(s, t) {
|
|
1339
|
+
const e = s.caret, n = s.content;
|
|
1340
|
+
let r, o;
|
|
1341
|
+
switch (t.inputType) {
|
|
1342
|
+
case "insertText": {
|
|
1343
|
+
t.preventDefault();
|
|
1344
|
+
const i = t.data ?? "";
|
|
1345
|
+
r = n.slice(0, e) + i + n.slice(e), o = e + i.length;
|
|
1346
|
+
break;
|
|
1347
|
+
}
|
|
1348
|
+
case "deleteContentBackward":
|
|
1349
|
+
case "deleteContentForward":
|
|
1350
|
+
case "deleteWordBackward":
|
|
1351
|
+
case "deleteWordForward":
|
|
1352
|
+
case "deleteSoftLineBackward":
|
|
1353
|
+
case "deleteSoftLineForward": {
|
|
1354
|
+
const i = t.getTargetRanges();
|
|
1355
|
+
if (!i.length) return !1;
|
|
1356
|
+
const { startOffset: a, endOffset: c } = i[0];
|
|
1357
|
+
if (a === c) return !1;
|
|
1358
|
+
t.preventDefault(), r = n.slice(0, a) + n.slice(c), o = a;
|
|
1359
|
+
break;
|
|
1360
|
+
}
|
|
1361
|
+
case "insertFromPaste":
|
|
1362
|
+
case "insertReplacementText": {
|
|
1363
|
+
const i = t.dataTransfer?.getData("text/plain") ?? "", a = t.getTargetRanges(), c = a[0]?.startOffset ?? e, l = a[0]?.endOffset ?? e;
|
|
1364
|
+
t.preventDefault(), r = n.slice(0, c) + i + n.slice(l), o = c + i.length;
|
|
1365
|
+
break;
|
|
1366
|
+
}
|
|
1367
|
+
default:
|
|
1368
|
+
return !1;
|
|
1369
|
+
}
|
|
1370
|
+
return s.content = r, s.caret = o, !0;
|
|
1379
1371
|
}
|
|
1380
1372
|
function ae(s, t) {
|
|
1381
1373
|
const e = s.state.selecting.get();
|
|
@@ -1415,40 +1407,40 @@ function ht(s, t) {
|
|
|
1415
1407
|
});
|
|
1416
1408
|
}
|
|
1417
1409
|
class ce {
|
|
1418
|
-
#
|
|
1419
|
-
#
|
|
1410
|
+
#e = [];
|
|
1411
|
+
#t = !1;
|
|
1420
1412
|
register(t) {
|
|
1421
|
-
return this.#
|
|
1413
|
+
return this.#e.push(t), this;
|
|
1422
1414
|
}
|
|
1423
1415
|
enableAll() {
|
|
1424
|
-
this.#
|
|
1416
|
+
this.#t || (this.#t = !0, this.#e.forEach((t) => t.enable()));
|
|
1425
1417
|
}
|
|
1426
1418
|
disableAll() {
|
|
1427
|
-
this.#
|
|
1419
|
+
this.#t && (this.#t = !1, this.#e.forEach((t) => t.disable()));
|
|
1428
1420
|
}
|
|
1429
1421
|
}
|
|
1430
|
-
const
|
|
1422
|
+
const V = (s, t) => ({
|
|
1431
1423
|
name: s,
|
|
1432
1424
|
enable: () => t.enable(),
|
|
1433
1425
|
disable: () => t.disable()
|
|
1434
1426
|
}), le = (s) => {
|
|
1435
1427
|
const t = new ce();
|
|
1436
|
-
return t.register(
|
|
1428
|
+
return t.register(V("keydown", s.controllers.keydown)).register(V("system", s.controllers.system)).register(V("focus", s.controllers.focus)).register(V("textSelection", s.controllers.textSelection)), t;
|
|
1437
1429
|
};
|
|
1438
1430
|
class de {
|
|
1439
1431
|
constructor(t) {
|
|
1440
1432
|
this.store = t;
|
|
1441
1433
|
}
|
|
1442
|
-
#
|
|
1443
|
-
#
|
|
1434
|
+
#e = [];
|
|
1435
|
+
#t = !1;
|
|
1444
1436
|
enable(t) {
|
|
1445
1437
|
const { store: e } = this, n = le(e);
|
|
1446
|
-
n.enableAll(), this.#
|
|
1438
|
+
n.enableAll(), this.#e.push(() => n.disableAll()), this.#n(), t?.getTrigger && this.#s(t.getTrigger);
|
|
1447
1439
|
}
|
|
1448
1440
|
disable() {
|
|
1449
|
-
for (const t of this.#
|
|
1441
|
+
for (const t of this.#e)
|
|
1450
1442
|
t();
|
|
1451
|
-
this.#
|
|
1443
|
+
this.#e = [], this.#t = !1;
|
|
1452
1444
|
}
|
|
1453
1445
|
/**
|
|
1454
1446
|
* Synchronizes the parser with current options and handles parsing.
|
|
@@ -1457,12 +1449,12 @@ class de {
|
|
|
1457
1449
|
*/
|
|
1458
1450
|
syncParser(t, e) {
|
|
1459
1451
|
const { store: n } = this, r = e?.map((i) => i.markup);
|
|
1460
|
-
if (r && r.some(Boolean) ? n.state.parser.set(new
|
|
1452
|
+
if (r && r.some(Boolean) ? n.state.parser.set(new H(r)) : n.state.parser.set(void 0), this.#t) {
|
|
1461
1453
|
n.state.recovery.get() || n.events.parse();
|
|
1462
1454
|
return;
|
|
1463
1455
|
}
|
|
1464
1456
|
const o = t ?? n.state.defaultValue.get() ?? "";
|
|
1465
|
-
n.state.tokens.set(
|
|
1457
|
+
n.state.tokens.set(R(n, o)), this.#t = !0;
|
|
1466
1458
|
}
|
|
1467
1459
|
/**
|
|
1468
1460
|
* Recovers focus after tokens change.
|
|
@@ -1473,27 +1465,21 @@ class de {
|
|
|
1473
1465
|
this.store.state.Mark.get() && this.store.controllers.focus.recover();
|
|
1474
1466
|
}
|
|
1475
1467
|
#n() {
|
|
1476
|
-
const t = this.store.refs.container;
|
|
1477
|
-
if (!t) return;
|
|
1478
|
-
const e = () => this.store.events.change();
|
|
1479
|
-
t.addEventListener("input", e), this.#t.push(() => t.removeEventListener("input", e));
|
|
1480
|
-
}
|
|
1481
|
-
#s() {
|
|
1482
1468
|
const { store: t } = this;
|
|
1483
|
-
this.#
|
|
1469
|
+
this.#e.push(
|
|
1484
1470
|
t.events.parse.on(() => {
|
|
1485
1471
|
if (t.state.recovery.get()) {
|
|
1486
1472
|
const e = I(t.state.tokens.get());
|
|
1487
|
-
t.state.tokens.set(
|
|
1473
|
+
t.state.tokens.set(R(t, e)), t.state.previousValue.set(e);
|
|
1488
1474
|
return;
|
|
1489
1475
|
}
|
|
1490
1476
|
t.state.tokens.set(t.nodes.focus.target ? Ft(t) : Wt(t));
|
|
1491
1477
|
})
|
|
1492
1478
|
);
|
|
1493
1479
|
}
|
|
1494
|
-
#
|
|
1480
|
+
#s(t) {
|
|
1495
1481
|
const { store: e } = this;
|
|
1496
|
-
e.controllers.overlay.enableTrigger(t, (n) => e.state.overlayMatch.set(n)), this.#
|
|
1482
|
+
e.controllers.overlay.enableTrigger(t, (n) => e.state.overlayMatch.set(n)), this.#e.push(() => e.controllers.overlay.disable()), this.#e.push(
|
|
1497
1483
|
e.state.overlayMatch.on((n) => {
|
|
1498
1484
|
n ? (e.nodes.input.target = e.nodes.focus.target, e.controllers.overlay.enableClose()) : e.controllers.overlay.disableClose();
|
|
1499
1485
|
})
|
|
@@ -1501,10 +1487,59 @@ class de {
|
|
|
1501
1487
|
}
|
|
1502
1488
|
}
|
|
1503
1489
|
class ue {
|
|
1490
|
+
constructor(t) {
|
|
1491
|
+
this.store = t;
|
|
1492
|
+
}
|
|
1493
|
+
#e;
|
|
1494
|
+
#t;
|
|
1495
|
+
#n;
|
|
1496
|
+
#s;
|
|
1497
|
+
#r;
|
|
1498
|
+
#o;
|
|
1499
|
+
#i;
|
|
1500
|
+
#a;
|
|
1501
|
+
enableTrigger(t, e) {
|
|
1502
|
+
if (this.#e) return;
|
|
1503
|
+
this.#e = this.store.events.clearOverlay.on(() => {
|
|
1504
|
+
e(void 0);
|
|
1505
|
+
}), this.#t = this.store.events.checkOverlay.on(() => {
|
|
1506
|
+
const r = Q.find(this.store.state.options.get(), t);
|
|
1507
|
+
e(r);
|
|
1508
|
+
}), this.#n = this.store.events.change.on(() => {
|
|
1509
|
+
const r = this.store.state.showOverlayOn.get(), o = "change";
|
|
1510
|
+
(r === o || Array.isArray(r) && r.includes(o)) && this.store.events.checkOverlay();
|
|
1511
|
+
}), this.#s = () => {
|
|
1512
|
+
const r = this.store.state.showOverlayOn.get(), o = "selectionChange";
|
|
1513
|
+
(r === o || Array.isArray(r) && r.includes(o)) && this.store.events.checkOverlay();
|
|
1514
|
+
}, this.#r = () => {
|
|
1515
|
+
document.addEventListener("selectionchange", this.#s);
|
|
1516
|
+
}, this.#o = () => {
|
|
1517
|
+
document.removeEventListener("selectionchange", this.#s);
|
|
1518
|
+
};
|
|
1519
|
+
const n = this.store.refs.container;
|
|
1520
|
+
n && (n.addEventListener("focusin", this.#r), n.addEventListener("focusout", this.#o));
|
|
1521
|
+
}
|
|
1522
|
+
enableClose() {
|
|
1523
|
+
this.#i || (this.#i = (t) => {
|
|
1524
|
+
t.key === v.ESC && this.store.events.clearOverlay();
|
|
1525
|
+
}, this.#a = (t) => {
|
|
1526
|
+
const e = t.target;
|
|
1527
|
+
this.store.refs.overlay?.contains(e) || this.store.refs.container?.contains(e) || this.store.events.clearOverlay();
|
|
1528
|
+
}, window.addEventListener("keydown", this.#i), document.addEventListener("click", this.#a, !0));
|
|
1529
|
+
}
|
|
1530
|
+
disableClose() {
|
|
1531
|
+
this.#i && (window.removeEventListener("keydown", this.#i), document.removeEventListener("click", this.#a, !0), this.#i = void 0, this.#a = void 0);
|
|
1532
|
+
}
|
|
1533
|
+
disable() {
|
|
1534
|
+
const t = this.store.refs.container;
|
|
1535
|
+
t && this.#r && (t.removeEventListener("focusin", this.#r), t.removeEventListener("focusout", this.#o)), this.#s && document.removeEventListener("selectionchange", this.#s), this.disableClose(), this.#e?.(), this.#t?.(), this.#n?.(), this.#e = void 0, this.#t = void 0, this.#n = void 0, this.#s = void 0, this.#r = void 0, this.#o = void 0;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
class he {
|
|
1504
1539
|
key = new Zt();
|
|
1505
1540
|
nodes = {
|
|
1506
|
-
focus: new
|
|
1507
|
-
input: new
|
|
1541
|
+
focus: new B(void 0, this),
|
|
1542
|
+
input: new B(void 0, this)
|
|
1508
1543
|
};
|
|
1509
1544
|
state;
|
|
1510
1545
|
events = Xt();
|
|
@@ -1513,11 +1548,11 @@ class ue {
|
|
|
1513
1548
|
overlay: null
|
|
1514
1549
|
};
|
|
1515
1550
|
controllers = {
|
|
1516
|
-
overlay: new
|
|
1517
|
-
focus: new
|
|
1518
|
-
keydown: new
|
|
1551
|
+
overlay: new ue(this),
|
|
1552
|
+
focus: new Yt(this),
|
|
1553
|
+
keydown: new re(this),
|
|
1519
1554
|
system: new Kt(this),
|
|
1520
|
-
textSelection: new
|
|
1555
|
+
textSelection: new ne(this)
|
|
1521
1556
|
};
|
|
1522
1557
|
lifecycle = new de(this);
|
|
1523
1558
|
constructor(t) {
|
|
@@ -1560,13 +1595,13 @@ class ue {
|
|
|
1560
1595
|
};
|
|
1561
1596
|
}
|
|
1562
1597
|
}
|
|
1563
|
-
class
|
|
1598
|
+
class fe {
|
|
1564
1599
|
ref;
|
|
1565
|
-
#t;
|
|
1566
1600
|
#e;
|
|
1601
|
+
#t;
|
|
1567
1602
|
#n;
|
|
1568
1603
|
constructor(t) {
|
|
1569
|
-
this.ref = t.ref, this.#
|
|
1604
|
+
this.ref = t.ref, this.#e = t.store, this.#t = t.token;
|
|
1570
1605
|
}
|
|
1571
1606
|
get readOnly() {
|
|
1572
1607
|
return this.#n;
|
|
@@ -1575,53 +1610,53 @@ class he {
|
|
|
1575
1610
|
this.#n = t;
|
|
1576
1611
|
}
|
|
1577
1612
|
get content() {
|
|
1578
|
-
return this.#
|
|
1613
|
+
return this.#t.content;
|
|
1579
1614
|
}
|
|
1580
1615
|
set content(t) {
|
|
1581
|
-
this.#
|
|
1616
|
+
this.#t.content = t, this.#s();
|
|
1582
1617
|
}
|
|
1583
1618
|
get value() {
|
|
1584
|
-
return this.#
|
|
1619
|
+
return this.#t.value;
|
|
1585
1620
|
}
|
|
1586
1621
|
set value(t) {
|
|
1587
|
-
this.#
|
|
1622
|
+
this.#t.value = t ?? "", this.#s();
|
|
1588
1623
|
}
|
|
1589
1624
|
get meta() {
|
|
1590
|
-
return this.#
|
|
1625
|
+
return this.#t.meta;
|
|
1591
1626
|
}
|
|
1592
1627
|
set meta(t) {
|
|
1593
|
-
this.#
|
|
1628
|
+
this.#t.meta = t, this.#s();
|
|
1594
1629
|
}
|
|
1595
1630
|
get depth() {
|
|
1596
|
-
return z(this.#
|
|
1631
|
+
return z(this.#e.state.tokens.get(), this.#t).depth;
|
|
1597
1632
|
}
|
|
1598
1633
|
get hasChildren() {
|
|
1599
|
-
return this.#
|
|
1634
|
+
return this.#t.children.length > 0;
|
|
1600
1635
|
}
|
|
1601
1636
|
get parent() {
|
|
1602
|
-
return z(this.#
|
|
1637
|
+
return z(this.#e.state.tokens.get(), this.#t)?.parent;
|
|
1603
1638
|
}
|
|
1604
1639
|
get tokens() {
|
|
1605
|
-
return this.#
|
|
1640
|
+
return this.#t.children;
|
|
1606
1641
|
}
|
|
1607
1642
|
change = (t) => {
|
|
1608
|
-
this.#
|
|
1643
|
+
this.#t.content = t.content, this.#t.value = t.value ?? "", t.meta !== void 0 && (this.#t.meta = t.meta), this.#s();
|
|
1609
1644
|
};
|
|
1610
|
-
remove = () => this.#
|
|
1645
|
+
remove = () => this.#e.events.delete({ token: this.#t });
|
|
1611
1646
|
#s() {
|
|
1612
|
-
this.#
|
|
1647
|
+
this.#e.events.change();
|
|
1613
1648
|
}
|
|
1614
1649
|
}
|
|
1615
1650
|
let ft = 0;
|
|
1616
1651
|
function rt(s) {
|
|
1617
1652
|
return `block-${ft++}-${s}`;
|
|
1618
1653
|
}
|
|
1619
|
-
function
|
|
1654
|
+
function ge() {
|
|
1620
1655
|
ft = 0;
|
|
1621
1656
|
}
|
|
1622
|
-
function
|
|
1657
|
+
function pe(s) {
|
|
1623
1658
|
if (s.length === 0) return [];
|
|
1624
|
-
|
|
1659
|
+
ge();
|
|
1625
1660
|
const t = [];
|
|
1626
1661
|
let e = [], n = -1;
|
|
1627
1662
|
const r = (o) => {
|
|
@@ -1644,7 +1679,7 @@ function ge(s) {
|
|
|
1644
1679
|
continue;
|
|
1645
1680
|
}
|
|
1646
1681
|
if (o.type !== "text") continue;
|
|
1647
|
-
const a =
|
|
1682
|
+
const a = ve(o);
|
|
1648
1683
|
for (let c = 0; c < a.length; c++) {
|
|
1649
1684
|
const l = a[c];
|
|
1650
1685
|
if (l.isNewline) {
|
|
@@ -1664,7 +1699,7 @@ function ge(s) {
|
|
|
1664
1699
|
}
|
|
1665
1700
|
return t;
|
|
1666
1701
|
}
|
|
1667
|
-
function
|
|
1702
|
+
function ve(s) {
|
|
1668
1703
|
const t = [], { content: e, position: n } = s;
|
|
1669
1704
|
let r = n.start;
|
|
1670
1705
|
const o = [], i = () => {
|
|
@@ -1700,12 +1735,12 @@ function pe(s) {
|
|
|
1700
1735
|
}
|
|
1701
1736
|
return i(), t;
|
|
1702
1737
|
}
|
|
1703
|
-
function
|
|
1738
|
+
function me(s, t, e, n) {
|
|
1704
1739
|
if (e === n || e === n - 1 || t.length < 2 || e < 0 || e >= t.length || n < 0 || n > t.length) return s;
|
|
1705
|
-
const r =
|
|
1706
|
-
return
|
|
1740
|
+
const r = ye(s, t), o = ke(r, e, n);
|
|
1741
|
+
return xe(o);
|
|
1707
1742
|
}
|
|
1708
|
-
function
|
|
1743
|
+
function ye(s, t) {
|
|
1709
1744
|
return t.map((e, n) => {
|
|
1710
1745
|
const r = s.substring(e.startPos, e.endPos);
|
|
1711
1746
|
let o = "";
|
|
@@ -1720,7 +1755,7 @@ function me(s, t) {
|
|
|
1720
1755
|
};
|
|
1721
1756
|
});
|
|
1722
1757
|
}
|
|
1723
|
-
function
|
|
1758
|
+
function xe(s) {
|
|
1724
1759
|
const t = [];
|
|
1725
1760
|
for (let e = 0; e < s.length; e++) {
|
|
1726
1761
|
const n = s[e], r = e === s.length - 1;
|
|
@@ -1731,11 +1766,11 @@ function ye(s) {
|
|
|
1731
1766
|
}
|
|
1732
1767
|
return t.join("");
|
|
1733
1768
|
}
|
|
1734
|
-
function
|
|
1769
|
+
function ke(s, t, e) {
|
|
1735
1770
|
const n = [...s], [r] = n.splice(t, 1), o = e > t ? e - 1 : e;
|
|
1736
|
-
return n.splice(o, 0, r),
|
|
1771
|
+
return n.splice(o, 0, r), we(n, s), n;
|
|
1737
1772
|
}
|
|
1738
|
-
function
|
|
1773
|
+
function we(s, t) {
|
|
1739
1774
|
for (let e = 0; e < s.length - 1; e++) {
|
|
1740
1775
|
const n = s[e].index, r = s[e + 1].index;
|
|
1741
1776
|
if (Math.abs(n - r) === 1) {
|
|
@@ -1747,90 +1782,48 @@ function ke(s, t) {
|
|
|
1747
1782
|
`;
|
|
1748
1783
|
}
|
|
1749
1784
|
}
|
|
1750
|
-
const
|
|
1751
|
-
|
|
1752
|
-
|
|
1785
|
+
const Se = [
|
|
1786
|
+
{
|
|
1787
|
+
markup: Pt,
|
|
1788
|
+
overlay: {
|
|
1789
|
+
trigger: It,
|
|
1790
|
+
data: []
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
], Ce = (s) => () => {
|
|
1794
|
+
const [t, e] = P(() => s.get());
|
|
1795
|
+
return M(() => s.on(e), [s]), t;
|
|
1753
1796
|
};
|
|
1754
|
-
function
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
const e =
|
|
1759
|
-
|
|
1797
|
+
function be(s, t) {
|
|
1798
|
+
St(t, () => s.createHandler(), [s]), M(() => (s.lifecycle.enable({
|
|
1799
|
+
getTrigger: (a) => a.overlay?.trigger
|
|
1800
|
+
}), () => s.lifecycle.disable()), []);
|
|
1801
|
+
const e = s.state.value.use(), n = s.state.Mark.use(), r = s.state.options.use(), o = n ? r : void 0;
|
|
1802
|
+
M(() => {
|
|
1803
|
+
s.lifecycle.syncParser(e, o);
|
|
1804
|
+
}, [e, o]);
|
|
1805
|
+
const i = s.state.tokens.use();
|
|
1806
|
+
M(() => {
|
|
1807
|
+
s.lifecycle.recoverFocus();
|
|
1808
|
+
}, [i]);
|
|
1760
1809
|
}
|
|
1761
|
-
const
|
|
1762
|
-
|
|
1810
|
+
const K = at(void 0);
|
|
1811
|
+
K.displayName = "StoreContext";
|
|
1763
1812
|
function E() {
|
|
1764
|
-
const s = ct(
|
|
1813
|
+
const s = ct(K);
|
|
1765
1814
|
return bt(s), s;
|
|
1766
1815
|
}
|
|
1767
|
-
const
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
const n = ct(t);
|
|
1771
|
-
if (n === void 0)
|
|
1772
|
-
throw new Error(`Context "${s}" not found. Make sure to wrap component in its Provider.`);
|
|
1773
|
-
return n;
|
|
1774
|
-
}, t.Provider, t];
|
|
1775
|
-
}, [et, ot] = Se("NodeProvider");
|
|
1776
|
-
function gt(s, t, e, n) {
|
|
1777
|
-
const r = E(), o = r.state.Mark.use(), i = r.state.Overlay.use(), a = s === "mark" ? o : i, c = s === "mark" ? t?.mark : t?.overlay;
|
|
1778
|
-
let l;
|
|
1779
|
-
c !== void 0 ? typeof c == "function" ? l = c(e) : l = c : l = e ?? {};
|
|
1780
|
-
const d = l.slot || a || n;
|
|
1781
|
-
if (!d)
|
|
1782
|
-
throw new Error(
|
|
1783
|
-
`No ${s} component found. Provide either option.${s}.slot, global ${s === "mark" ? "Mark" : "Overlay"}, or a defaultComponent.`
|
|
1784
|
-
);
|
|
1785
|
-
return [d, l];
|
|
1786
|
-
}
|
|
1787
|
-
function Ce() {
|
|
1788
|
-
const s = et(), t = E(), e = t.state.options.use(), n = t.key, r = e?.[s.descriptor.index], o = s.children.map((l) => /* @__PURE__ */ f(F, { mark: l, isNested: !0 }, n.get(l))), i = {
|
|
1789
|
-
value: s.value,
|
|
1790
|
-
meta: s.meta,
|
|
1791
|
-
nested: s.nested?.content,
|
|
1792
|
-
children: s.children.length > 0 ? o : void 0
|
|
1793
|
-
}, [a, c] = gt("mark", r, i);
|
|
1794
|
-
return /* @__PURE__ */ f(a, { ...c });
|
|
1795
|
-
}
|
|
1796
|
-
const be = () => {
|
|
1797
|
-
const s = et(), t = E(), e = H(null), n = t.state.readOnly.use(), r = t.state.slots.use(), o = t.state.slotProps.use(), i = S(() => K("span", r), [r]), a = S(() => Y("span", o), [o]);
|
|
1798
|
-
if (s.type !== "text")
|
|
1799
|
-
throw new Error("TextSpan component expects a TextToken");
|
|
1800
|
-
return St(() => {
|
|
1801
|
-
e.current && e.current.textContent !== s.content && (e.current.textContent = s.content);
|
|
1802
|
-
}, [s.content]), /* @__PURE__ */ f(
|
|
1803
|
-
i,
|
|
1804
|
-
{
|
|
1805
|
-
...a,
|
|
1806
|
-
ref: e,
|
|
1807
|
-
contentEditable: !n,
|
|
1808
|
-
onPaste: Ee,
|
|
1809
|
-
suppressContentEditableWarning: !0
|
|
1810
|
-
}
|
|
1811
|
-
);
|
|
1816
|
+
const Ee = {
|
|
1817
|
+
container: "div",
|
|
1818
|
+
span: "span"
|
|
1812
1819
|
};
|
|
1813
|
-
function
|
|
1814
|
-
s
|
|
1815
|
-
|
|
1816
|
-
|
|
1820
|
+
function Y(s, t) {
|
|
1821
|
+
return t?.[s] ? t[s] : Ee[s];
|
|
1822
|
+
}
|
|
1823
|
+
function tt(s, t) {
|
|
1824
|
+
const e = t?.[s];
|
|
1825
|
+
return e ? Et(e) : void 0;
|
|
1817
1826
|
}
|
|
1818
|
-
const F = O(({ mark: s, isNested: t = !1 }) => s.type === "mark" ? /* @__PURE__ */ f(ot, { value: s, children: /* @__PURE__ */ f(Ce, {}) }) : t ? /* @__PURE__ */ f(wt, { children: s.content }) : /* @__PURE__ */ f(ot, { value: s, children: /* @__PURE__ */ f(be, {}) }));
|
|
1819
|
-
F.displayName = "Token";
|
|
1820
|
-
const pt = O(() => {
|
|
1821
|
-
const s = E(), t = s.state.tokens.use(), e = s.state.slots.use(), n = s.state.slotProps.use(), r = s.state.className.use(), o = s.state.style.use(), i = s.key, a = s.refs, c = S(() => K("container", e), [e]), l = S(() => Y("container", n), [n]);
|
|
1822
|
-
return /* @__PURE__ */ f(
|
|
1823
|
-
c,
|
|
1824
|
-
{
|
|
1825
|
-
ref: (d) => a.container = d,
|
|
1826
|
-
...l,
|
|
1827
|
-
className: r,
|
|
1828
|
-
style: o,
|
|
1829
|
-
children: t.map((d) => /* @__PURE__ */ f(F, { mark: d }, i.get(d)))
|
|
1830
|
-
}
|
|
1831
|
-
);
|
|
1832
|
-
});
|
|
1833
|
-
pt.displayName = "Container";
|
|
1834
1827
|
const q = {
|
|
1835
1828
|
position: "absolute",
|
|
1836
1829
|
left: -28,
|
|
@@ -1853,17 +1846,17 @@ const q = {
|
|
|
1853
1846
|
margin: 0,
|
|
1854
1847
|
font: "inherit",
|
|
1855
1848
|
lineHeight: 1
|
|
1856
|
-
},
|
|
1849
|
+
}, gt = {
|
|
1857
1850
|
...q,
|
|
1858
1851
|
opacity: 1
|
|
1859
1852
|
}, Te = {
|
|
1860
|
-
...
|
|
1853
|
+
...gt,
|
|
1861
1854
|
cursor: "grabbing"
|
|
1862
1855
|
}, Ne = {
|
|
1863
1856
|
position: "relative",
|
|
1864
1857
|
paddingLeft: 4,
|
|
1865
1858
|
transition: "opacity 0.2s ease"
|
|
1866
|
-
},
|
|
1859
|
+
}, ot = {
|
|
1867
1860
|
position: "absolute",
|
|
1868
1861
|
left: 0,
|
|
1869
1862
|
right: 0,
|
|
@@ -1872,7 +1865,7 @@ const q = {
|
|
|
1872
1865
|
borderRadius: 1,
|
|
1873
1866
|
pointerEvents: "none",
|
|
1874
1867
|
zIndex: 10
|
|
1875
|
-
},
|
|
1868
|
+
}, pt = O(() => /* @__PURE__ */ Z("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "currentColor", children: [
|
|
1876
1869
|
/* @__PURE__ */ f("circle", { cx: "5", cy: "3", r: "1.5" }),
|
|
1877
1870
|
/* @__PURE__ */ f("circle", { cx: "11", cy: "3", r: "1.5" }),
|
|
1878
1871
|
/* @__PURE__ */ f("circle", { cx: "5", cy: "8", r: "1.5" }),
|
|
@@ -1880,20 +1873,20 @@ const q = {
|
|
|
1880
1873
|
/* @__PURE__ */ f("circle", { cx: "5", cy: "13", r: "1.5" }),
|
|
1881
1874
|
/* @__PURE__ */ f("circle", { cx: "11", cy: "13", r: "1.5" })
|
|
1882
1875
|
] }));
|
|
1883
|
-
|
|
1884
|
-
const
|
|
1885
|
-
const [r, o] = P(!1), [i, a] = P(!1), [c, l] = P(null), d =
|
|
1876
|
+
pt.displayName = "GripIcon";
|
|
1877
|
+
const vt = O(({ blockIndex: s, children: t, readOnly: e, onReorder: n }) => {
|
|
1878
|
+
const [r, o] = P(!1), [i, a] = P(!1), [c, l] = P(null), d = $(null), g = k(() => o(!0), []), u = k(() => o(!1), []), h = k(
|
|
1886
1879
|
(p) => {
|
|
1887
1880
|
p.dataTransfer.effectAllowed = "move", p.dataTransfer.setData("text/plain", String(s)), a(!0), d.current && p.dataTransfer.setDragImage(d.current, 0, 0);
|
|
1888
1881
|
},
|
|
1889
1882
|
[s]
|
|
1890
|
-
),
|
|
1883
|
+
), m = k(() => {
|
|
1891
1884
|
a(!1), l(null);
|
|
1892
1885
|
}, []), C = k((p) => {
|
|
1893
1886
|
if (p.preventDefault(), p.dataTransfer.dropEffect = "move", !d.current) return;
|
|
1894
1887
|
const D = d.current.getBoundingClientRect(), W = D.top + D.height / 2;
|
|
1895
1888
|
l(p.clientY < W ? "before" : "after");
|
|
1896
|
-
}, []),
|
|
1889
|
+
}, []), y = k((p) => {
|
|
1897
1890
|
p.currentTarget.contains(p.relatedTarget) || l(null);
|
|
1898
1891
|
}, []), b = k(
|
|
1899
1892
|
(p) => {
|
|
@@ -1907,7 +1900,7 @@ const yt = O(({ blockIndex: s, children: t, readOnly: e, onReorder: n }) => {
|
|
|
1907
1900
|
), T = {
|
|
1908
1901
|
...Ne,
|
|
1909
1902
|
opacity: i ? 0.4 : 1
|
|
1910
|
-
}, L = e ? { ...q, display: "none" } : i ? Te : r ?
|
|
1903
|
+
}, L = e ? { ...q, display: "none" } : i ? Te : r ? gt : q;
|
|
1911
1904
|
return /* @__PURE__ */ Z(
|
|
1912
1905
|
"div",
|
|
1913
1906
|
{
|
|
@@ -1916,38 +1909,76 @@ const yt = O(({ blockIndex: s, children: t, readOnly: e, onReorder: n }) => {
|
|
|
1916
1909
|
onMouseEnter: g,
|
|
1917
1910
|
onMouseLeave: u,
|
|
1918
1911
|
onDragOver: C,
|
|
1919
|
-
onDragLeave:
|
|
1912
|
+
onDragLeave: y,
|
|
1920
1913
|
onDrop: b,
|
|
1921
1914
|
children: [
|
|
1922
|
-
c === "before" && /* @__PURE__ */ f("div", { style: { ...
|
|
1915
|
+
c === "before" && /* @__PURE__ */ f("div", { style: { ...ot, top: -1 } }),
|
|
1923
1916
|
/* @__PURE__ */ f(
|
|
1924
1917
|
"button",
|
|
1925
1918
|
{
|
|
1926
1919
|
type: "button",
|
|
1927
1920
|
draggable: !e,
|
|
1928
1921
|
onDragStart: h,
|
|
1929
|
-
onDragEnd:
|
|
1922
|
+
onDragEnd: m,
|
|
1930
1923
|
style: L,
|
|
1931
1924
|
"aria-label": "Drag to reorder",
|
|
1932
|
-
children: /* @__PURE__ */ f(
|
|
1925
|
+
children: /* @__PURE__ */ f(pt, {})
|
|
1933
1926
|
}
|
|
1934
1927
|
),
|
|
1935
1928
|
t,
|
|
1936
|
-
c === "after" && /* @__PURE__ */ f("div", { style: { ...
|
|
1929
|
+
c === "after" && /* @__PURE__ */ f("div", { style: { ...ot, bottom: -1 } })
|
|
1937
1930
|
]
|
|
1938
1931
|
}
|
|
1939
1932
|
);
|
|
1940
1933
|
});
|
|
1941
|
-
|
|
1942
|
-
const
|
|
1943
|
-
const
|
|
1944
|
-
|
|
1934
|
+
vt.displayName = "DraggableBlock";
|
|
1935
|
+
const Ie = (s) => {
|
|
1936
|
+
const t = at(void 0);
|
|
1937
|
+
return t.displayName = s, [() => {
|
|
1938
|
+
const n = ct(t);
|
|
1939
|
+
if (n === void 0)
|
|
1940
|
+
throw new Error(`Context "${s}" not found. Make sure to wrap component in its Provider.`);
|
|
1941
|
+
return n;
|
|
1942
|
+
}, t.Provider, t];
|
|
1943
|
+
}, [et, it] = Ie("NodeProvider");
|
|
1944
|
+
function mt(s, t, e, n) {
|
|
1945
|
+
const r = E(), o = r.state.Mark.use(), i = r.state.Overlay.use(), a = s === "mark" ? o : i, c = s === "mark" ? t?.mark : t?.overlay;
|
|
1946
|
+
let l;
|
|
1947
|
+
c !== void 0 ? typeof c == "function" ? l = c(e) : l = c : l = e ?? {};
|
|
1948
|
+
const d = l.slot || a || n;
|
|
1949
|
+
if (!d)
|
|
1950
|
+
throw new Error(
|
|
1951
|
+
`No ${s} component found. Provide either option.${s}.slot, global ${s === "mark" ? "Mark" : "Overlay"}, or a defaultComponent.`
|
|
1952
|
+
);
|
|
1953
|
+
return [d, l];
|
|
1954
|
+
}
|
|
1955
|
+
function Pe() {
|
|
1956
|
+
const s = et(), t = E(), e = t.state.options.use(), n = t.key, r = e?.[s.descriptor.index], o = s.children.map((l) => /* @__PURE__ */ f(F, { mark: l, isNested: !0 }, n.get(l))), i = {
|
|
1957
|
+
value: s.value,
|
|
1958
|
+
meta: s.meta,
|
|
1959
|
+
nested: s.nested?.content,
|
|
1960
|
+
children: s.children.length > 0 ? o : void 0
|
|
1961
|
+
}, [a, c] = mt("mark", r, i);
|
|
1962
|
+
return /* @__PURE__ */ f(a, { ...c });
|
|
1963
|
+
}
|
|
1964
|
+
const Me = () => {
|
|
1965
|
+
const s = et(), t = E(), e = $(null), n = t.state.readOnly.use(), r = t.state.slots.use(), o = t.state.slotProps.use(), i = S(() => Y("span", r), [r]), a = S(() => tt("span", o), [o]);
|
|
1966
|
+
if (s.type !== "text")
|
|
1967
|
+
throw new Error("TextSpan component expects a TextToken");
|
|
1968
|
+
return Ct(() => {
|
|
1969
|
+
e.current && e.current.textContent !== s.content && (e.current.textContent = s.content);
|
|
1970
|
+
}, [s.content]), /* @__PURE__ */ f(i, { ...a, ref: e, contentEditable: !n, suppressContentEditableWarning: !0 });
|
|
1971
|
+
}, F = O(({ mark: s, isNested: t = !1 }) => s.type === "mark" ? /* @__PURE__ */ f(it, { value: s, children: /* @__PURE__ */ f(Pe, {}) }) : t ? /* @__PURE__ */ f(wt, { children: s.content }) : /* @__PURE__ */ f(it, { value: s, children: /* @__PURE__ */ f(Me, {}) }));
|
|
1972
|
+
F.displayName = "Token";
|
|
1973
|
+
const yt = O(() => {
|
|
1974
|
+
const s = E(), t = s.state.tokens.use(), e = s.state.slots.use(), n = s.state.slotProps.use(), r = s.state.className.use(), o = s.state.style.use(), i = s.state.readOnly.use(), a = s.state.value.use(), c = s.state.onChange.use(), l = s.key, d = s.refs, g = S(() => Y("container", e), [e]), u = S(() => tt("container", n), [n]), h = S(() => pe(t), [t]), m = $(h);
|
|
1975
|
+
m.current = h;
|
|
1945
1976
|
const C = k(
|
|
1946
|
-
(
|
|
1977
|
+
(y, b) => {
|
|
1947
1978
|
if (!a || !c) return;
|
|
1948
|
-
const T =
|
|
1979
|
+
const T = m.current, L = me(a, T, y, b);
|
|
1949
1980
|
if (L !== a) {
|
|
1950
|
-
const p =
|
|
1981
|
+
const p = R(s, L);
|
|
1951
1982
|
s.state.tokens.set(p), s.state.previousValue.set(L), c(L);
|
|
1952
1983
|
}
|
|
1953
1984
|
},
|
|
@@ -1956,16 +1987,30 @@ const xt = O(() => {
|
|
|
1956
1987
|
return /* @__PURE__ */ f(
|
|
1957
1988
|
g,
|
|
1958
1989
|
{
|
|
1959
|
-
ref: (
|
|
1990
|
+
ref: (y) => d.container = y,
|
|
1960
1991
|
...u,
|
|
1961
1992
|
className: r,
|
|
1962
1993
|
style: o,
|
|
1963
|
-
children: h.map((
|
|
1994
|
+
children: h.map((y, b) => /* @__PURE__ */ f(vt, { blockIndex: b, readOnly: i, onReorder: C, children: y.tokens.map((T) => /* @__PURE__ */ f(F, { mark: T }, l.get(T))) }, y.id))
|
|
1995
|
+
}
|
|
1996
|
+
);
|
|
1997
|
+
});
|
|
1998
|
+
yt.displayName = "BlockContainer";
|
|
1999
|
+
const xt = O(() => {
|
|
2000
|
+
const s = E(), t = s.state.tokens.use(), e = s.state.slots.use(), n = s.state.slotProps.use(), r = s.state.className.use(), o = s.state.style.use(), i = s.key, a = s.refs, c = S(() => Y("container", e), [e]), l = S(() => tt("container", n), [n]);
|
|
2001
|
+
return /* @__PURE__ */ f(
|
|
2002
|
+
c,
|
|
2003
|
+
{
|
|
2004
|
+
ref: (d) => a.container = d,
|
|
2005
|
+
...l,
|
|
2006
|
+
className: r,
|
|
2007
|
+
style: o,
|
|
2008
|
+
children: t.map((d) => /* @__PURE__ */ f(F, { mark: d }, i.get(d)))
|
|
1964
2009
|
}
|
|
1965
2010
|
);
|
|
1966
2011
|
});
|
|
1967
|
-
xt.displayName = "
|
|
1968
|
-
function
|
|
2012
|
+
xt.displayName = "Container";
|
|
2013
|
+
function Le() {
|
|
1969
2014
|
const s = E(), t = s.state.overlayMatch.use(), e = w.getAbsolutePosition(), n = k(() => s.events.clearOverlay(), []), r = k(
|
|
1970
2015
|
(i) => {
|
|
1971
2016
|
const a = {
|
|
@@ -1997,12 +2042,12 @@ function Ie() {
|
|
|
1997
2042
|
);
|
|
1998
2043
|
return { match: t, style: e, select: r, close: n, ref: o };
|
|
1999
2044
|
}
|
|
2000
|
-
const
|
|
2001
|
-
Container:
|
|
2002
|
-
Suggestions:
|
|
2003
|
-
suggestionActive:
|
|
2004
|
-
},
|
|
2005
|
-
const s = E(), { match: t, select: e, style: n, ref: r } =
|
|
2045
|
+
const Ae = "_Container_1lmfr_1", Oe = "_Suggestions_1lmfr_10", De = "_suggestionActive_1lmfr_38", X = {
|
|
2046
|
+
Container: Ae,
|
|
2047
|
+
Suggestions: Oe,
|
|
2048
|
+
suggestionActive: De
|
|
2049
|
+
}, Re = () => {
|
|
2050
|
+
const s = E(), { match: t, select: e, style: n, ref: r } = Le(), [o, i] = P(NaN), a = t.option.overlay?.data || [], c = S(
|
|
2006
2051
|
() => a.filter((d) => d.toLowerCase().indexOf(t.value.toLowerCase()) > -1),
|
|
2007
2052
|
[t.value, a]
|
|
2008
2053
|
), l = c.length;
|
|
@@ -2011,17 +2056,17 @@ const Pe = "_Container_1lmfr_1", Me = "_Suggestions_1lmfr_10", Le = "_suggestion
|
|
|
2011
2056
|
if (!d) return;
|
|
2012
2057
|
const g = (u) => {
|
|
2013
2058
|
switch (u.key) {
|
|
2014
|
-
case
|
|
2059
|
+
case v.UP:
|
|
2015
2060
|
u.preventDefault(), i((h) => isNaN(h) ? 0 : (l + (h - 1) % l) % l);
|
|
2016
2061
|
break;
|
|
2017
|
-
case
|
|
2062
|
+
case v.DOWN:
|
|
2018
2063
|
u.preventDefault(), i((h) => isNaN(h) ? 0 : (h + 1) % l);
|
|
2019
2064
|
break;
|
|
2020
|
-
case
|
|
2065
|
+
case v.ENTER:
|
|
2021
2066
|
u.preventDefault(), i((h) => {
|
|
2022
2067
|
if (isNaN(h)) return h;
|
|
2023
|
-
const
|
|
2024
|
-
return e({ value:
|
|
2068
|
+
const m = c[h];
|
|
2069
|
+
return e({ value: m, meta: h.toString() }), h;
|
|
2025
2070
|
});
|
|
2026
2071
|
break;
|
|
2027
2072
|
}
|
|
@@ -2043,35 +2088,10 @@ const Pe = "_Container_1lmfr_1", Me = "_Suggestions_1lmfr_10", Le = "_suggestion
|
|
|
2043
2088
|
);
|
|
2044
2089
|
}) }) : null;
|
|
2045
2090
|
}, kt = O(() => {
|
|
2046
|
-
const s = E(), t = s.state.overlayMatch.use(), e = S(() => t ? s.key.get(t.option) : void 0, [t]), [n, r] =
|
|
2091
|
+
const s = E(), t = s.state.overlayMatch.use(), e = S(() => t ? s.key.get(t.option) : void 0, [t]), [n, r] = mt("overlay", t?.option, void 0, Re);
|
|
2047
2092
|
if (e) return /* @__PURE__ */ f(n, { ...r ?? {} }, e);
|
|
2048
2093
|
});
|
|
2049
2094
|
kt.displayName = "OverlayRenderer";
|
|
2050
|
-
function Oe(s, t) {
|
|
2051
|
-
Ct(t, () => s.createHandler(), [s]), M(() => (s.lifecycle.enable({
|
|
2052
|
-
getTrigger: (a) => a.overlay?.trigger
|
|
2053
|
-
}), () => s.lifecycle.disable()), []);
|
|
2054
|
-
const e = s.state.value.use(), n = s.state.Mark.use(), r = s.state.options.use(), o = n ? r : void 0;
|
|
2055
|
-
M(() => {
|
|
2056
|
-
s.lifecycle.syncParser(e, o);
|
|
2057
|
-
}, [e, o]);
|
|
2058
|
-
const i = s.state.tokens.use();
|
|
2059
|
-
M(() => {
|
|
2060
|
-
s.lifecycle.recoverFocus();
|
|
2061
|
-
}, [i]);
|
|
2062
|
-
}
|
|
2063
|
-
const De = (s) => () => {
|
|
2064
|
-
const [t, e] = P(() => s.get());
|
|
2065
|
-
return M(() => s.on(e), [s]), t;
|
|
2066
|
-
}, _e = [
|
|
2067
|
-
{
|
|
2068
|
-
markup: Pt,
|
|
2069
|
-
overlay: {
|
|
2070
|
-
trigger: It,
|
|
2071
|
-
data: []
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2074
|
-
];
|
|
2075
2095
|
function Fe(s) {
|
|
2076
2096
|
const {
|
|
2077
2097
|
ref: t,
|
|
@@ -2084,11 +2104,11 @@ function Fe(s) {
|
|
|
2084
2104
|
Overlay: c,
|
|
2085
2105
|
slots: l,
|
|
2086
2106
|
slotProps: d,
|
|
2087
|
-
options: g =
|
|
2107
|
+
options: g = Se,
|
|
2088
2108
|
showOverlayOn: u = "change",
|
|
2089
2109
|
className: h,
|
|
2090
|
-
style:
|
|
2091
|
-
} = s, C = Tt(X.Container, h, d?.container?.className),
|
|
2110
|
+
style: m
|
|
2111
|
+
} = s, C = Tt(X.Container, h, d?.container?.className), y = Nt(m, d?.container?.style), [b] = P(() => new he({ createUseHook: Ce }));
|
|
2092
2112
|
b.state.set({
|
|
2093
2113
|
value: e,
|
|
2094
2114
|
defaultValue: n,
|
|
@@ -2099,39 +2119,39 @@ function Fe(s) {
|
|
|
2099
2119
|
Mark: a,
|
|
2100
2120
|
Overlay: c,
|
|
2101
2121
|
className: C,
|
|
2102
|
-
style:
|
|
2122
|
+
style: y,
|
|
2103
2123
|
slots: l,
|
|
2104
2124
|
slotProps: d
|
|
2105
|
-
}),
|
|
2106
|
-
const T = i ?
|
|
2107
|
-
return /* @__PURE__ */ Z(
|
|
2125
|
+
}), be(b, t);
|
|
2126
|
+
const T = i ? yt : xt;
|
|
2127
|
+
return /* @__PURE__ */ Z(K.Provider, { value: b, children: [
|
|
2108
2128
|
/* @__PURE__ */ f(T, {}),
|
|
2109
2129
|
/* @__PURE__ */ f(kt, {})
|
|
2110
2130
|
] });
|
|
2111
2131
|
}
|
|
2112
2132
|
const We = (s = {}) => {
|
|
2113
|
-
const t = E(), e = et(), n =
|
|
2133
|
+
const t = E(), e = et(), n = $(null);
|
|
2114
2134
|
if (e.type !== "mark")
|
|
2115
2135
|
throw new Error("useMark can only be used with mark tokens");
|
|
2116
|
-
const [r] = P(() => new
|
|
2117
|
-
|
|
2136
|
+
const [r] = P(() => new fe({ ref: n, store: t, token: e }));
|
|
2137
|
+
_e(n, s, e);
|
|
2118
2138
|
const o = t.state.readOnly.use();
|
|
2119
2139
|
return M(() => {
|
|
2120
2140
|
r.readOnly = o;
|
|
2121
2141
|
}, [o]), r;
|
|
2122
2142
|
};
|
|
2123
|
-
function
|
|
2143
|
+
function _e(s, t, e) {
|
|
2124
2144
|
M(() => {
|
|
2125
2145
|
s.current && !t.controlled && (s.current.textContent = e.content);
|
|
2126
2146
|
}, []);
|
|
2127
2147
|
}
|
|
2128
2148
|
export {
|
|
2129
|
-
|
|
2149
|
+
fe as MarkHandler,
|
|
2130
2150
|
Fe as MarkedInput,
|
|
2131
2151
|
j as annotate,
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2152
|
+
He as denote,
|
|
2153
|
+
me as reorderBlocks,
|
|
2154
|
+
pe as splitTokensIntoBlocks,
|
|
2135
2155
|
We as useMark,
|
|
2136
|
-
|
|
2156
|
+
Le as useOverlay
|
|
2137
2157
|
};
|