@markput/react 0.6.0 → 0.8.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/index.css +1 -1
- package/index.d.ts +14 -17
- package/index.js +1257 -1049
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,64 +1,103 @@
|
|
|
1
1
|
import "./index.css";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
//#region ../../common/core/src/shared/utils/
|
|
5
|
-
function
|
|
6
|
-
|
|
2
|
+
import { createContext as e, memo as t, useCallback as n, useContext as r, useEffect as i, useImperativeHandle as a, useLayoutEffect as o, useMemo as s, useRef as c, useState as l, useSyncExternalStore as u } from "react";
|
|
3
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
4
|
+
//#region ../../common/core/src/shared/utils/shallow.ts
|
|
5
|
+
function p(e, t) {
|
|
6
|
+
if (Object.is(e, t)) return !0;
|
|
7
|
+
if (typeof e != "object" || !e || typeof t != "object" || !t) return !1;
|
|
8
|
+
let n = Object.keys(e);
|
|
9
|
+
if (n.length !== Object.keys(t).length) return !1;
|
|
10
|
+
for (let r of n) if (!Object.prototype.hasOwnProperty.call(t, r) || !Object.is(Reflect.get(e, r), Reflect.get(t, r))) return !1;
|
|
11
|
+
return !0;
|
|
7
12
|
}
|
|
8
13
|
//#endregion
|
|
9
14
|
//#region ../../common/core/src/shared/utils/cx.ts
|
|
10
|
-
function
|
|
15
|
+
function m(...e) {
|
|
11
16
|
return e.filter(Boolean).join(" ") || void 0;
|
|
12
17
|
}
|
|
13
18
|
//#endregion
|
|
14
19
|
//#region ../../common/core/src/shared/utils/merge.ts
|
|
15
|
-
function
|
|
20
|
+
function h(...e) {
|
|
16
21
|
let t = Object.assign({}, ...e.filter(Boolean));
|
|
17
22
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
18
23
|
}
|
|
19
24
|
//#endregion
|
|
20
25
|
//#region ../../common/core/src/shared/utils/resolveOptionSlot.ts
|
|
21
|
-
function
|
|
26
|
+
function g(e, t) {
|
|
22
27
|
return e === void 0 ? t : typeof e == "function" ? e(t) : e;
|
|
23
28
|
}
|
|
24
29
|
//#endregion
|
|
30
|
+
//#region ../../common/core/src/shared/utils/dataAttributes.ts
|
|
31
|
+
function ee(e) {
|
|
32
|
+
return e ? Object.fromEntries(Object.entries(e).map(([e, t]) => e.startsWith("data") && e.length > 4 && e[4] === e[4].toUpperCase() ? [`data-${e.slice(4).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase()}`, t] : [e, t])) : {};
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
25
35
|
//#region ../../common/core/src/shared/utils/resolveSlot.ts
|
|
26
|
-
var
|
|
36
|
+
var te = {
|
|
27
37
|
container: "div",
|
|
38
|
+
block: "div",
|
|
28
39
|
span: "span"
|
|
29
40
|
};
|
|
30
|
-
function
|
|
31
|
-
return t?.[e] ??
|
|
41
|
+
function _(e, t) {
|
|
42
|
+
return t?.[e] ?? te[e];
|
|
32
43
|
}
|
|
33
|
-
function
|
|
44
|
+
function v(e, t) {
|
|
34
45
|
let n = t?.[e];
|
|
35
|
-
return n ?
|
|
46
|
+
return n ? ee(n) : void 0;
|
|
47
|
+
}
|
|
48
|
+
function ne(e, t, n) {
|
|
49
|
+
let r = t?.Overlay ?? e ?? n;
|
|
50
|
+
if (!r) throw Error("No overlay component found. Provide either option.Overlay, global Overlay, or a defaultComponent.");
|
|
51
|
+
return [r, g(t?.overlay, {})];
|
|
52
|
+
}
|
|
53
|
+
function re(e, t, n, r, i) {
|
|
54
|
+
if (e.type === "text") return [r ?? i, { value: e.content }];
|
|
55
|
+
let a = t?.[e.descriptor.index], o = {
|
|
56
|
+
value: e.value,
|
|
57
|
+
meta: e.meta
|
|
58
|
+
}, s = g(a?.mark, o), c = a?.Mark ?? n;
|
|
59
|
+
if (!c) throw Error("No mark component found. Provide either option.Mark or global Mark.");
|
|
60
|
+
return [c, s];
|
|
36
61
|
}
|
|
37
62
|
//#endregion
|
|
38
63
|
//#region ../../common/core/src/shared/constants.ts
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
64
|
+
var y = {
|
|
65
|
+
UP: "ArrowUp",
|
|
66
|
+
DOWN: "ArrowDown",
|
|
67
|
+
LEFT: "ArrowLeft",
|
|
68
|
+
RIGHT: "ArrowRight",
|
|
69
|
+
END: "End",
|
|
70
|
+
HOME: "Home",
|
|
71
|
+
PAGE_DOWN: "PageDown",
|
|
72
|
+
PAGE_UP: "PageUp",
|
|
73
|
+
ENTER: "Enter",
|
|
74
|
+
TAB: "Tab",
|
|
75
|
+
SPACE: " ",
|
|
76
|
+
BACKSPACE: "Backspace",
|
|
77
|
+
DELETE: "Delete",
|
|
78
|
+
COMMA: ",",
|
|
79
|
+
ESC: "Escape"
|
|
80
|
+
}, ie = [{
|
|
42
81
|
markup: "@[__value__](__meta__)",
|
|
43
82
|
overlay: {
|
|
44
83
|
trigger: "@",
|
|
45
84
|
data: []
|
|
46
85
|
}
|
|
47
|
-
}],
|
|
86
|
+
}], b = {
|
|
48
87
|
Value: "__value__",
|
|
49
88
|
Meta: "__meta__",
|
|
50
|
-
|
|
51
|
-
},
|
|
89
|
+
Slot: "__slot__"
|
|
90
|
+
}, x = {
|
|
52
91
|
Value: "value",
|
|
53
92
|
Meta: "meta",
|
|
54
|
-
|
|
93
|
+
Slot: "slot"
|
|
55
94
|
};
|
|
56
95
|
//#endregion
|
|
57
|
-
//#region ../../common/core/src/features/parsing/
|
|
58
|
-
function
|
|
59
|
-
let { segments: n, gapTypes: r, counts: i, valueGapIndices: a } =
|
|
60
|
-
|
|
61
|
-
let o = i.value === 2, { segments: s, gapTypes: c } = o ?
|
|
96
|
+
//#region ../../common/core/src/features/parsing/parser/core/MarkupDescriptor.ts
|
|
97
|
+
function ae(e, t) {
|
|
98
|
+
let { segments: n, gapTypes: r, counts: i, valueGapIndices: a } = se(e);
|
|
99
|
+
ce(i, e);
|
|
100
|
+
let o = i.value === 2, { segments: s, gapTypes: c } = o ? le(n, r, a) : {
|
|
62
101
|
segments: n,
|
|
63
102
|
gapTypes: r
|
|
64
103
|
};
|
|
@@ -67,23 +106,28 @@ function T(e, t) {
|
|
|
67
106
|
index: t,
|
|
68
107
|
segments: s,
|
|
69
108
|
gapTypes: c,
|
|
70
|
-
|
|
109
|
+
hasSlot: i.slot === 1,
|
|
71
110
|
hasTwoValues: o,
|
|
72
111
|
segmentGlobalIndices: Array.from({ length: s.length })
|
|
73
112
|
};
|
|
74
113
|
}
|
|
75
|
-
|
|
114
|
+
var oe = {
|
|
115
|
+
[x.Value]: b.Value,
|
|
116
|
+
[x.Meta]: b.Meta,
|
|
117
|
+
[x.Slot]: b.Slot
|
|
118
|
+
};
|
|
119
|
+
function se(e) {
|
|
76
120
|
let t = [], n = [], r = [], i = {
|
|
77
121
|
value: 0,
|
|
78
122
|
meta: 0,
|
|
79
|
-
|
|
123
|
+
slot: 0
|
|
80
124
|
}, a = [], o = [
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
125
|
+
x.Value,
|
|
126
|
+
x.Meta,
|
|
127
|
+
x.Slot
|
|
84
128
|
];
|
|
85
129
|
for (let t of o) {
|
|
86
|
-
let n =
|
|
130
|
+
let n = oe[t], r = e.indexOf(n);
|
|
87
131
|
for (; r !== -1;) a.push({
|
|
88
132
|
type: t,
|
|
89
133
|
position: r
|
|
@@ -93,7 +137,7 @@ function E(e) {
|
|
|
93
137
|
let s = 0;
|
|
94
138
|
for (let o of a) {
|
|
95
139
|
let a = e.substring(s, o.position);
|
|
96
|
-
a.length > 0 && t.push(a), n.push(o.type), i[o.type]++, o.type ===
|
|
140
|
+
a.length > 0 && t.push(a), n.push(o.type), i[o.type]++, o.type === x.Value && r.push(n.length - 1), s = o.position + oe[o.type].length;
|
|
97
141
|
}
|
|
98
142
|
let c = e.substring(s);
|
|
99
143
|
return c.length > 0 && t.push(c), {
|
|
@@ -103,47 +147,42 @@ function E(e) {
|
|
|
103
147
|
valueGapIndices: r
|
|
104
148
|
};
|
|
105
149
|
}
|
|
106
|
-
function
|
|
150
|
+
function ce(e, t) {
|
|
107
151
|
let n = [
|
|
108
152
|
{
|
|
109
153
|
count: e.value,
|
|
110
154
|
max: 2,
|
|
111
|
-
name:
|
|
155
|
+
name: b.Value
|
|
112
156
|
},
|
|
113
157
|
{
|
|
114
158
|
count: e.meta,
|
|
115
159
|
max: 1,
|
|
116
|
-
name:
|
|
160
|
+
name: b.Meta
|
|
117
161
|
},
|
|
118
162
|
{
|
|
119
|
-
count: e.
|
|
163
|
+
count: e.slot,
|
|
120
164
|
max: 1,
|
|
121
|
-
name:
|
|
165
|
+
name: b.Slot
|
|
122
166
|
}
|
|
123
167
|
];
|
|
124
168
|
for (let { count: e, max: r, name: i } of n) if (e > r) throw Error(`Invalid markup: "${t}". Max ${r} "${i}" placeholders, got ${e}`);
|
|
125
|
-
if (e.value === 0 && e.
|
|
169
|
+
if (e.value === 0 && e.slot === 0) throw Error(`Invalid markup: "${t}". Need at least one "${b.Value}" or "${b.Slot}"`);
|
|
126
170
|
}
|
|
127
|
-
|
|
128
|
-
[w.Value]: C.Value,
|
|
129
|
-
[w.Meta]: C.Meta,
|
|
130
|
-
[w.Nested]: C.Nested
|
|
131
|
-
};
|
|
132
|
-
function k(e, t, n) {
|
|
171
|
+
function le(e, t, n) {
|
|
133
172
|
if (n.length !== 2) return {
|
|
134
173
|
segments: e,
|
|
135
174
|
gapTypes: t
|
|
136
175
|
};
|
|
137
176
|
let [r, i] = n, a = [], o = e[r], s = e[r + 1];
|
|
138
|
-
o && s && a.push(
|
|
177
|
+
o && s && a.push(ue(o, s, e[r + 2]));
|
|
139
178
|
for (let t = r + 2; t < i; t++) a.push(e[t]);
|
|
140
179
|
let c = e[i], l = e[i + 1];
|
|
141
|
-
return c && l && a.push(
|
|
180
|
+
return c && l && a.push(ue(c, l, e[i + 2])), {
|
|
142
181
|
segments: a,
|
|
143
|
-
gapTypes: t.filter((e) => e !==
|
|
182
|
+
gapTypes: t.filter((e) => e !== x.Value)
|
|
144
183
|
};
|
|
145
184
|
}
|
|
146
|
-
function
|
|
185
|
+
function ue(e, t, n) {
|
|
147
186
|
if (!n) return [
|
|
148
187
|
e,
|
|
149
188
|
t,
|
|
@@ -157,8 +196,12 @@ function A(e, t, n) {
|
|
|
157
196
|
];
|
|
158
197
|
}
|
|
159
198
|
//#endregion
|
|
160
|
-
//#region ../../common/core/src/features/parsing/
|
|
161
|
-
|
|
199
|
+
//#region ../../common/core/src/features/parsing/parser/core/MarkupRegistry.ts
|
|
200
|
+
function de(e, t) {
|
|
201
|
+
let n = e.get(t);
|
|
202
|
+
return n || (n = [], e.set(t, n)), n;
|
|
203
|
+
}
|
|
204
|
+
var fe = class {
|
|
162
205
|
markups;
|
|
163
206
|
descriptors;
|
|
164
207
|
segments = [];
|
|
@@ -168,7 +211,7 @@ var j = class {
|
|
|
168
211
|
let t = /* @__PURE__ */ new Map();
|
|
169
212
|
this.descriptors = e.map((e, n) => {
|
|
170
213
|
if (e === void 0) return null;
|
|
171
|
-
let r =
|
|
214
|
+
let r = ae(e, n);
|
|
172
215
|
return r.segments.forEach((e, n) => {
|
|
173
216
|
this.processSegment(r, e, n, t);
|
|
174
217
|
}), this.addToFirstSegmentIndexMap(r), r;
|
|
@@ -176,25 +219,22 @@ var j = class {
|
|
|
176
219
|
}
|
|
177
220
|
addToFirstSegmentIndexMap(e) {
|
|
178
221
|
let t = e.segmentGlobalIndices[0];
|
|
179
|
-
|
|
180
|
-
let n = this.firstSegmentIndexMap.get(t);
|
|
181
|
-
n ? n.push(e) : this.firstSegmentIndexMap.set(t, [e]);
|
|
222
|
+
de(this.firstSegmentIndexMap, t).push(e);
|
|
182
223
|
}
|
|
183
224
|
processSegment(e, t, n, r) {
|
|
184
225
|
let i = this.getSegmentKey(t);
|
|
185
226
|
if (!i) return;
|
|
186
|
-
this.registerSegment(t, i, r);
|
|
187
|
-
let a = r.get(i);
|
|
227
|
+
let a = this.registerSegment(t, i, r);
|
|
188
228
|
if (e.segmentGlobalIndices[n] = a, typeof t != "string") {
|
|
189
229
|
let [e, n] = t;
|
|
190
230
|
e && this.registerSegment(e, e, r), n && this.registerSegment(n, n, r);
|
|
191
231
|
}
|
|
192
232
|
}
|
|
193
233
|
registerSegment(e, t, n) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
234
|
+
let r = n.get(t);
|
|
235
|
+
if (r !== void 0) return r;
|
|
236
|
+
let i = this.segments.length;
|
|
237
|
+
return this.segments.push(e), n.set(t, i), i;
|
|
198
238
|
}
|
|
199
239
|
getSegmentKey(e) {
|
|
200
240
|
if (typeof e == "string") return e;
|
|
@@ -203,26 +243,34 @@ var j = class {
|
|
|
203
243
|
}
|
|
204
244
|
};
|
|
205
245
|
//#endregion
|
|
206
|
-
//#region ../../common/core/src/features/parsing/
|
|
207
|
-
function
|
|
246
|
+
//#region ../../common/core/src/features/parsing/parser/utils/getSegmentIndex.ts
|
|
247
|
+
function pe(e, t) {
|
|
208
248
|
if (!t) return e;
|
|
209
249
|
let n = 5381;
|
|
210
250
|
for (let e = 0; e < t.length; e++) n = n * 33 ^ t.charCodeAt(e);
|
|
211
251
|
return n >>>= 0, e * 1e6 + (n & 1048575);
|
|
212
252
|
}
|
|
213
253
|
//#endregion
|
|
214
|
-
//#region ../../common/core/src/features/parsing/
|
|
215
|
-
var
|
|
254
|
+
//#region ../../common/core/src/features/parsing/parser/core/Match.ts
|
|
255
|
+
var me = class {
|
|
216
256
|
gaps = {};
|
|
217
257
|
captured;
|
|
218
258
|
expectedSegmentIndex;
|
|
219
259
|
start;
|
|
220
260
|
end;
|
|
221
261
|
constructor(e, t) {
|
|
222
|
-
if (this.descriptor = e, this.expectedSegmentIndex = 1, this.start = t.start, this.end = t.end, e.segments.length === 1
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
262
|
+
if (this.descriptor = e, this.expectedSegmentIndex = 1, this.start = t.start, this.end = t.end, e.segments.length === 1) {
|
|
263
|
+
this.expectedSegmentIndex = NaN;
|
|
264
|
+
let t = e.gapTypes[0] ?? "value";
|
|
265
|
+
t === "slot" ? this.gaps.slot = {
|
|
266
|
+
start: this.start,
|
|
267
|
+
end: this.start
|
|
268
|
+
} : this.gaps[t] = {
|
|
269
|
+
start: this.start,
|
|
270
|
+
end: this.end
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
if (e.hasTwoValues && t.captured) {
|
|
226
274
|
this.captured = t.captured;
|
|
227
275
|
let e = t.start + t.value.indexOf(t.captured), n = e + t.captured.length;
|
|
228
276
|
this.gaps.value = {
|
|
@@ -245,7 +293,7 @@ var ee = class {
|
|
|
245
293
|
let e = this.descriptor.segmentGlobalIndices[this.expectedSegmentIndex], t = this.descriptor.segments[this.expectedSegmentIndex];
|
|
246
294
|
if (typeof t == "object" && this.descriptor.hasTwoValues && this.captured && this.isAwaitingLastSegment) {
|
|
247
295
|
let [n, r] = t;
|
|
248
|
-
return
|
|
296
|
+
return pe(e, n + this.captured + r);
|
|
249
297
|
}
|
|
250
298
|
return e;
|
|
251
299
|
}
|
|
@@ -261,9 +309,16 @@ var ee = class {
|
|
|
261
309
|
}, this.end = e.end, this.expectedSegmentIndex++, this.expectedSegmentIndex >= this.descriptor.segments.length && (this.expectedSegmentIndex = NaN);
|
|
262
310
|
}
|
|
263
311
|
conflictsWith(e) {
|
|
264
|
-
return !e || this.start >= e.end ? !1 : !e.descriptor.
|
|
312
|
+
return !e || this.start >= e.end ? !1 : !e.descriptor.hasSlot || e.gaps.slot === void 0 ? !0 : !(this.start >= e.gaps.slot.start && this.end <= e.gaps.slot.end);
|
|
265
313
|
}
|
|
266
|
-
}
|
|
314
|
+
};
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region ../../common/core/src/features/parsing/parser/core/PatternMatcher.ts
|
|
317
|
+
function he(e, t) {
|
|
318
|
+
let n = e.get(t);
|
|
319
|
+
return n || (n = [], e.set(t, n)), n;
|
|
320
|
+
}
|
|
321
|
+
var ge = class {
|
|
267
322
|
pendingStates = /* @__PURE__ */ new Map();
|
|
268
323
|
completingStates = /* @__PURE__ */ new Map();
|
|
269
324
|
completedStates = [];
|
|
@@ -273,7 +328,7 @@ var ee = class {
|
|
|
273
328
|
process(e) {
|
|
274
329
|
this.pendingStates.clear(), this.completingStates.clear(), this.completedStates.length = 0;
|
|
275
330
|
for (let t of e) this.processWaitingStates(t), this.tryStartNewStates(t);
|
|
276
|
-
return this.completedStates.map((e) => e.match);
|
|
331
|
+
return this.resolveSlotLeadingMatches(), this.completedStates.map((e) => e.match);
|
|
277
332
|
}
|
|
278
333
|
processWaitingStates(e) {
|
|
279
334
|
let t = this.dequeueWaitingMatch(e);
|
|
@@ -284,7 +339,7 @@ var ee = class {
|
|
|
284
339
|
}
|
|
285
340
|
tryStartNewStates(e) {
|
|
286
341
|
this.registry.firstSegmentIndexMap.get(e.index)?.forEach((t) => {
|
|
287
|
-
let n = new
|
|
342
|
+
let n = new me(t, e);
|
|
288
343
|
if (!n.isInvalid) {
|
|
289
344
|
if (n.isCompleted) return this.addToCompleted(n);
|
|
290
345
|
this.addToWaiting(n);
|
|
@@ -292,20 +347,37 @@ var ee = class {
|
|
|
292
347
|
});
|
|
293
348
|
}
|
|
294
349
|
dequeueWaitingMatch(e) {
|
|
295
|
-
let t = e.captured ?
|
|
350
|
+
let t = e.captured ? pe(e.index, e.value) : e.index, n = this.completingStates.get(t);
|
|
296
351
|
if (n?.length) return n.pop();
|
|
297
352
|
let r = this.pendingStates.get(t);
|
|
298
353
|
if (r?.length) return r.pop();
|
|
299
354
|
}
|
|
300
355
|
addToWaiting(e) {
|
|
301
356
|
let t = e.nextSegment;
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
357
|
+
t !== void 0 && he(e.isAwaitingLastSegment ? this.completingStates : this.pendingStates, t).push(e);
|
|
358
|
+
}
|
|
359
|
+
resolveSlotLeadingMatches() {
|
|
360
|
+
let e = !1;
|
|
361
|
+
for (let t of this.completedStates) if (this.isSlotLeading(t.match)) {
|
|
362
|
+
e = !0;
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
if (!e) return;
|
|
366
|
+
let t = 0;
|
|
367
|
+
for (let e of this.completedStates) {
|
|
368
|
+
let { match: n } = e;
|
|
369
|
+
if (this.isSlotLeading(n)) {
|
|
370
|
+
let r = n.start;
|
|
371
|
+
n.start = t, e.position = t, n.gaps.slot = {
|
|
372
|
+
start: t,
|
|
373
|
+
end: r
|
|
374
|
+
}, t = n.end;
|
|
375
|
+
}
|
|
308
376
|
}
|
|
377
|
+
this.completedStates.sort((e, t) => e.position - t.position);
|
|
378
|
+
}
|
|
379
|
+
isSlotLeading(e) {
|
|
380
|
+
return e.descriptor.segments.length === 1 && e.descriptor.hasSlot;
|
|
309
381
|
}
|
|
310
382
|
addToCompleted(e) {
|
|
311
383
|
let t = e.start, n = 0, r = this.completedStates.length;
|
|
@@ -318,97 +390,109 @@ var ee = class {
|
|
|
318
390
|
match: e
|
|
319
391
|
});
|
|
320
392
|
}
|
|
321
|
-
},
|
|
393
|
+
}, S = (e) => e.replace(/[.*+?^${}()|[\]\\\\]/g, "\\$&");
|
|
322
394
|
//#endregion
|
|
323
|
-
//#region ../../common/core/src/features/parsing/
|
|
324
|
-
function
|
|
325
|
-
let r =
|
|
326
|
-
return `${r}([^${
|
|
327
|
-
}
|
|
328
|
-
var
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
dynamicRegex;
|
|
332
|
-
dynamicEntries;
|
|
333
|
-
dynamicIndices;
|
|
395
|
+
//#region ../../common/core/src/features/parsing/parser/core/SegmentMatcher.ts
|
|
396
|
+
function _e(e, t, n) {
|
|
397
|
+
let r = S(e), i = S(t);
|
|
398
|
+
return `${r}([^${S(t + n)}]+?)${i}`;
|
|
399
|
+
}
|
|
400
|
+
var ve = class {
|
|
401
|
+
static;
|
|
402
|
+
dynamic;
|
|
334
403
|
constructor(e) {
|
|
335
404
|
this.initializeDual(e);
|
|
336
405
|
}
|
|
337
406
|
initializeDual(e) {
|
|
338
407
|
let t = [], n = [], r = /* @__PURE__ */ new Map();
|
|
339
408
|
if (e.forEach((e, i) => {
|
|
340
|
-
typeof e == "string" ? (t.push(e), r.set(e, i)) : n.push(
|
|
409
|
+
typeof e == "string" ? (t.push(e), r.set(e, i)) : n.push({
|
|
410
|
+
segment: e,
|
|
411
|
+
index: i
|
|
412
|
+
});
|
|
341
413
|
}), t.length > 0) {
|
|
342
|
-
let e = [...t].
|
|
343
|
-
this.
|
|
414
|
+
let e = [...t].toSorted((e, t) => t.length - e.length).map(S);
|
|
415
|
+
this.static = {
|
|
416
|
+
regex: RegExp(`(?:${e.join("|")})`, "gu"),
|
|
417
|
+
toIndex: r
|
|
418
|
+
};
|
|
344
419
|
}
|
|
345
420
|
if (n.length > 0) {
|
|
346
|
-
let
|
|
347
|
-
n.forEach((n) => {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
421
|
+
let e = /* @__PURE__ */ new Set(), t = [];
|
|
422
|
+
n.forEach(({ segment: n, index: r }) => {
|
|
423
|
+
if (typeof n == "string") return;
|
|
424
|
+
let [i, a, o] = n;
|
|
425
|
+
e.add(r);
|
|
426
|
+
let s = _e(i, a, o).replace("(", `(?<content${r}>`);
|
|
427
|
+
t.push({
|
|
428
|
+
index: r,
|
|
429
|
+
pattern: s,
|
|
352
430
|
definition: n
|
|
353
431
|
});
|
|
354
|
-
|
|
355
|
-
let [e, a, o] = n;
|
|
356
|
-
t.add(i);
|
|
357
|
-
let s = ne(e, a, o).replace("(", `(?<content${i}>`);
|
|
358
|
-
r.push({
|
|
359
|
-
index: i,
|
|
360
|
-
pattern: s,
|
|
361
|
-
definition: n
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
}), r.sort((e, t) => {
|
|
432
|
+
}), t.sort((e, t) => {
|
|
365
433
|
let n = typeof e.definition == "string" ? e.definition.length : e.pattern.length;
|
|
366
434
|
return (typeof t.definition == "string" ? t.definition.length : t.pattern.length) - n;
|
|
367
|
-
}), this.
|
|
435
|
+
}), this.dynamic = {
|
|
436
|
+
entries: t,
|
|
437
|
+
indices: e,
|
|
438
|
+
regex: new RegExp(t.map((e, t) => `(?<seg${t}>${e.pattern})`).join("|"), "gu")
|
|
439
|
+
};
|
|
368
440
|
}
|
|
369
441
|
}
|
|
370
442
|
search(e) {
|
|
371
443
|
let t = [], n = [];
|
|
372
|
-
if (this.
|
|
373
|
-
let
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
444
|
+
if (this.static) {
|
|
445
|
+
let { regex: n, toIndex: r } = this.static;
|
|
446
|
+
for (let i of e.matchAll(n)) {
|
|
447
|
+
let e = r.get(i[0]);
|
|
448
|
+
e !== void 0 && t.push({
|
|
449
|
+
index: e,
|
|
450
|
+
start: i.index,
|
|
451
|
+
end: i.index + i[0].length,
|
|
452
|
+
value: i[0]
|
|
453
|
+
});
|
|
454
|
+
}
|
|
380
455
|
}
|
|
381
|
-
if (this.
|
|
382
|
-
let
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
456
|
+
if (this.dynamic) {
|
|
457
|
+
let { regex: t, entries: r, indices: i } = this.dynamic;
|
|
458
|
+
for (let a of e.matchAll(t)) {
|
|
459
|
+
let e = a[0], t = a.index, o, s;
|
|
460
|
+
if (a.groups) {
|
|
461
|
+
for (let e = 0; e < r.length; e++) if (a.groups[`seg${e}`] !== void 0) {
|
|
462
|
+
o = r[e].index, i.has(o) && (s = a.groups[`content${o}`]);
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
387
465
|
}
|
|
466
|
+
o !== void 0 && n.push({
|
|
467
|
+
index: o,
|
|
468
|
+
start: t,
|
|
469
|
+
end: t + e.length,
|
|
470
|
+
value: e,
|
|
471
|
+
captured: s
|
|
472
|
+
});
|
|
388
473
|
}
|
|
389
|
-
i !== void 0 && n.push({
|
|
390
|
-
index: i,
|
|
391
|
-
start: r,
|
|
392
|
-
end: r + e.length,
|
|
393
|
-
value: e,
|
|
394
|
-
captured: a
|
|
395
|
-
});
|
|
396
474
|
}
|
|
397
475
|
let r = [...n];
|
|
398
476
|
for (let e of t) n.some((t) => e.start < t.end && e.end > t.start) || r.push(e);
|
|
399
477
|
return r.sort((e, t) => e.start - t.start), r;
|
|
400
478
|
}
|
|
401
|
-
},
|
|
479
|
+
}, ye = (e, t = 0, n = e.length) => ({
|
|
402
480
|
type: "text",
|
|
403
481
|
content: e.substring(t, n),
|
|
404
482
|
position: {
|
|
405
483
|
start: t,
|
|
406
484
|
end: n
|
|
407
485
|
}
|
|
408
|
-
}),
|
|
486
|
+
}), be = class {
|
|
409
487
|
input;
|
|
488
|
+
options;
|
|
489
|
+
constructor(e) {
|
|
490
|
+
this.options = e ?? {};
|
|
491
|
+
}
|
|
410
492
|
build(e, t) {
|
|
411
|
-
|
|
493
|
+
if (this.input = t, e.length === 0) return this.filterTokens([this.createTextToken(0, t.length)]);
|
|
494
|
+
let n = this.buildSinglePass(e);
|
|
495
|
+
return this.filterTokens(n);
|
|
412
496
|
}
|
|
413
497
|
buildSinglePass(e) {
|
|
414
498
|
let t = [], n = [], r = null, i = 0;
|
|
@@ -428,7 +512,7 @@ var re = class {
|
|
|
428
512
|
t.push(e), i = a.end;
|
|
429
513
|
}
|
|
430
514
|
let o = this.createMarkToken(a);
|
|
431
|
-
if (this.
|
|
515
|
+
if (this.hasSlotContent(a)) {
|
|
432
516
|
let e = this.getContentBounds(a);
|
|
433
517
|
n.push({
|
|
434
518
|
match: a,
|
|
@@ -438,61 +522,66 @@ var re = class {
|
|
|
438
522
|
} else e ? e.token.children.push(o) : t.push(o);
|
|
439
523
|
}
|
|
440
524
|
for (; n.length > 0;) {
|
|
441
|
-
let e = n.
|
|
525
|
+
let e = n[n.length - 1];
|
|
526
|
+
n.pop();
|
|
527
|
+
let r = this.getContentBounds(e.match);
|
|
442
528
|
this.finalizeParent(e, r.end), n.length > 0 ? n[n.length - 1].token.children.push(e.token) : t.push(e.token);
|
|
443
529
|
}
|
|
444
530
|
return t.push(this.createTextToken(i, this.input.length)), t;
|
|
445
531
|
}
|
|
446
532
|
finalizeParent(e, t) {
|
|
447
|
-
|
|
448
|
-
e.token.children.push(n), e.token.children.some((e) => e.type === "mark") || (e.token.children = []);
|
|
533
|
+
e.token.children.push(this.createTextToken(e.textPos, t));
|
|
449
534
|
}
|
|
450
535
|
createMarkToken(e) {
|
|
451
|
-
let t = this.extractSubstring(e.gaps.value?.start, e.gaps.value?.end), n = this.extractSubstring(e.gaps.
|
|
536
|
+
let t = this.extractSubstring(e.gaps.value?.start, e.gaps.value?.end), n = this.extractSubstring(e.gaps.slot?.start, e.gaps.slot?.end), r = this.extractSubstring(e.gaps.meta?.start, e.gaps.meta?.end), i = n || void 0, a = e.gaps.meta === void 0 ? void 0 : r;
|
|
452
537
|
return {
|
|
453
538
|
type: "mark",
|
|
454
539
|
content: this.input.substring(e.start, e.end),
|
|
455
540
|
children: [],
|
|
456
541
|
descriptor: e.descriptor,
|
|
457
|
-
value:
|
|
542
|
+
value: t,
|
|
458
543
|
meta: a,
|
|
459
544
|
position: {
|
|
460
545
|
start: e.start,
|
|
461
546
|
end: e.end
|
|
462
547
|
},
|
|
463
|
-
|
|
548
|
+
slot: this.createSlotSourceInfo(e, i)
|
|
464
549
|
};
|
|
465
550
|
}
|
|
466
551
|
getContentBounds(e) {
|
|
467
|
-
return e.gaps.
|
|
552
|
+
return e.gaps.slot ? e.gaps.slot : e.gaps.value ? e.gaps.value : {
|
|
468
553
|
start: e.start,
|
|
469
554
|
end: e.start
|
|
470
555
|
};
|
|
471
556
|
}
|
|
472
|
-
|
|
473
|
-
return e.gaps.
|
|
557
|
+
hasSlotContent(e) {
|
|
558
|
+
return e.gaps.slot !== void 0;
|
|
474
559
|
}
|
|
475
560
|
extractSubstring(e, t) {
|
|
476
561
|
return e !== void 0 && t !== void 0 ? this.input.substring(e, t) : "";
|
|
477
562
|
}
|
|
478
563
|
createTextToken(e, t) {
|
|
479
|
-
return
|
|
564
|
+
return ye(this.input, e, t);
|
|
480
565
|
}
|
|
481
|
-
|
|
482
|
-
if (!(!t || e.gaps.
|
|
566
|
+
createSlotSourceInfo(e, t) {
|
|
567
|
+
if (!(!t || e.gaps.slot === void 0)) return {
|
|
483
568
|
content: t,
|
|
484
|
-
start: e.gaps.
|
|
485
|
-
end: e.gaps.
|
|
569
|
+
start: e.gaps.slot.start,
|
|
570
|
+
end: e.gaps.slot.end
|
|
486
571
|
};
|
|
487
572
|
}
|
|
573
|
+
filterTokens(e) {
|
|
574
|
+
let { marksOnly: t, skipEmptyText: n } = this.options;
|
|
575
|
+
return !t && !n ? e : e.filter((e) => e.type === "text" ? !(t || n && e.position.start === e.position.end) : !0);
|
|
576
|
+
}
|
|
488
577
|
};
|
|
489
578
|
//#endregion
|
|
490
|
-
//#region ../../common/core/src/features/parsing/
|
|
491
|
-
function
|
|
579
|
+
//#region ../../common/core/src/features/parsing/parser/utils/processTokens.ts
|
|
580
|
+
function C(e, t) {
|
|
492
581
|
let n = "";
|
|
493
582
|
for (let r of e) if (r.type === "text") n += r.content;
|
|
494
583
|
else if (r.children.length > 0) {
|
|
495
|
-
let e =
|
|
584
|
+
let e = C(r.children, t), i = {
|
|
496
585
|
...r,
|
|
497
586
|
value: e
|
|
498
587
|
};
|
|
@@ -501,85 +590,88 @@ function oe(e, t) {
|
|
|
501
590
|
return n;
|
|
502
591
|
}
|
|
503
592
|
//#endregion
|
|
504
|
-
//#region ../../common/core/src/features/parsing/
|
|
505
|
-
function
|
|
593
|
+
//#region ../../common/core/src/features/parsing/parser/utils/annotate.ts
|
|
594
|
+
function w(e, t) {
|
|
506
595
|
let n = e;
|
|
507
|
-
return t.value !== void 0 && (n = n.replaceAll(
|
|
596
|
+
return t.value !== void 0 && (n = n.replaceAll(b.Value, t.value)), t.meta !== void 0 && (n = n.replaceAll(b.Meta, t.meta)), t.slot !== void 0 && (n = n.replaceAll(b.Slot, t.slot)), n;
|
|
508
597
|
}
|
|
509
598
|
//#endregion
|
|
510
|
-
//#region ../../common/core/src/features/parsing/
|
|
511
|
-
function
|
|
599
|
+
//#region ../../common/core/src/features/parsing/parser/utils/toString.ts
|
|
600
|
+
function T(e) {
|
|
512
601
|
let t = "";
|
|
513
602
|
for (let n of e) {
|
|
514
603
|
if (n.type === "text") {
|
|
515
604
|
t += n.content;
|
|
516
605
|
continue;
|
|
517
606
|
}
|
|
518
|
-
let e = n.descriptor
|
|
519
|
-
t +=
|
|
607
|
+
let { markup: e, hasSlot: r } = n.descriptor, i = r ? n.children.length > 0 ? T(n.children) : n.slot?.content : void 0;
|
|
608
|
+
t += w(e, {
|
|
520
609
|
value: n.value,
|
|
521
610
|
meta: n.meta,
|
|
522
|
-
|
|
611
|
+
slot: i
|
|
523
612
|
});
|
|
524
613
|
}
|
|
525
614
|
return t;
|
|
526
615
|
}
|
|
527
616
|
//#endregion
|
|
528
|
-
//#region ../../common/core/src/features/parsing/
|
|
529
|
-
var
|
|
617
|
+
//#region ../../common/core/src/features/parsing/parser/Parser.ts
|
|
618
|
+
var xe = class e {
|
|
530
619
|
registry;
|
|
531
620
|
segmentMatcher;
|
|
532
621
|
patternMatcher;
|
|
533
622
|
treeBuilder;
|
|
534
|
-
|
|
535
|
-
|
|
623
|
+
parseOptions;
|
|
624
|
+
constructor(e, t) {
|
|
625
|
+
this.registry = new fe(e), this.segmentMatcher = new ve(this.registry.segments), this.patternMatcher = new ge(this.registry), this.parseOptions = t ?? {}, this.treeBuilder = new be(this.parseOptions);
|
|
536
626
|
}
|
|
537
627
|
static parse(t, n) {
|
|
538
628
|
let r = n?.markup;
|
|
539
|
-
|
|
629
|
+
if (!r || r.length === 0) return [ye(t)];
|
|
630
|
+
let { markup: i, ...a } = n;
|
|
631
|
+
return new e(r, a).parse(t);
|
|
540
632
|
}
|
|
541
633
|
static stringify(e) {
|
|
542
|
-
return
|
|
634
|
+
return T(e);
|
|
543
635
|
}
|
|
544
636
|
parse(e) {
|
|
545
637
|
let t = this.segmentMatcher.search(e), n = this.patternMatcher.process(t);
|
|
546
638
|
return this.treeBuilder.build(n, e);
|
|
547
639
|
}
|
|
548
640
|
stringify(e) {
|
|
549
|
-
return
|
|
641
|
+
return T(e);
|
|
550
642
|
}
|
|
551
643
|
transform(e, t) {
|
|
552
|
-
return
|
|
644
|
+
return C(this.parse(e), t);
|
|
553
645
|
}
|
|
554
646
|
escape(e) {
|
|
555
|
-
return this.registry.segments.filter((e) => typeof e == "string").
|
|
647
|
+
return this.registry.segments.filter((e) => typeof e == "string").toSorted((e, t) => t.length - e.length).reduce((e, t) => e.replaceAll(t, t.replace(/(.)/g, "\\$1")), e);
|
|
556
648
|
}
|
|
557
649
|
unescape(e) {
|
|
558
650
|
return e.replaceAll(/\\(.)/g, "$1");
|
|
559
651
|
}
|
|
560
652
|
};
|
|
561
653
|
//#endregion
|
|
562
|
-
//#region ../../common/core/src/features/parsing/
|
|
563
|
-
function
|
|
564
|
-
return n.length ?
|
|
654
|
+
//#region ../../common/core/src/features/parsing/parser/utils/denote.ts
|
|
655
|
+
function Se(e, t, n) {
|
|
656
|
+
return n.length ? C(new xe(n).parse(e), t) : e;
|
|
565
657
|
}
|
|
566
658
|
//#endregion
|
|
567
659
|
//#region ../../common/core/src/features/parsing/utils/findToken.ts
|
|
568
|
-
function
|
|
660
|
+
function E(e, t, n = 0, r) {
|
|
569
661
|
for (let i of e) {
|
|
570
662
|
if (i === t) return {
|
|
571
663
|
depth: n,
|
|
572
664
|
parent: r
|
|
573
665
|
};
|
|
574
666
|
if (i.type === "mark") {
|
|
575
|
-
let e =
|
|
667
|
+
let e = E(i.children, t, n + 1, i);
|
|
576
668
|
if (e) return e;
|
|
577
669
|
}
|
|
578
670
|
}
|
|
579
671
|
}
|
|
580
672
|
//#endregion
|
|
581
|
-
//#region ../../common/core/src/features/preparsing/utils/findGap.ts
|
|
582
|
-
function
|
|
673
|
+
//#region ../../common/core/src/features/parsing/preparsing/utils/findGap.ts
|
|
674
|
+
function Ce(e = "", t = "") {
|
|
583
675
|
if (e === t) return {};
|
|
584
676
|
let n;
|
|
585
677
|
for (let r = 0; r < e.length; r++) if (e[r] !== t[r]) {
|
|
@@ -597,8 +689,8 @@ function le(e = "", t = "") {
|
|
|
597
689
|
};
|
|
598
690
|
}
|
|
599
691
|
//#endregion
|
|
600
|
-
//#region ../../common/core/src/features/preparsing/utils/getClosestIndexes.ts
|
|
601
|
-
function
|
|
692
|
+
//#region ../../common/core/src/features/parsing/preparsing/utils/getClosestIndexes.ts
|
|
693
|
+
function we(e, t) {
|
|
602
694
|
let n = -1, r = e.length;
|
|
603
695
|
for (; r - n > 1;) {
|
|
604
696
|
let i = Math.round((n + r) / 2);
|
|
@@ -608,49 +700,47 @@ function ue(e, t) {
|
|
|
608
700
|
}
|
|
609
701
|
//#endregion
|
|
610
702
|
//#region ../../common/core/src/features/parsing/utils/valueParser.ts
|
|
611
|
-
function
|
|
703
|
+
function Te(e) {
|
|
612
704
|
let { focus: t } = e.nodes, n = e.state.parser.get(), r = e.state.tokens.get();
|
|
613
705
|
if (!n) return r;
|
|
614
706
|
let i = n.parse(t.content);
|
|
615
707
|
return i.length === 1 ? r : r.toSpliced(t.index, 1, ...i);
|
|
616
708
|
}
|
|
617
|
-
function
|
|
618
|
-
let t = e.state.value.get(), n =
|
|
709
|
+
function Ee(e) {
|
|
710
|
+
let t = e.state.value.get(), n = De(e), r = Ce(e.state.previousValue.get(), t);
|
|
619
711
|
if (!r.left && !r.right) return e.state.previousValue.set(t), e.state.tokens.get();
|
|
620
712
|
e.state.previousValue.set(t);
|
|
621
713
|
let i = e.state.tokens.get();
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
return a.length === 1 ? i : i.toSpliced(t, 1, ...a);
|
|
630
|
-
}
|
|
631
|
-
case r.right !== void 0: {
|
|
632
|
-
let [t] = ue(n, r.right), a = L(e, t);
|
|
633
|
-
return a.length === 1 ? i : i.toSpliced(t, 1, ...a);
|
|
634
|
-
}
|
|
635
|
-
default: return R(e, t ?? "");
|
|
714
|
+
if (r.left !== void 0 && n.includes(r.left) && r.right !== void 0 && Math.abs(r.left - r.right) > 1) {
|
|
715
|
+
let t = n.indexOf(r.left), a = D(e, t - 1, t);
|
|
716
|
+
return i.toSpliced(t - 1, 2, ...a);
|
|
717
|
+
}
|
|
718
|
+
if (r.left !== void 0) {
|
|
719
|
+
let [t] = we(n, r.left), a = D(e, t);
|
|
720
|
+
return a.length === 1 ? i : i.toSpliced(t, 1, ...a);
|
|
636
721
|
}
|
|
722
|
+
if (r.right !== void 0) {
|
|
723
|
+
let [t] = we(n, r.right), a = D(e, t);
|
|
724
|
+
return a.length === 1 ? i : i.toSpliced(t, 1, ...a);
|
|
725
|
+
}
|
|
726
|
+
return O(e, t ?? "");
|
|
637
727
|
}
|
|
638
|
-
function
|
|
728
|
+
function D(e, ...t) {
|
|
639
729
|
let n = "", r = e.state.tokens.get();
|
|
640
730
|
for (let e of t) {
|
|
641
731
|
let t = r[e];
|
|
642
732
|
n += t.content;
|
|
643
733
|
}
|
|
644
|
-
return
|
|
734
|
+
return O(e, n);
|
|
645
735
|
}
|
|
646
|
-
function
|
|
736
|
+
function De(e) {
|
|
647
737
|
let t = 0;
|
|
648
738
|
return e.state.tokens.get().map((e) => {
|
|
649
739
|
let n = e.content.length;
|
|
650
740
|
return t += n, t - n;
|
|
651
|
-
})
|
|
741
|
+
});
|
|
652
742
|
}
|
|
653
|
-
function
|
|
743
|
+
function O(e, t) {
|
|
654
744
|
let n = e.state.parser.get();
|
|
655
745
|
return n ? n.parse(t) : [{
|
|
656
746
|
type: "text",
|
|
@@ -663,12 +753,12 @@ function R(e, t) {
|
|
|
663
753
|
}
|
|
664
754
|
//#endregion
|
|
665
755
|
//#region ../../common/core/src/shared/classes/Reactive.ts
|
|
666
|
-
var
|
|
756
|
+
var Oe = (e, t) => e === t, k = class e {
|
|
667
757
|
#e;
|
|
668
758
|
#t = /* @__PURE__ */ new Set();
|
|
669
759
|
#n;
|
|
670
760
|
constructor(e, t) {
|
|
671
|
-
this.#e = e, this.#n = t?.equals ??
|
|
761
|
+
this.#e = e, this.#n = t?.equals ?? Oe;
|
|
672
762
|
}
|
|
673
763
|
static event() {
|
|
674
764
|
return new e(void 0, { equals: !1 });
|
|
@@ -677,13 +767,13 @@ var me = (e, t) => e === t, z = class e {
|
|
|
677
767
|
return this.#e;
|
|
678
768
|
}
|
|
679
769
|
set value(e) {
|
|
680
|
-
|
|
770
|
+
this.setSilent(e) && this.notify();
|
|
681
771
|
}
|
|
682
772
|
on(e) {
|
|
683
773
|
return this.#t.add(e), () => this.#t.delete(e);
|
|
684
774
|
}
|
|
685
775
|
emit(e) {
|
|
686
|
-
|
|
776
|
+
e !== void 0 && (this.#e = e), this.#t.forEach((e) => e(this.#e));
|
|
687
777
|
}
|
|
688
778
|
get() {
|
|
689
779
|
return this.#e;
|
|
@@ -691,49 +781,204 @@ var me = (e, t) => e === t, z = class e {
|
|
|
691
781
|
set(e) {
|
|
692
782
|
this.value = e;
|
|
693
783
|
}
|
|
784
|
+
setSilent(e) {
|
|
785
|
+
return this.#n === !1 || !this.#n(this.#e, e) ? (this.#e = e, !0) : !1;
|
|
786
|
+
}
|
|
787
|
+
notify() {
|
|
788
|
+
this.#t.forEach((e) => e(this.#e));
|
|
789
|
+
}
|
|
694
790
|
};
|
|
695
791
|
//#endregion
|
|
696
792
|
//#region ../../common/core/src/shared/classes/defineState.ts
|
|
697
|
-
function
|
|
793
|
+
function ke(e, t) {
|
|
698
794
|
let n = {};
|
|
699
795
|
return n.get = () => e.get(), n.set = (t) => e.set(t), n.on = (t) => e.on(t), n.use = t(n), n;
|
|
700
796
|
}
|
|
701
|
-
function
|
|
702
|
-
let
|
|
703
|
-
for (let t in e)
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
797
|
+
function Ae(e, t, n) {
|
|
798
|
+
let r = /* @__PURE__ */ new Map();
|
|
799
|
+
for (let t in e) {
|
|
800
|
+
let i = n?.equals?.[t];
|
|
801
|
+
r.set(t, new k(e[t], i == null ? void 0 : { equals: i }));
|
|
802
|
+
}
|
|
803
|
+
return new Proxy(e, { get(e, n) {
|
|
804
|
+
if (n === "set") return (e) => {
|
|
805
|
+
let t = [];
|
|
806
|
+
for (let n in e) {
|
|
807
|
+
let i = r.get(n);
|
|
808
|
+
i?.setSilent(e[n]) && t.push(i);
|
|
809
|
+
}
|
|
810
|
+
for (let e of t) e.notify();
|
|
707
811
|
};
|
|
708
|
-
let i =
|
|
709
|
-
if (i) return
|
|
812
|
+
let i = r.get(n);
|
|
813
|
+
if (i) return ke(i, t);
|
|
710
814
|
} });
|
|
711
815
|
}
|
|
712
816
|
//#endregion
|
|
713
817
|
//#region ../../common/core/src/shared/classes/defineEvents.ts
|
|
714
|
-
function
|
|
715
|
-
|
|
818
|
+
function je(e) {
|
|
819
|
+
return Object.assign((t) => {
|
|
716
820
|
e.emit(t);
|
|
717
|
-
};
|
|
718
|
-
return t.on = (t) => e.on(t), t;
|
|
821
|
+
}, { on: (t) => e.on(t) });
|
|
719
822
|
}
|
|
720
|
-
function
|
|
823
|
+
function Me(e) {
|
|
721
824
|
let t = e ? Object.keys(e) : [], n = /* @__PURE__ */ new Map();
|
|
722
|
-
for (let e of t) n.set(e,
|
|
825
|
+
for (let e of t) n.set(e, k.event());
|
|
723
826
|
return new Proxy({}, { get(e, t) {
|
|
724
827
|
let r = n.get(t);
|
|
725
|
-
return r || (r =
|
|
828
|
+
return r || (r = k.event(), n.set(t, r)), je(r);
|
|
726
829
|
} });
|
|
727
830
|
}
|
|
728
831
|
//#endregion
|
|
729
|
-
//#region ../../common/core/src/
|
|
730
|
-
|
|
832
|
+
//#region ../../common/core/src/features/drag/eventHandlers.ts
|
|
833
|
+
function Ne(e, t) {
|
|
834
|
+
return e < t.top + t.height / 2 ? "before" : "after";
|
|
835
|
+
}
|
|
836
|
+
function Pe(e) {
|
|
837
|
+
let t = parseInt(e.getData("text/plain"), 10);
|
|
838
|
+
return isNaN(t) ? null : t;
|
|
839
|
+
}
|
|
840
|
+
function Fe(e, t) {
|
|
841
|
+
return t === "before" ? e : e + 1;
|
|
842
|
+
}
|
|
843
|
+
//#endregion
|
|
844
|
+
//#region ../../common/core/src/shared/utils/menuUtils.ts
|
|
845
|
+
function Ie(e, t) {
|
|
846
|
+
return !!t && !t.contains(e instanceof Node ? e : null);
|
|
847
|
+
}
|
|
848
|
+
function Le(e) {
|
|
849
|
+
return e.key === "Escape";
|
|
850
|
+
}
|
|
851
|
+
//#endregion
|
|
852
|
+
//#region ../../common/core/src/shared/classes/BlockStore.ts
|
|
853
|
+
var Re = class {
|
|
854
|
+
refs = { container: null };
|
|
855
|
+
state;
|
|
856
|
+
#e = 0;
|
|
857
|
+
#t = null;
|
|
858
|
+
#n;
|
|
859
|
+
#r;
|
|
860
|
+
#i;
|
|
861
|
+
constructor(e) {
|
|
862
|
+
this.state = Ae({
|
|
863
|
+
isHovered: !1,
|
|
864
|
+
isDragging: !1,
|
|
865
|
+
dropPosition: null,
|
|
866
|
+
menuOpen: !1,
|
|
867
|
+
menuPosition: {
|
|
868
|
+
top: 0,
|
|
869
|
+
left: 0
|
|
870
|
+
}
|
|
871
|
+
}, e);
|
|
872
|
+
}
|
|
873
|
+
attachContainer(e, t, n) {
|
|
874
|
+
if (this.#e = t, this.#t = n, e === this.refs.container || (this.#n?.(), this.refs.container = e, !e)) return;
|
|
875
|
+
let r = () => this.state.isHovered.set(!0), i = () => this.state.isHovered.set(!1), a = (t) => {
|
|
876
|
+
t.dataTransfer && (t.preventDefault(), t.dataTransfer.dropEffect = "move", this.state.dropPosition.set(Ne(t.clientY, e.getBoundingClientRect())));
|
|
877
|
+
}, o = (e) => {
|
|
878
|
+
let t = e.currentTarget;
|
|
879
|
+
t instanceof Node && t.contains(e.relatedTarget instanceof Node ? e.relatedTarget : null) || this.state.dropPosition.set(null);
|
|
880
|
+
}, s = (e) => {
|
|
881
|
+
if (!e.dataTransfer) return;
|
|
882
|
+
e.preventDefault();
|
|
883
|
+
let t = Pe(e.dataTransfer);
|
|
884
|
+
if (t === null) return;
|
|
885
|
+
let r = Fe(this.#e, this.state.dropPosition.get() ?? "after");
|
|
886
|
+
this.state.dropPosition.set(null), n.reorder(t, r);
|
|
887
|
+
};
|
|
888
|
+
e.addEventListener("mouseenter", r), e.addEventListener("mouseleave", i), e.addEventListener("dragover", a), e.addEventListener("dragleave", o), e.addEventListener("drop", s), this.#n = () => {
|
|
889
|
+
e.removeEventListener("mouseenter", r), e.removeEventListener("mouseleave", i), e.removeEventListener("dragover", a), e.removeEventListener("dragleave", o), e.removeEventListener("drop", s);
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
attachGrip(e, t, n) {
|
|
893
|
+
if (this.#e = t, this.#t = n, this.#r?.(), !e) return;
|
|
894
|
+
let r = (e) => {
|
|
895
|
+
e.dataTransfer && (e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/plain", String(this.#e)), this.state.isDragging.set(!0), this.refs.container && e.dataTransfer.setDragImage(this.refs.container, 0, 0));
|
|
896
|
+
}, i = () => {
|
|
897
|
+
this.state.isDragging.set(!1), this.state.dropPosition.set(null);
|
|
898
|
+
}, a = (t) => {
|
|
899
|
+
t.preventDefault();
|
|
900
|
+
let n = e.getBoundingClientRect();
|
|
901
|
+
this.state.menuPosition.set({
|
|
902
|
+
top: n.bottom + 4,
|
|
903
|
+
left: n.left
|
|
904
|
+
}), this.state.menuOpen.set(!0);
|
|
905
|
+
};
|
|
906
|
+
e.addEventListener("dragstart", r), e.addEventListener("dragend", i), e.addEventListener("click", a), this.#r = () => {
|
|
907
|
+
e.removeEventListener("dragstart", r), e.removeEventListener("dragend", i), e.removeEventListener("click", a);
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
attachMenu(e) {
|
|
911
|
+
if (this.#i?.(), !e) return;
|
|
912
|
+
let t = (t) => {
|
|
913
|
+
Ie(t.target, e) && this.closeMenu();
|
|
914
|
+
}, n = (e) => {
|
|
915
|
+
Le(e) && this.closeMenu();
|
|
916
|
+
};
|
|
917
|
+
document.addEventListener("mousedown", t), document.addEventListener("keydown", n), this.#i = () => {
|
|
918
|
+
document.removeEventListener("mousedown", t), document.removeEventListener("keydown", n);
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
closeMenu = () => this.state.menuOpen.set(!1);
|
|
922
|
+
addBlock = () => {
|
|
923
|
+
this.#t && (this.#t.add(this.#e), this.closeMenu());
|
|
924
|
+
};
|
|
925
|
+
deleteBlock = () => {
|
|
926
|
+
this.#t && (this.#t.delete(this.#e), this.closeMenu());
|
|
927
|
+
};
|
|
928
|
+
duplicateBlock = () => {
|
|
929
|
+
this.#t && (this.#t.duplicate(this.#e), this.closeMenu());
|
|
930
|
+
};
|
|
931
|
+
}, ze = class {
|
|
932
|
+
#e = /* @__PURE__ */ new WeakMap();
|
|
933
|
+
#t;
|
|
934
|
+
constructor(e) {
|
|
935
|
+
this.#t = e;
|
|
936
|
+
}
|
|
937
|
+
get(e) {
|
|
938
|
+
let t = this.#e.get(e);
|
|
939
|
+
return t || (t = new Re(this.#t), this.#e.set(e, t)), t;
|
|
940
|
+
}
|
|
941
|
+
}, Be = class {
|
|
731
942
|
#e = 1;
|
|
732
943
|
#t = /* @__PURE__ */ new WeakMap();
|
|
733
944
|
get(e) {
|
|
734
945
|
return this.#t.has(e) ? this.#t.get(e) : (this.#t.set(e, this.#e), this.#e++);
|
|
735
946
|
}
|
|
736
|
-
}
|
|
947
|
+
};
|
|
948
|
+
//#endregion
|
|
949
|
+
//#region ../../common/core/src/shared/checkers/domGuards.ts
|
|
950
|
+
function A(e) {
|
|
951
|
+
return typeof HTMLElement < "u" && e instanceof HTMLElement;
|
|
952
|
+
}
|
|
953
|
+
function j(e) {
|
|
954
|
+
return e instanceof Text;
|
|
955
|
+
}
|
|
956
|
+
function M(e, t) {
|
|
957
|
+
let n = e?.children[t];
|
|
958
|
+
return n instanceof HTMLElement ? n : void 0;
|
|
959
|
+
}
|
|
960
|
+
function N(e) {
|
|
961
|
+
return e ? Array.from(e.children).filter((e) => e instanceof HTMLElement) : [];
|
|
962
|
+
}
|
|
963
|
+
function Ve(e) {
|
|
964
|
+
let t = e?.firstElementChild;
|
|
965
|
+
return t instanceof HTMLElement ? t : null;
|
|
966
|
+
}
|
|
967
|
+
function He(e) {
|
|
968
|
+
let t = e?.lastElementChild;
|
|
969
|
+
return t instanceof HTMLElement ? t : null;
|
|
970
|
+
}
|
|
971
|
+
function Ue(e) {
|
|
972
|
+
let { target: t } = e;
|
|
973
|
+
return t instanceof Node ? t : null;
|
|
974
|
+
}
|
|
975
|
+
function P(e) {
|
|
976
|
+
let t = e.nextNode();
|
|
977
|
+
return t?.nodeType === 3 ? t : null;
|
|
978
|
+
}
|
|
979
|
+
//#endregion
|
|
980
|
+
//#region ../../common/core/src/features/caret/Caret.ts
|
|
981
|
+
var F = class {
|
|
737
982
|
static get isSelectedPosition() {
|
|
738
983
|
let e = window.getSelection();
|
|
739
984
|
if (e) return e.isCollapsed;
|
|
@@ -746,11 +991,11 @@ var ye = class {
|
|
|
746
991
|
}
|
|
747
992
|
static getSelectedNode() {
|
|
748
993
|
let e = window.getSelection()?.anchorNode;
|
|
749
|
-
if (e) return e;
|
|
994
|
+
if (e && document.contains(e)) return e;
|
|
750
995
|
throw Error("Anchor node of selection is not exists!");
|
|
751
996
|
}
|
|
752
997
|
static getAbsolutePosition() {
|
|
753
|
-
let e = window.getSelection()?.getRangeAt(0).getBoundingClientRect
|
|
998
|
+
let e = window.getSelection()?.getRangeAt(0).getBoundingClientRect();
|
|
754
999
|
return e ? {
|
|
755
1000
|
left: e.left,
|
|
756
1001
|
top: e.top + e.height + 1
|
|
@@ -779,19 +1024,19 @@ var ye = class {
|
|
|
779
1024
|
return t.bottom > n.bottom - t.height - 2;
|
|
780
1025
|
}
|
|
781
1026
|
static setAtX(e, t, n) {
|
|
782
|
-
let r = e.getBoundingClientRect(), i = n ?? r.top + r.height / 2, a = document.caretRangeFromPoint?.(t, i) ??
|
|
783
|
-
if (!a) return;
|
|
784
|
-
let o = window.getSelection();
|
|
1027
|
+
let r = e.getBoundingClientRect(), i = n ?? r.top + r.height / 2, a = document, o = a.caretRangeFromPoint?.(t, i) ?? a.caretPositionFromPoint?.(t, i);
|
|
785
1028
|
if (!o) return;
|
|
786
|
-
let s;
|
|
787
|
-
if (
|
|
788
|
-
|
|
1029
|
+
let s = window.getSelection();
|
|
1030
|
+
if (!s) return;
|
|
1031
|
+
let c;
|
|
1032
|
+
if (o instanceof Range) c = o;
|
|
1033
|
+
else if ("offsetNode" in o) c = document.createRange(), c.setStart(o.offsetNode, o.offset), c.collapse(!0);
|
|
789
1034
|
else return;
|
|
790
|
-
if (!e.contains(
|
|
1035
|
+
if (!e.contains(c.startContainer)) {
|
|
791
1036
|
this.setIndex(e, Infinity);
|
|
792
1037
|
return;
|
|
793
1038
|
}
|
|
794
|
-
|
|
1039
|
+
s.removeAllRanges(), s.addRange(c);
|
|
795
1040
|
}
|
|
796
1041
|
static trySetIndex(e, t) {
|
|
797
1042
|
try {
|
|
@@ -803,11 +1048,11 @@ var ye = class {
|
|
|
803
1048
|
static setIndex(e, t) {
|
|
804
1049
|
let n = window.getSelection();
|
|
805
1050
|
if (!n) return;
|
|
806
|
-
let r = document.createTreeWalker(e, 4), i = r
|
|
1051
|
+
let r = document.createTreeWalker(e, 4), i = P(r);
|
|
807
1052
|
if (!i) return;
|
|
808
1053
|
let a = isFinite(t) ? Math.max(0, t) : Infinity;
|
|
809
|
-
for (
|
|
810
|
-
let e = r
|
|
1054
|
+
for (;;) {
|
|
1055
|
+
let e = P(r);
|
|
811
1056
|
if (!e || a <= i.length) {
|
|
812
1057
|
let e = isFinite(a) ? Math.min(a, i.length) : i.length, t = document.createRange();
|
|
813
1058
|
t.setStart(i, e), t.collapse(!0), n.removeAllRanges(), n.addRange(t);
|
|
@@ -832,22 +1077,26 @@ var ye = class {
|
|
|
832
1077
|
let t = window.getSelection();
|
|
833
1078
|
if (!t?.anchorNode || !t.rangeCount) return;
|
|
834
1079
|
let n = t.getRangeAt(0);
|
|
835
|
-
n
|
|
1080
|
+
n.setStart(n.startContainer.firstChild ?? n.startContainer, e), n.setEnd(n.startContainer.firstChild ?? n.startContainer, e);
|
|
836
1081
|
}
|
|
837
1082
|
setCaretRightTo(e, t) {
|
|
838
1083
|
let n = window.getSelection()?.getRangeAt(0);
|
|
839
1084
|
n?.setStart(n.endContainer, t), n?.setEnd(n.endContainer, t);
|
|
840
1085
|
}
|
|
841
|
-
},
|
|
1086
|
+
}, We = /* @__PURE__ */ new RegExp(/^\w*/), Ge = class e {
|
|
842
1087
|
span;
|
|
843
1088
|
node;
|
|
844
1089
|
dividedText;
|
|
845
1090
|
constructor() {
|
|
846
|
-
let e =
|
|
847
|
-
this.node =
|
|
1091
|
+
let e = F.getCurrentPosition();
|
|
1092
|
+
this.node = F.getSelectedNode(), this.span = F.getFocusedSpan(), this.dividedText = this.getDividedTextBy(e);
|
|
848
1093
|
}
|
|
849
1094
|
static find(t, n) {
|
|
850
|
-
if (t &&
|
|
1095
|
+
if (t && F.isSelectedPosition) try {
|
|
1096
|
+
return new e().find(t, n);
|
|
1097
|
+
} catch {
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
851
1100
|
}
|
|
852
1101
|
getDividedTextBy(e) {
|
|
853
1102
|
return {
|
|
@@ -880,7 +1129,7 @@ var ye = class {
|
|
|
880
1129
|
}
|
|
881
1130
|
matchRightPart() {
|
|
882
1131
|
let { right: e } = this.dividedText;
|
|
883
|
-
return { word: e.match(
|
|
1132
|
+
return { word: e.match(We)?.[0] };
|
|
884
1133
|
}
|
|
885
1134
|
matchLeftPart(e) {
|
|
886
1135
|
let t = this.makeTriggerRegex(e), { left: n } = this.dividedText, r = n.match(t);
|
|
@@ -893,17 +1142,17 @@ var ye = class {
|
|
|
893
1142
|
};
|
|
894
1143
|
}
|
|
895
1144
|
makeTriggerRegex(e) {
|
|
896
|
-
let t =
|
|
1145
|
+
let t = S(e) + "(\\w*)$";
|
|
897
1146
|
return new RegExp(t);
|
|
898
1147
|
}
|
|
899
|
-
},
|
|
1148
|
+
}, Ke = class e {
|
|
900
1149
|
#e;
|
|
901
1150
|
#t;
|
|
902
1151
|
get target() {
|
|
903
1152
|
return this.#e;
|
|
904
1153
|
}
|
|
905
1154
|
set target(e) {
|
|
906
|
-
this.#e = e;
|
|
1155
|
+
this.#e = A(e) ? e : void 0;
|
|
907
1156
|
}
|
|
908
1157
|
get next() {
|
|
909
1158
|
return new e(this.target?.nextSibling, this.#t);
|
|
@@ -921,22 +1170,22 @@ var ye = class {
|
|
|
921
1170
|
return this.target?.isContentEditable ?? !1;
|
|
922
1171
|
}
|
|
923
1172
|
get isCaretAtBeginning() {
|
|
924
|
-
if (this.target) return
|
|
1173
|
+
if (this.target) return F.getCaretIndex(this.target) === 0;
|
|
925
1174
|
}
|
|
926
1175
|
get isCaretAtEnd() {
|
|
927
|
-
if (this.target) return
|
|
1176
|
+
if (this.target) return F.getCaretIndex(this.target) === this.target.textContent.length;
|
|
928
1177
|
}
|
|
929
1178
|
get index() {
|
|
930
1179
|
return this.target?.parentElement ? [...this.target.parentElement.children].indexOf(this.target) : -1;
|
|
931
1180
|
}
|
|
932
1181
|
get caret() {
|
|
933
|
-
return this.target ?
|
|
1182
|
+
return this.target ? F.getCaretIndex(this.target) : -1;
|
|
934
1183
|
}
|
|
935
1184
|
set caret(e) {
|
|
936
|
-
this.target &&
|
|
1185
|
+
this.target && F.trySetIndex(this.target, e);
|
|
937
1186
|
}
|
|
938
1187
|
get length() {
|
|
939
|
-
return this.target?.textContent
|
|
1188
|
+
return this.target?.textContent.length ?? -1;
|
|
940
1189
|
}
|
|
941
1190
|
get content() {
|
|
942
1191
|
return this.target?.textContent ?? "";
|
|
@@ -945,10 +1194,10 @@ var ye = class {
|
|
|
945
1194
|
this.target && (this.target.textContent = e ?? "");
|
|
946
1195
|
}
|
|
947
1196
|
get head() {
|
|
948
|
-
return this.#t.refs.container
|
|
1197
|
+
return Ve(this.#t.refs.container ?? void 0);
|
|
949
1198
|
}
|
|
950
1199
|
get tail() {
|
|
951
|
-
return this.#t.refs.container
|
|
1200
|
+
return He(this.#t.refs.container ?? void 0);
|
|
952
1201
|
}
|
|
953
1202
|
get isFocused() {
|
|
954
1203
|
return this.target === document.activeElement;
|
|
@@ -957,7 +1206,7 @@ var ye = class {
|
|
|
957
1206
|
this.target = e, this.#t = t;
|
|
958
1207
|
}
|
|
959
1208
|
setCaretToEnd() {
|
|
960
|
-
|
|
1209
|
+
F.setCaretToEnd(this.target);
|
|
961
1210
|
}
|
|
962
1211
|
focus() {
|
|
963
1212
|
this.target?.focus();
|
|
@@ -967,37 +1216,118 @@ var ye = class {
|
|
|
967
1216
|
}
|
|
968
1217
|
};
|
|
969
1218
|
//#endregion
|
|
970
|
-
//#region ../../common/core/src/features/
|
|
971
|
-
function
|
|
972
|
-
return e.
|
|
1219
|
+
//#region ../../common/core/src/features/drag/operations.ts
|
|
1220
|
+
function qe(e, t, n) {
|
|
1221
|
+
return e.substring(t.position.end, n.position.start);
|
|
1222
|
+
}
|
|
1223
|
+
function I(e) {
|
|
1224
|
+
return e.type === "mark" && e.descriptor.hasSlot && e.descriptor.segments.length === 1;
|
|
1225
|
+
}
|
|
1226
|
+
function L(e, t) {
|
|
1227
|
+
return !!(e.type === "text" && t.type === "text" && t.position.start > e.position.end || I(e) && I(t) && e.descriptor === t.descriptor);
|
|
1228
|
+
}
|
|
1229
|
+
function Je(e, t, n, r) {
|
|
1230
|
+
if (t.length === 0) return e + r;
|
|
1231
|
+
if (e === "" || t.length === 1 && t[0].type === "text" && t[0].content === "") return r + r;
|
|
1232
|
+
if (n >= t.length - 1) return e + r;
|
|
1233
|
+
let i = t[n + 1].position.start;
|
|
1234
|
+
return e.slice(0, i) + r + e.slice(i);
|
|
1235
|
+
}
|
|
1236
|
+
function Ye(e, t, n) {
|
|
1237
|
+
return t.length <= 1 ? "" : n >= t.length - 1 ? e.slice(0, t[n - 1].position.end) : e.slice(0, t[n].position.start) + e.slice(t[n + 1].position.start);
|
|
1238
|
+
}
|
|
1239
|
+
function Xe(e, t, n) {
|
|
1240
|
+
let r = t[n], i = e.substring(r.position.start, r.position.end);
|
|
1241
|
+
if (n >= t.length - 1) return e + i;
|
|
1242
|
+
let a = t[n + 1], o = qe(e, r, a);
|
|
1243
|
+
return e.slice(0, a.position.start) + i + o + e.slice(a.position.start);
|
|
1244
|
+
}
|
|
1245
|
+
function R(e, t) {
|
|
1246
|
+
if (t <= 0 || t >= e.length) return 0;
|
|
1247
|
+
let n = e[t - 1];
|
|
1248
|
+
return I(n) && n.slot ? n.slot.end : n.position.end;
|
|
1249
|
+
}
|
|
1250
|
+
function z(e, t, n) {
|
|
1251
|
+
if (n <= 0 || n >= t.length) return e;
|
|
1252
|
+
let r = t[n - 1], i = t[n];
|
|
1253
|
+
if (I(r) && I(i)) {
|
|
1254
|
+
let t = r.slot ? r.slot.end : r.position.end;
|
|
1255
|
+
return e.slice(0, t) + e.slice(i.position.start);
|
|
1256
|
+
}
|
|
1257
|
+
return e.slice(0, r.position.end) + e.slice(i.position.start);
|
|
1258
|
+
}
|
|
1259
|
+
function Ze(e, t, n, r) {
|
|
1260
|
+
if (n === r || n === r - 1 || t.length < 2 || n < 0 || n >= t.length || r < 0 || r > t.length) return e;
|
|
1261
|
+
let i = t.map((t) => e.substring(t.position.start, t.position.end)), a = t.slice(0, -1).map((n, r) => qe(e, n, t[r + 1])), [o] = i.splice(n, 1), s = n < a.length ? n : n - 1;
|
|
1262
|
+
a.splice(s, 1);
|
|
1263
|
+
let c = r > n ? r - 1 : r;
|
|
1264
|
+
i.splice(c, 0, o), c < i.length - 1 && a.splice(c, 0, "");
|
|
1265
|
+
let l = [];
|
|
1266
|
+
for (let e = 0; e < i.length; e++) l.push(i[e]), e < a.length && l.push(a[e]);
|
|
1267
|
+
return l.join("");
|
|
973
1268
|
}
|
|
974
1269
|
//#endregion
|
|
975
|
-
//#region ../../common/core/src/features/
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
1270
|
+
//#region ../../common/core/src/features/drag/tokens.ts
|
|
1271
|
+
var Qe = {
|
|
1272
|
+
type: "text",
|
|
1273
|
+
content: "",
|
|
1274
|
+
position: {
|
|
1275
|
+
start: 0,
|
|
1276
|
+
end: 0
|
|
1277
|
+
}
|
|
1278
|
+
}, $e = class {
|
|
1279
|
+
constructor(e) {
|
|
1280
|
+
this.store = e;
|
|
1281
|
+
}
|
|
1282
|
+
enable() {}
|
|
1283
|
+
disable() {}
|
|
1284
|
+
reorder(e, t) {
|
|
1285
|
+
let n = this.store.state.value.get();
|
|
1286
|
+
if (n == null || !this.store.state.onChange.get()) return;
|
|
1287
|
+
let r = Ze(n, this.store.state.tokens.get(), e, t);
|
|
1288
|
+
r !== n && this.store.applyValue(r);
|
|
1289
|
+
}
|
|
1290
|
+
add(e) {
|
|
1291
|
+
let t = this.store.state.value.get();
|
|
1292
|
+
if (t == null || !this.store.state.onChange.get()) return;
|
|
1293
|
+
let n = this.store.state.tokens.get(), r = n.length > 0 ? n : [Qe], i = this.#e();
|
|
1294
|
+
this.store.applyValue(Je(t, r, e, i)), queueMicrotask(() => {
|
|
1295
|
+
let t = this.store.refs.container;
|
|
1296
|
+
t && M(t, e + 1)?.focus();
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
delete(e) {
|
|
1300
|
+
let t = this.store.state.value.get();
|
|
1301
|
+
if (t == null || !this.store.state.onChange.get()) return;
|
|
1302
|
+
let n = this.store.state.tokens.get();
|
|
1303
|
+
this.store.applyValue(Ye(t, n, e));
|
|
1304
|
+
}
|
|
1305
|
+
duplicate(e) {
|
|
1306
|
+
let t = this.store.state.value.get();
|
|
1307
|
+
if (t == null || !this.store.state.onChange.get()) return;
|
|
1308
|
+
let n = this.store.state.tokens.get();
|
|
1309
|
+
this.store.applyValue(Xe(t, n, e));
|
|
1310
|
+
}
|
|
1311
|
+
#e() {
|
|
1312
|
+
let e = this.store.state.options.get()?.[0];
|
|
1313
|
+
return e?.markup ? w(e.markup, {
|
|
1314
|
+
value: "",
|
|
1315
|
+
slot: "",
|
|
1316
|
+
meta: ""
|
|
1317
|
+
}) : "\n";
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
//#endregion
|
|
1321
|
+
//#region ../../common/core/src/features/drag/config.ts
|
|
1322
|
+
function et(e) {
|
|
1323
|
+
return typeof e == "object" && !!e.alwaysShowHandle;
|
|
997
1324
|
}
|
|
998
1325
|
//#endregion
|
|
999
1326
|
//#region ../../common/core/src/features/editable/ContentEditableController.ts
|
|
1000
|
-
|
|
1327
|
+
function tt(e) {
|
|
1328
|
+
return e.tagName === "SPAN" && (e.attributes.length === 0 || e.attributes.length === 1 && e.hasAttribute("contenteditable"));
|
|
1329
|
+
}
|
|
1330
|
+
var nt = class {
|
|
1001
1331
|
#e;
|
|
1002
1332
|
constructor(e) {
|
|
1003
1333
|
this.store = e;
|
|
@@ -1011,10 +1341,95 @@ var we = class {
|
|
|
1011
1341
|
sync() {
|
|
1012
1342
|
let e = this.store.refs.container;
|
|
1013
1343
|
if (!e) return;
|
|
1014
|
-
let t = this.store.state.readOnly.get() ? "false" : "true",
|
|
1015
|
-
|
|
1344
|
+
let t = this.store.state.readOnly.get(), n = t ? "false" : "true", r = e.children, i = !!this.store.state.drag.get();
|
|
1345
|
+
if (i) {
|
|
1346
|
+
let i = this.store.state.tokens.get();
|
|
1347
|
+
for (let a = 0; a < i.length && a < r.length; a++) {
|
|
1348
|
+
let r = M(e, a);
|
|
1349
|
+
r && (i[a].type === "mark" ? t || (r.tabIndex = 0) : r.contentEditable = n);
|
|
1350
|
+
}
|
|
1351
|
+
} else for (let t = 0; t < r.length; t += 2) {
|
|
1352
|
+
let r = M(e, t);
|
|
1353
|
+
r && (r.contentEditable = n);
|
|
1354
|
+
}
|
|
1355
|
+
let a = this.store.state.tokens.get();
|
|
1356
|
+
i ? this.#r(a, e, t) : this.#t(a, e);
|
|
1016
1357
|
}
|
|
1017
|
-
|
|
1358
|
+
#t(e, t) {
|
|
1359
|
+
for (let n = 0; n < e.length; n++) {
|
|
1360
|
+
let r = e[n], i = M(t, n);
|
|
1361
|
+
i && (r.type === "text" ? i.textContent !== r.content && (i.textContent = r.content) : r.children.length > 0 && this.#n(r.children, i));
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
#n(e, t, n) {
|
|
1365
|
+
let r = t.children, i = 0;
|
|
1366
|
+
for (let a of e) if (a.type === "text") {
|
|
1367
|
+
for (; i < r.length;) {
|
|
1368
|
+
let e = M(t, i);
|
|
1369
|
+
if (e && tt(e)) break;
|
|
1370
|
+
i++;
|
|
1371
|
+
}
|
|
1372
|
+
let e = M(t, i);
|
|
1373
|
+
e && (e.textContent !== a.content && (e.textContent = a.content), n !== void 0 && (e.contentEditable = n), i++);
|
|
1374
|
+
} else if (a.children.length > 0) {
|
|
1375
|
+
for (; i < r.length;) {
|
|
1376
|
+
let e = M(t, i);
|
|
1377
|
+
if (e && !tt(e)) break;
|
|
1378
|
+
i++;
|
|
1379
|
+
}
|
|
1380
|
+
let e = M(t, i);
|
|
1381
|
+
e && (this.#n(a.children, e, n), i++);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
#r(e, t, n) {
|
|
1385
|
+
let r = n ? "false" : "true";
|
|
1386
|
+
for (let i = 0; i < e.length; i++) {
|
|
1387
|
+
let a = e[i], o = M(t, i);
|
|
1388
|
+
if (!o) continue;
|
|
1389
|
+
if (a.type === "mark") {
|
|
1390
|
+
if (a.children.length > 0) {
|
|
1391
|
+
let e = o.hasAttribute("data-testid") ? M(o, n ? 0 : 1) : o;
|
|
1392
|
+
e && this.#n(a.children, e, r);
|
|
1393
|
+
}
|
|
1394
|
+
continue;
|
|
1395
|
+
}
|
|
1396
|
+
let s = M(o, n ? 0 : 1);
|
|
1397
|
+
s && s.textContent !== a.content && (s.textContent = a.content);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1401
|
+
//#endregion
|
|
1402
|
+
//#region ../../common/core/src/features/editing/utils/createNewSpan.ts
|
|
1403
|
+
function rt(e, t, n, r) {
|
|
1404
|
+
return e.slice(0, n) + t + e.slice(n + r.length);
|
|
1405
|
+
}
|
|
1406
|
+
//#endregion
|
|
1407
|
+
//#region ../../common/core/src/features/editing/utils/deleteMark.ts
|
|
1408
|
+
function B(e, t) {
|
|
1409
|
+
let n = {
|
|
1410
|
+
prev: 2,
|
|
1411
|
+
self: 1,
|
|
1412
|
+
next: 0
|
|
1413
|
+
}[e], { focus: r } = t.nodes, i = t.state.tokens.get(), a = i.splice(r.index - n, 3), o = a.at(0), s = a.at(2), c = o?.content ?? "", l = s?.content ?? "";
|
|
1414
|
+
t.state.tokens.set(i.toSpliced(r.index - n, 0, {
|
|
1415
|
+
type: "text",
|
|
1416
|
+
content: c + l,
|
|
1417
|
+
position: {
|
|
1418
|
+
start: o?.position.start ?? 0,
|
|
1419
|
+
end: s?.position.end ?? (c + l).length
|
|
1420
|
+
}
|
|
1421
|
+
}));
|
|
1422
|
+
let u = r;
|
|
1423
|
+
for (let e = 0; e < n; e++) u = u.prev;
|
|
1424
|
+
let d = u.length;
|
|
1425
|
+
t.state.recovery.set({
|
|
1426
|
+
anchor: u.prev,
|
|
1427
|
+
caret: d
|
|
1428
|
+
}), t.state.onChange.get()?.(T(t.state.tokens.get()));
|
|
1429
|
+
}
|
|
1430
|
+
//#endregion
|
|
1431
|
+
//#region ../../common/core/src/features/events/SystemListenerController.ts
|
|
1432
|
+
var it = class {
|
|
1018
1433
|
#e;
|
|
1019
1434
|
#t;
|
|
1020
1435
|
#n;
|
|
@@ -1023,39 +1438,43 @@ var we = class {
|
|
|
1023
1438
|
}
|
|
1024
1439
|
enable() {
|
|
1025
1440
|
this.#e || (this.#e = this.store.events.change.on(() => {
|
|
1026
|
-
let e = this.store.state.onChange.get();
|
|
1027
|
-
if (!
|
|
1028
|
-
|
|
1029
|
-
|
|
1441
|
+
let e = this.store.state.onChange.get(), { focus: t } = this.store.nodes;
|
|
1442
|
+
if (!t.target || !t.target.isContentEditable) {
|
|
1443
|
+
let t = this.store.state.tokens.get(), n = T(t);
|
|
1444
|
+
e?.(n), this.store.state.previousValue.set(n), this.store.state.tokens.set([...t]);
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
let n = this.store.state.tokens.get(), r = n[t.index];
|
|
1448
|
+
r.type === "text" ? r.content = t.content : r.value = t.content, e?.(T(n)), this.store.events.parse();
|
|
1030
1449
|
}), this.#t = this.store.events.delete.on((e) => {
|
|
1031
|
-
if (!e) return;
|
|
1032
1450
|
let { token: t } = e, n = this.store.state.onChange.get(), r = this.store.state.tokens.get(), i = r.indexOf(t);
|
|
1033
|
-
this.store.state.tokens.set(r.toSpliced(i, 1)), n?.(
|
|
1451
|
+
this.store.state.tokens.set(r.toSpliced(i, 1)), n?.(T(this.store.state.tokens.get()));
|
|
1034
1452
|
}), this.#n = this.store.events.select.on((e) => {
|
|
1035
|
-
|
|
1036
|
-
|
|
1453
|
+
let t = this.store.state.Mark.get(), n = this.store.state.onChange.get(), { mark: r, match: { option: i, span: a, index: o, source: s } } = e, c = i.markup;
|
|
1454
|
+
if (!c) return;
|
|
1455
|
+
let l = r.type === "mark" ? w(c, {
|
|
1037
1456
|
value: r.value,
|
|
1038
1457
|
meta: r.meta
|
|
1039
|
-
}) :
|
|
1458
|
+
}) : w(c, { value: r.content }), u = rt(a, l, o, s);
|
|
1040
1459
|
if (this.store.state.recovery.set(t ? {
|
|
1041
1460
|
caret: 0,
|
|
1042
1461
|
anchor: this.store.nodes.input.next,
|
|
1043
1462
|
isNext: !0,
|
|
1044
1463
|
childIndex: this.store.nodes.input.index
|
|
1045
1464
|
} : {
|
|
1046
|
-
caret: o +
|
|
1465
|
+
caret: o + l.length,
|
|
1047
1466
|
anchor: this.store.nodes.input
|
|
1048
1467
|
}), this.store.nodes.input.target) {
|
|
1049
|
-
this.store.nodes.input.content =
|
|
1468
|
+
this.store.nodes.input.content = u;
|
|
1050
1469
|
let e = this.store.state.tokens.get(), t = e[this.store.nodes.input.index];
|
|
1051
|
-
t.type === "text" && (t.content =
|
|
1470
|
+
t.type === "text" && (t.content = u), this.store.nodes.focus.target = this.store.nodes.input.target, this.store.nodes.input.clear(), n?.(T(e)), this.store.events.parse();
|
|
1052
1471
|
}
|
|
1053
1472
|
}));
|
|
1054
1473
|
}
|
|
1055
1474
|
disable() {
|
|
1056
1475
|
this.#e?.(), this.#t?.(), this.#n?.(), this.#e = void 0, this.#t = void 0, this.#n = void 0;
|
|
1057
1476
|
}
|
|
1058
|
-
},
|
|
1477
|
+
}, at = class {
|
|
1059
1478
|
#e;
|
|
1060
1479
|
#t;
|
|
1061
1480
|
#n;
|
|
@@ -1066,17 +1485,21 @@ var we = class {
|
|
|
1066
1485
|
if (this.#e) return;
|
|
1067
1486
|
let e = this.store.refs.container;
|
|
1068
1487
|
e && (this.#e = (e) => {
|
|
1069
|
-
|
|
1488
|
+
let t = A(e.target) ? e.target : void 0;
|
|
1489
|
+
this.store.nodes.focus.target = t;
|
|
1070
1490
|
}, this.#t = () => {
|
|
1071
1491
|
this.store.nodes.focus.target = void 0;
|
|
1072
1492
|
}, this.#n = () => {
|
|
1073
1493
|
let e = this.store.state.tokens.get();
|
|
1074
|
-
e.length === 1 && e[0].type === "text" && e[0].content === ""
|
|
1494
|
+
if (e.length === 1 && e[0].type === "text" && e[0].content === "") {
|
|
1495
|
+
let e = this.store.refs.container;
|
|
1496
|
+
(e ? Ve(e) : null)?.focus();
|
|
1497
|
+
}
|
|
1075
1498
|
}, e.addEventListener("focusin", this.#e), e.addEventListener("focusout", this.#t), e.addEventListener("click", this.#n));
|
|
1076
1499
|
}
|
|
1077
1500
|
disable() {
|
|
1078
1501
|
let e = this.store.refs.container;
|
|
1079
|
-
!e || !this.#e || (e.removeEventListener("focusin", this.#e), e.removeEventListener("focusout", this.#t), e.removeEventListener("click", this.#n), this.#e = void 0, this.#t = void 0, this.#n = void 0);
|
|
1502
|
+
!e || !this.#e || (e.removeEventListener("focusin", this.#e), this.#t && e.removeEventListener("focusout", this.#t), this.#n && e.removeEventListener("click", this.#n), this.#e = void 0, this.#t = void 0, this.#n = void 0);
|
|
1080
1503
|
}
|
|
1081
1504
|
recover() {
|
|
1082
1505
|
let e = this.store.state.recovery.get();
|
|
@@ -1084,15 +1507,15 @@ var we = class {
|
|
|
1084
1507
|
let { anchor: t, caret: n, isNext: r } = e, i = !t.target || !t.target.isConnected;
|
|
1085
1508
|
switch (!0) {
|
|
1086
1509
|
case r && i: {
|
|
1087
|
-
let t = this.store.refs.container, n = e.childIndex == null ? void 0 : t
|
|
1088
|
-
n ? n.focus() : this.store.nodes.focus.tail
|
|
1510
|
+
let t = this.store.refs.container, n = e.childIndex == null ? void 0 : M(t, e.childIndex + 2);
|
|
1511
|
+
n ? n.focus() : this.store.nodes.focus.tail?.focus();
|
|
1089
1512
|
break;
|
|
1090
1513
|
}
|
|
1091
1514
|
case r:
|
|
1092
1515
|
t.prev.focus();
|
|
1093
1516
|
break;
|
|
1094
1517
|
case i:
|
|
1095
|
-
this.store.nodes.focus.head
|
|
1518
|
+
this.store.nodes.focus.head?.focus();
|
|
1096
1519
|
break;
|
|
1097
1520
|
default: t.next.focus();
|
|
1098
1521
|
}
|
|
@@ -1100,150 +1523,49 @@ var we = class {
|
|
|
1100
1523
|
}
|
|
1101
1524
|
};
|
|
1102
1525
|
//#endregion
|
|
1103
|
-
//#region ../../common/core/src/features/
|
|
1104
|
-
function
|
|
1105
|
-
return typeof e == "object" && !!e.alwaysShowHandle;
|
|
1106
|
-
}
|
|
1107
|
-
//#endregion
|
|
1108
|
-
//#region ../../common/core/src/features/blocks/dragOperations.ts
|
|
1109
|
-
function H(e) {
|
|
1110
|
-
return e.tokens.length === 0 || e.tokens[0].type === "text";
|
|
1111
|
-
}
|
|
1112
|
-
function Oe(e, t) {
|
|
1113
|
-
return H(e) && H(t) ? "\n\n" : "";
|
|
1114
|
-
}
|
|
1115
|
-
function ke(e, t, n) {
|
|
1116
|
-
if (t.length === 0) return e + "\n\n";
|
|
1117
|
-
if (n >= t.length - 1) return e === "" ? "\n\n\n\n" : e + "\n\n";
|
|
1118
|
-
let r = t[n], i = t[n + 1];
|
|
1119
|
-
return i.startPos - r.endPos === 0 ? e.slice(0, r.endPos) + "\n\n\n\n" + e.slice(i.startPos) : e.slice(0, i.startPos) + "\n\n" + e.slice(i.startPos);
|
|
1120
|
-
}
|
|
1121
|
-
function Ae(e, t, n) {
|
|
1122
|
-
return t.length <= 1 ? "" : n >= t.length - 1 ? e.slice(0, t[n - 1].endPos) : e.slice(0, t[n].startPos) + e.slice(t[n + 1].startPos);
|
|
1123
|
-
}
|
|
1124
|
-
function je(e, t, n) {
|
|
1125
|
-
let r = t[n], i = e.substring(r.startPos, r.endPos);
|
|
1126
|
-
if (n >= t.length - 1) return e + (H(r), "\n\n") + i;
|
|
1127
|
-
let a = t[n + 1], o = a.startPos - r.endPos === 0 ? "" : "\n\n";
|
|
1128
|
-
return e.slice(0, a.startPos) + i + o + e.slice(a.startPos);
|
|
1129
|
-
}
|
|
1130
|
-
function Me(e, t) {
|
|
1131
|
-
return t <= 0 || t >= e.length ? 0 : e[t - 1].endPos;
|
|
1132
|
-
}
|
|
1133
|
-
function U(e, t, n) {
|
|
1134
|
-
if (n <= 0 || n >= t.length) return e;
|
|
1135
|
-
let r = t[n - 1], i = t[n];
|
|
1136
|
-
return e.slice(0, r.endPos) + e.slice(i.startPos);
|
|
1137
|
-
}
|
|
1138
|
-
function Ne(e, t, n, r) {
|
|
1139
|
-
if (n === r || n === r - 1 || t.length < 2 || n < 0 || n >= t.length || r < 0 || r > t.length) return e;
|
|
1140
|
-
let i = t.map((t) => e.substring(t.startPos, t.endPos)), a = [...t], [o] = a.splice(n, 1), [s] = i.splice(n, 1), c = r > n ? r - 1 : r;
|
|
1141
|
-
a.splice(c, 0, o), i.splice(c, 0, s);
|
|
1142
|
-
let l = [];
|
|
1143
|
-
for (let e = 0; e < i.length; e++) l.push(i[e]), e < i.length - 1 && l.push(Oe(a[e], a[e + 1]));
|
|
1144
|
-
return l.join("");
|
|
1145
|
-
}
|
|
1146
|
-
//#endregion
|
|
1147
|
-
//#region ../../common/core/src/features/blocks/splitTokensIntoDragRows.ts
|
|
1148
|
-
function Pe(e) {
|
|
1149
|
-
let t = [], { content: n, position: r } = e, i = r.start, a = [], o = () => {
|
|
1150
|
-
if (a.length > 0) {
|
|
1151
|
-
let e = a.join("");
|
|
1152
|
-
t.push({
|
|
1153
|
-
content: e,
|
|
1154
|
-
position: {
|
|
1155
|
-
start: i,
|
|
1156
|
-
end: i + e.length
|
|
1157
|
-
},
|
|
1158
|
-
isBlockSeparator: !1
|
|
1159
|
-
}), i += e.length, a.length = 0;
|
|
1160
|
-
}
|
|
1161
|
-
};
|
|
1162
|
-
for (let e = 0; e < n.length; e++) {
|
|
1163
|
-
let r = n[e];
|
|
1164
|
-
r === "\n" ? e + 1 < n.length && n[e + 1] === "\n" ? (o(), t.push({
|
|
1165
|
-
content: "\n\n",
|
|
1166
|
-
position: {
|
|
1167
|
-
start: i,
|
|
1168
|
-
end: i + 2
|
|
1169
|
-
},
|
|
1170
|
-
isBlockSeparator: !0
|
|
1171
|
-
}), i += 2, e++) : (a.push(r), i++) : r === "\r" ? e + 1 < n.length && n[e + 1] === "\n" ? e + 2 < n.length && n[e + 2] === "\r" && e + 3 < n.length && n[e + 3] === "\n" ? (o(), t.push({
|
|
1172
|
-
content: "\n\n",
|
|
1173
|
-
position: {
|
|
1174
|
-
start: i,
|
|
1175
|
-
end: i + 4
|
|
1176
|
-
},
|
|
1177
|
-
isBlockSeparator: !0
|
|
1178
|
-
}), i += 4, e += 3) : (a.push("\n"), i += 2, e++) : (a.push("\n"), i++) : a.push(r);
|
|
1179
|
-
}
|
|
1180
|
-
return o(), t;
|
|
1181
|
-
}
|
|
1182
|
-
var Fe = 0;
|
|
1183
|
-
function W(e) {
|
|
1184
|
-
return `drag-${Fe++}-${e}`;
|
|
1185
|
-
}
|
|
1186
|
-
function Ie() {
|
|
1187
|
-
Fe = 0;
|
|
1188
|
-
}
|
|
1189
|
-
function G(e) {
|
|
1190
|
-
if (e.length === 0) return [];
|
|
1191
|
-
Ie();
|
|
1192
|
-
let t = [], n = null;
|
|
1193
|
-
for (let r of e) if (r.type === "mark") n = null, t.push({
|
|
1194
|
-
id: W(r.position.start),
|
|
1195
|
-
tokens: [r],
|
|
1196
|
-
startPos: r.position.start,
|
|
1197
|
-
endPos: r.position.end
|
|
1198
|
-
});
|
|
1199
|
-
else if (r.type === "text") {
|
|
1200
|
-
let e = Pe(r);
|
|
1201
|
-
for (let r of e) r.isBlockSeparator ? (n !== null && t.push({
|
|
1202
|
-
id: W(n),
|
|
1203
|
-
tokens: [],
|
|
1204
|
-
startPos: n,
|
|
1205
|
-
endPos: n
|
|
1206
|
-
}), n = r.position.end) : r.content.trim().length > 0 && (n = null, t.push({
|
|
1207
|
-
id: W(r.position.start),
|
|
1208
|
-
tokens: [{
|
|
1209
|
-
type: "text",
|
|
1210
|
-
content: r.content,
|
|
1211
|
-
position: r.position
|
|
1212
|
-
}],
|
|
1213
|
-
startPos: r.position.start,
|
|
1214
|
-
endPos: r.position.end
|
|
1215
|
-
}));
|
|
1216
|
-
}
|
|
1217
|
-
return n !== null && t.push({
|
|
1218
|
-
id: W(n),
|
|
1219
|
-
tokens: [],
|
|
1220
|
-
startPos: n,
|
|
1221
|
-
endPos: n
|
|
1222
|
-
}), t;
|
|
1223
|
-
}
|
|
1224
|
-
//#endregion
|
|
1225
|
-
//#region ../../common/core/src/features/navigation/index.ts
|
|
1226
|
-
function Le(e, t) {
|
|
1526
|
+
//#region ../../common/core/src/features/navigation/navigation.ts
|
|
1527
|
+
function ot(e, t) {
|
|
1227
1528
|
let { focus: n } = e.nodes;
|
|
1228
1529
|
if (n.isMark && !n.isEditable || n.isCaretAtBeginning) {
|
|
1229
1530
|
let e = n.prev;
|
|
1230
1531
|
for (; e.target && e.isMark && !e.isEditable;) e = e.prev;
|
|
1231
|
-
return e.target ? (t.preventDefault(), e.target.focus(),
|
|
1532
|
+
return e.target ? (t.preventDefault(), e.target.focus(), F.setCaretToEnd(e.target), !0) : !1;
|
|
1232
1533
|
}
|
|
1233
1534
|
return !1;
|
|
1234
1535
|
}
|
|
1235
|
-
function
|
|
1536
|
+
function st(e, t) {
|
|
1236
1537
|
let { focus: n } = e.nodes;
|
|
1237
1538
|
if (n.isMark && !n.isEditable || n.isCaretAtEnd) {
|
|
1238
1539
|
let e = n.next;
|
|
1239
1540
|
for (; e.target && e.isMark && !e.isEditable;) e = e.next;
|
|
1240
|
-
return e.target ? (t.preventDefault(), e.target.focus(),
|
|
1541
|
+
return e.target ? (t.preventDefault(), e.target.focus(), F.trySetIndex(e.target, 0), !0) : !1;
|
|
1241
1542
|
}
|
|
1242
1543
|
return !1;
|
|
1243
1544
|
}
|
|
1244
1545
|
//#endregion
|
|
1546
|
+
//#region ../../common/core/src/features/selection/selectionHelpers.ts
|
|
1547
|
+
function ct(e) {
|
|
1548
|
+
let t = window.getSelection(), n = e.refs.container;
|
|
1549
|
+
if (!t?.rangeCount || !n?.firstChild || !n.lastChild) return !1;
|
|
1550
|
+
try {
|
|
1551
|
+
let e = t.getRangeAt(0);
|
|
1552
|
+
return n.contains(e.startContainer) && n.contains(e.endContainer) && e.toString().length > 0;
|
|
1553
|
+
} catch {
|
|
1554
|
+
return !1;
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
function lt(e, t) {
|
|
1558
|
+
if ((t.ctrlKey || t.metaKey) && t.code === "KeyA") {
|
|
1559
|
+
if (e.state.drag.get()) return;
|
|
1560
|
+
t.preventDefault();
|
|
1561
|
+
let n = window.getSelection(), r = e.refs.container?.firstChild, i = e.refs.container?.lastChild;
|
|
1562
|
+
if (!n || !r || !i) return;
|
|
1563
|
+
n.setBaseAndExtent(r, 0, i, 1), e.state.selecting.set("all");
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
//#endregion
|
|
1245
1567
|
//#region ../../common/core/src/features/selection/TextSelectionController.ts
|
|
1246
|
-
var
|
|
1568
|
+
var ut = class {
|
|
1247
1569
|
#e;
|
|
1248
1570
|
#t;
|
|
1249
1571
|
#n;
|
|
@@ -1255,250 +1577,275 @@ var ze = class {
|
|
|
1255
1577
|
}
|
|
1256
1578
|
enable() {
|
|
1257
1579
|
this.#e || (this.#e = (e) => {
|
|
1258
|
-
this.#i = e
|
|
1580
|
+
this.#i = Ue(e), this.#a = !0;
|
|
1259
1581
|
}, this.#t = (e) => {
|
|
1260
|
-
let t = this
|
|
1261
|
-
|
|
1582
|
+
let t = this.store.refs.container;
|
|
1583
|
+
if (!t) return;
|
|
1584
|
+
let n = this.#a, r = !t.contains(this.#i) || this.#i !== e.target, i = window.getSelection()?.containsNode(t, !0);
|
|
1585
|
+
n && r && i && this.store.state.selecting.set("drag");
|
|
1262
1586
|
}, this.#n = () => {
|
|
1263
1587
|
this.#a = !1, this.#i = null, this.store.state.selecting.set(void 0);
|
|
1264
1588
|
}, this.#r = () => {
|
|
1265
1589
|
if (this.store.state.selecting.get() !== "drag") return;
|
|
1266
|
-
let e =
|
|
1267
|
-
|
|
1590
|
+
let e = this.store.refs.container;
|
|
1591
|
+
if (!e) return;
|
|
1592
|
+
let t = N(e), n = t.map((e) => e.contentEditable);
|
|
1593
|
+
t.forEach((e) => e.contentEditable = "false"), t.forEach((e, t) => e.contentEditable = n[t]);
|
|
1268
1594
|
}, document.addEventListener("mousedown", this.#e), document.addEventListener("mousemove", this.#t), document.addEventListener("mouseup", this.#n), document.addEventListener("selectionchange", this.#r));
|
|
1269
1595
|
}
|
|
1270
1596
|
disable() {
|
|
1271
|
-
this.#e && (document.removeEventListener("mousedown", this.#e), document.removeEventListener("mousemove", this.#t), document.removeEventListener("mouseup", this.#n), document.removeEventListener("selectionchange", this.#r), this.#e = void 0, this.#t = void 0, this.#n = void 0, this.#r = void 0), this.#i = null, this.#a = !1;
|
|
1597
|
+
this.#e && (document.removeEventListener("mousedown", this.#e), this.#t && document.removeEventListener("mousemove", this.#t), this.#n && document.removeEventListener("mouseup", this.#n), this.#r && document.removeEventListener("selectionchange", this.#r), this.#e = void 0, this.#t = void 0, this.#n = void 0, this.#r = void 0), this.#i = null, this.#a = !1;
|
|
1272
1598
|
}
|
|
1273
1599
|
};
|
|
1274
1600
|
//#endregion
|
|
1275
|
-
//#region ../../common/core/src/features/selection/index.ts
|
|
1276
|
-
function Be(e, t) {
|
|
1277
|
-
if ((t.ctrlKey || t.metaKey) && t.code === "KeyA") {
|
|
1278
|
-
if (e.state.drag.get()) return;
|
|
1279
|
-
t.preventDefault();
|
|
1280
|
-
let n = window.getSelection(), r = e.refs.container?.firstChild, i = e.refs.container?.lastChild;
|
|
1281
|
-
if (!n || !r || !i) return;
|
|
1282
|
-
n.setBaseAndExtent(r, 0, i, 1), e.state.selecting.set("all");
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
//#endregion
|
|
1286
1601
|
//#region ../../common/core/src/features/input/KeyDownController.ts
|
|
1287
|
-
|
|
1602
|
+
function dt(e) {
|
|
1603
|
+
return e.type === "text" ? !0 : e.descriptor.hasSlot && e.descriptor.segments.length === 1;
|
|
1604
|
+
}
|
|
1605
|
+
var ft = class {
|
|
1288
1606
|
#e;
|
|
1289
1607
|
#t;
|
|
1290
1608
|
#n;
|
|
1291
1609
|
constructor(e) {
|
|
1292
1610
|
this.store = e;
|
|
1293
1611
|
}
|
|
1612
|
+
#r() {
|
|
1613
|
+
let e = this.store.state.options.get()?.[0];
|
|
1614
|
+
return e?.markup ? w(e.markup, {
|
|
1615
|
+
value: "",
|
|
1616
|
+
slot: "",
|
|
1617
|
+
meta: ""
|
|
1618
|
+
}) : "\n";
|
|
1619
|
+
}
|
|
1294
1620
|
enable() {
|
|
1295
1621
|
if (this.#e) return;
|
|
1296
1622
|
let e = this.store.refs.container;
|
|
1297
1623
|
e && (this.#e = (e) => {
|
|
1298
|
-
e.key ===
|
|
1624
|
+
e.key === y.LEFT ? this.#o(e, "left") || ot(this.store, e) : e.key === y.RIGHT ? this.#o(e, "right") || st(this.store, e) : (e.key === y.UP || e.key === y.DOWN) && this.#s(e), this.#i(e), this.#a(e), lt(this.store, e);
|
|
1299
1625
|
}, this.#t = (e) => {
|
|
1300
|
-
|
|
1626
|
+
ht(this.store, e);
|
|
1301
1627
|
}, this.#n = (e) => {
|
|
1302
|
-
|
|
1628
|
+
pt(this.store, e);
|
|
1303
1629
|
}, e.addEventListener("keydown", this.#e), e.addEventListener("paste", this.#t), e.addEventListener("beforeinput", this.#n, !0));
|
|
1304
1630
|
}
|
|
1305
1631
|
disable() {
|
|
1306
1632
|
let e = this.store.refs.container;
|
|
1307
|
-
!e || !this.#e || (e.removeEventListener("keydown", this.#e), e.removeEventListener("paste", this.#t), e.removeEventListener("beforeinput", this.#n, !0), this.#e = void 0, this.#t = void 0, this.#n = void 0);
|
|
1633
|
+
!e || !this.#e || (e.removeEventListener("keydown", this.#e), this.#t && e.removeEventListener("paste", this.#t), this.#n && e.removeEventListener("beforeinput", this.#n, !0), this.#e = void 0, this.#t = void 0, this.#n = void 0);
|
|
1308
1634
|
}
|
|
1309
|
-
#
|
|
1635
|
+
#i(e) {
|
|
1310
1636
|
let { focus: t } = this.store.nodes, n = !!this.store.state.drag.get();
|
|
1311
|
-
if (!n && (e.key ===
|
|
1637
|
+
if (!n && (e.key === y.DELETE || e.key === y.BACKSPACE)) {
|
|
1312
1638
|
if (t.isMark) {
|
|
1313
|
-
if (t.isEditable && (e.key ===
|
|
1314
|
-
e.preventDefault(),
|
|
1639
|
+
if (t.isEditable && (e.key === y.BACKSPACE && !t.isCaretAtBeginning || e.key === y.DELETE && !t.isCaretAtEnd)) return;
|
|
1640
|
+
e.preventDefault(), B("self", this.store);
|
|
1315
1641
|
return;
|
|
1316
1642
|
}
|
|
1317
|
-
if (e.key ===
|
|
1318
|
-
e.preventDefault(),
|
|
1643
|
+
if (e.key === y.BACKSPACE && t.isSpan && t.isCaretAtBeginning && t.prev.target) {
|
|
1644
|
+
e.preventDefault(), B("prev", this.store);
|
|
1319
1645
|
return;
|
|
1320
1646
|
}
|
|
1321
|
-
if (e.key ===
|
|
1322
|
-
e.preventDefault(),
|
|
1647
|
+
if (e.key === y.DELETE && t.isSpan && t.isCaretAtEnd && t.next.target) {
|
|
1648
|
+
e.preventDefault(), B("next", this.store);
|
|
1323
1649
|
return;
|
|
1324
1650
|
}
|
|
1325
1651
|
}
|
|
1326
1652
|
if (!n) return;
|
|
1327
1653
|
let r = this.store.refs.container;
|
|
1328
1654
|
if (!r) return;
|
|
1329
|
-
let i =
|
|
1655
|
+
let i = N(r), a = i.findIndex((e) => e === document.activeElement || e.contains(document.activeElement));
|
|
1330
1656
|
if (a === -1) return;
|
|
1331
|
-
let o =
|
|
1657
|
+
let o = this.store.state.tokens.get();
|
|
1332
1658
|
if (a >= o.length) return;
|
|
1333
|
-
let s = o[a], c = this.store.state.
|
|
1659
|
+
let s = o[a], c = this.store.state.previousValue.get() ?? this.store.state.value.get() ?? "";
|
|
1334
1660
|
if (this.store.state.onChange.get()) {
|
|
1335
|
-
if (e.key ===
|
|
1336
|
-
let t = i[a], n =
|
|
1337
|
-
if (
|
|
1661
|
+
if (e.key === y.BACKSPACE) {
|
|
1662
|
+
let t = i[a], n = F.getCaretIndex(t) === 0;
|
|
1663
|
+
if (("content" in s ? s.content : "") === "") {
|
|
1338
1664
|
e.preventDefault();
|
|
1339
|
-
let t = o.length <= 1 ? "" : a >= o.length - 1 ? c.slice(0, o[a - 1].
|
|
1665
|
+
let t = o.length <= 1 ? "" : a >= o.length - 1 ? c.slice(0, o[a - 1].position.end) : c.slice(0, o[a].position.start) + c.slice(o[a + 1].position.start);
|
|
1340
1666
|
this.store.applyValue(t), queueMicrotask(() => {
|
|
1341
|
-
let e = r
|
|
1342
|
-
e && (e.focus(),
|
|
1667
|
+
let e = M(r, Math.max(0, a - 1));
|
|
1668
|
+
e && (e.focus(), F.setCaretToEnd(e));
|
|
1343
1669
|
});
|
|
1344
1670
|
return;
|
|
1345
1671
|
}
|
|
1346
1672
|
if (n && a > 0) {
|
|
1347
|
-
let t = o[a - 1], n = o[a]
|
|
1348
|
-
if (
|
|
1673
|
+
let t = o[a - 1], n = o[a];
|
|
1674
|
+
if (L(t, n)) {
|
|
1349
1675
|
e.preventDefault();
|
|
1350
|
-
let t =
|
|
1676
|
+
let t = R(o, a), n = z(c, o, a);
|
|
1351
1677
|
this.store.applyValue(n), queueMicrotask(() => {
|
|
1352
|
-
let e = r
|
|
1678
|
+
let e = M(r, a - 1);
|
|
1353
1679
|
if (e) {
|
|
1354
1680
|
e.focus();
|
|
1355
|
-
let n =
|
|
1356
|
-
|
|
1681
|
+
let n = this.store.state.tokens.get()[a - 1];
|
|
1682
|
+
H(e, n, t);
|
|
1357
1683
|
}
|
|
1358
1684
|
});
|
|
1359
1685
|
return;
|
|
1360
1686
|
}
|
|
1361
1687
|
e.preventDefault(), queueMicrotask(() => {
|
|
1362
1688
|
let e = i[a - 1];
|
|
1363
|
-
e
|
|
1689
|
+
e.focus(), t.type !== "mark" && F.setCaretToEnd(e);
|
|
1364
1690
|
});
|
|
1365
1691
|
return;
|
|
1366
1692
|
}
|
|
1367
1693
|
}
|
|
1368
|
-
if (e.key ===
|
|
1369
|
-
let t = i[a], n =
|
|
1694
|
+
if (e.key === y.DELETE) {
|
|
1695
|
+
let t = i[a], n = F.getCaretIndex(t), s = n === t.textContent.length;
|
|
1370
1696
|
if (n === 0 && a > 0) {
|
|
1371
|
-
let t = o[a - 1], n = o[a]
|
|
1372
|
-
if (
|
|
1697
|
+
let t = o[a - 1], n = o[a];
|
|
1698
|
+
if (L(t, n)) {
|
|
1373
1699
|
e.preventDefault();
|
|
1374
|
-
let t =
|
|
1700
|
+
let t = R(o, a), n = z(c, o, a);
|
|
1375
1701
|
this.store.applyValue(n), queueMicrotask(() => {
|
|
1376
|
-
let e = r
|
|
1702
|
+
let e = M(r, a - 1);
|
|
1377
1703
|
if (e) {
|
|
1378
1704
|
e.focus();
|
|
1379
|
-
let n =
|
|
1380
|
-
|
|
1705
|
+
let n = this.store.state.tokens.get()[a - 1];
|
|
1706
|
+
H(e, n, t);
|
|
1381
1707
|
}
|
|
1382
1708
|
});
|
|
1383
1709
|
return;
|
|
1384
1710
|
}
|
|
1385
1711
|
e.preventDefault(), queueMicrotask(() => {
|
|
1386
1712
|
let e = i[a - 1];
|
|
1387
|
-
e
|
|
1713
|
+
e.focus(), t.type !== "mark" && F.setCaretToEnd(e);
|
|
1388
1714
|
});
|
|
1389
1715
|
return;
|
|
1390
1716
|
}
|
|
1391
1717
|
if (s && a < o.length - 1) {
|
|
1392
|
-
let t = o[a], n = o[a + 1]
|
|
1393
|
-
if (
|
|
1718
|
+
let t = o[a], n = o[a + 1];
|
|
1719
|
+
if (L(t, n)) {
|
|
1394
1720
|
e.preventDefault();
|
|
1395
|
-
let
|
|
1396
|
-
this.store.applyValue(
|
|
1397
|
-
let e = r
|
|
1721
|
+
let t = R(o, a + 1), n = z(c, o, a + 1);
|
|
1722
|
+
this.store.applyValue(n), queueMicrotask(() => {
|
|
1723
|
+
let e = M(r, a);
|
|
1398
1724
|
if (e) {
|
|
1399
1725
|
e.focus();
|
|
1400
|
-
let
|
|
1401
|
-
|
|
1726
|
+
let n = this.store.state.tokens.get()[a];
|
|
1727
|
+
H(e, n, t);
|
|
1402
1728
|
}
|
|
1403
1729
|
});
|
|
1404
1730
|
return;
|
|
1405
1731
|
}
|
|
1406
1732
|
e.preventDefault(), queueMicrotask(() => {
|
|
1407
1733
|
let e = i[a + 1];
|
|
1408
|
-
e
|
|
1734
|
+
e.focus(), F.trySetIndex(e, 0);
|
|
1409
1735
|
});
|
|
1410
1736
|
return;
|
|
1411
1737
|
}
|
|
1412
1738
|
}
|
|
1413
1739
|
}
|
|
1414
1740
|
}
|
|
1415
|
-
#
|
|
1416
|
-
if (!this.store.state.drag.get() || e.key !==
|
|
1741
|
+
#a(e) {
|
|
1742
|
+
if (!this.store.state.drag.get() || e.key !== y.ENTER || e.shiftKey) return;
|
|
1417
1743
|
let t = this.store.refs.container;
|
|
1418
1744
|
if (!t) return;
|
|
1419
1745
|
let n = document.activeElement;
|
|
1420
|
-
if (!n || !t.contains(n)) return;
|
|
1746
|
+
if (!A(n) || !t.contains(n)) return;
|
|
1421
1747
|
e.preventDefault();
|
|
1422
|
-
let r = t
|
|
1748
|
+
let r = N(t), i = -1;
|
|
1423
1749
|
for (let e = 0; e < r.length; e++) if (r[e] === n || r[e].contains(n)) {
|
|
1424
1750
|
i = e;
|
|
1425
1751
|
break;
|
|
1426
1752
|
}
|
|
1427
1753
|
if (i === -1) return;
|
|
1428
|
-
let a =
|
|
1429
|
-
if (!o) return;
|
|
1430
|
-
let s = r[i], c = this.store.state.value.get() ?? "";
|
|
1754
|
+
let a = this.store.state.tokens.get(), o = a[i], s = r[i], c = this.store.state.previousValue.get() ?? this.store.state.value.get() ?? "";
|
|
1431
1755
|
if (!this.store.state.onChange.get()) return;
|
|
1432
|
-
|
|
1433
|
-
|
|
1756
|
+
let l = this.#r();
|
|
1757
|
+
if (!dt(o)) {
|
|
1758
|
+
let e = Je(c, a, i, l);
|
|
1434
1759
|
this.store.applyValue(e), queueMicrotask(() => {
|
|
1435
|
-
let e =
|
|
1436
|
-
if (
|
|
1437
|
-
let
|
|
1438
|
-
|
|
1760
|
+
let e = i + 1;
|
|
1761
|
+
if (e < t.children.length) {
|
|
1762
|
+
let n = M(t, e);
|
|
1763
|
+
n && (n.focus(), F.trySetIndex(n, 0));
|
|
1439
1764
|
}
|
|
1440
1765
|
});
|
|
1441
1766
|
return;
|
|
1442
1767
|
}
|
|
1443
|
-
let
|
|
1768
|
+
let u = V(s, o), d = c.slice(0, u) + l + c.slice(u);
|
|
1444
1769
|
this.store.applyValue(d), queueMicrotask(() => {
|
|
1445
|
-
let e =
|
|
1446
|
-
if (
|
|
1447
|
-
let
|
|
1448
|
-
|
|
1770
|
+
let e = i + 1;
|
|
1771
|
+
if (e < t.children.length) {
|
|
1772
|
+
let n = M(t, e);
|
|
1773
|
+
n && (n.focus(), F.trySetIndex(n, 0));
|
|
1449
1774
|
}
|
|
1450
1775
|
});
|
|
1451
1776
|
}
|
|
1452
|
-
#
|
|
1777
|
+
#o(e, t) {
|
|
1778
|
+
if (!this.store.state.drag.get()) return !1;
|
|
1779
|
+
let n = this.store.refs.container;
|
|
1780
|
+
if (!n) return !1;
|
|
1781
|
+
let r = document.activeElement;
|
|
1782
|
+
if (!A(r) || !n.contains(r)) return !1;
|
|
1783
|
+
let i = N(n), a = i.findIndex((e) => e === r || e.contains(r));
|
|
1784
|
+
if (a === -1) return !1;
|
|
1785
|
+
let o = i[a];
|
|
1786
|
+
if (t === "left") {
|
|
1787
|
+
if (F.getCaretIndex(o) !== 0) return !1;
|
|
1788
|
+
if (a === 0) return !0;
|
|
1789
|
+
e.preventDefault();
|
|
1790
|
+
let t = i[a - 1];
|
|
1791
|
+
return t.focus(), F.setCaretToEnd(t), !0;
|
|
1792
|
+
}
|
|
1793
|
+
if (F.getCaretIndex(o) !== o.textContent.length) return !1;
|
|
1794
|
+
if (a >= i.length - 1) return !0;
|
|
1795
|
+
e.preventDefault();
|
|
1796
|
+
let s = i[a + 1];
|
|
1797
|
+
return s.focus(), F.trySetIndex(s, 0), !0;
|
|
1798
|
+
}
|
|
1799
|
+
#s(e) {
|
|
1453
1800
|
if (!this.store.state.drag.get()) return;
|
|
1454
1801
|
let t = this.store.refs.container;
|
|
1455
1802
|
if (!t) return;
|
|
1456
1803
|
let n = document.activeElement;
|
|
1457
|
-
if (!n || !t.contains(n)) return;
|
|
1458
|
-
let r =
|
|
1804
|
+
if (!A(n) || !t.contains(n)) return;
|
|
1805
|
+
let r = N(t), i = r.findIndex((e) => e === n || e.contains(n));
|
|
1459
1806
|
if (i === -1) return;
|
|
1460
1807
|
let a = r[i];
|
|
1461
|
-
if (e.key ===
|
|
1462
|
-
if (!
|
|
1808
|
+
if (e.key === y.UP) {
|
|
1809
|
+
if (!F.isCaretOnFirstLine(a) || i === 0) return;
|
|
1463
1810
|
e.preventDefault();
|
|
1464
|
-
let t =
|
|
1811
|
+
let t = F.getCaretRect()?.left ?? a.getBoundingClientRect().left, n = r[i - 1];
|
|
1465
1812
|
n.focus();
|
|
1466
1813
|
let o = n.getBoundingClientRect();
|
|
1467
|
-
|
|
1468
|
-
} else if (e.key ===
|
|
1469
|
-
if (!
|
|
1814
|
+
F.setAtX(n, t, o.bottom - 4);
|
|
1815
|
+
} else if (e.key === y.DOWN) {
|
|
1816
|
+
if (!F.isCaretOnLastLine(a) || i >= r.length - 1) return;
|
|
1470
1817
|
e.preventDefault();
|
|
1471
|
-
let t =
|
|
1818
|
+
let t = F.getCaretRect()?.left ?? a.getBoundingClientRect().left, n = r[i + 1];
|
|
1472
1819
|
n.focus();
|
|
1473
1820
|
let o = n.getBoundingClientRect();
|
|
1474
|
-
|
|
1821
|
+
F.setAtX(n, t, o.top + 4);
|
|
1475
1822
|
}
|
|
1476
1823
|
}
|
|
1477
1824
|
};
|
|
1478
|
-
function
|
|
1825
|
+
function V(e, t) {
|
|
1479
1826
|
let n = window.getSelection();
|
|
1480
|
-
if (!n?.rangeCount) return t.
|
|
1827
|
+
if (!n?.rangeCount) return t.position.end;
|
|
1481
1828
|
let { focusNode: r, focusOffset: i } = n;
|
|
1482
|
-
return r ?
|
|
1829
|
+
return r ? U(r, i, e, t) : t.position.end;
|
|
1483
1830
|
}
|
|
1484
|
-
function
|
|
1831
|
+
function pt(e, t) {
|
|
1485
1832
|
let n = e.state.selecting.get();
|
|
1486
|
-
if (n === "all" &&
|
|
1833
|
+
if (n === "all" && ct(e)) {
|
|
1487
1834
|
if (t.inputType === "insertFromPaste") {
|
|
1488
1835
|
t.preventDefault();
|
|
1489
1836
|
return;
|
|
1490
1837
|
}
|
|
1491
|
-
t.preventDefault(),
|
|
1838
|
+
t.preventDefault(), gt(e, t.inputType.startsWith("delete") ? "" : t.data ?? "");
|
|
1492
1839
|
return;
|
|
1493
1840
|
}
|
|
1494
1841
|
if (n === "all" && e.state.selecting.set(void 0), e.state.drag.get()) {
|
|
1495
|
-
|
|
1842
|
+
_t(e, t);
|
|
1496
1843
|
return;
|
|
1497
1844
|
}
|
|
1498
1845
|
let { focus: r } = e.nodes;
|
|
1499
|
-
!r.target || !r.isEditable ||
|
|
1846
|
+
!r.target || !r.isEditable || mt(r, t) && e.events.change();
|
|
1500
1847
|
}
|
|
1501
|
-
function
|
|
1848
|
+
function mt(e, t) {
|
|
1502
1849
|
let n = e.caret, r = e.content, i, a;
|
|
1503
1850
|
switch (t.inputType) {
|
|
1504
1851
|
case "insertText": {
|
|
@@ -1530,25 +1877,15 @@ function Ue(e, t) {
|
|
|
1530
1877
|
}
|
|
1531
1878
|
return e.content = i, e.caret = a, !0;
|
|
1532
1879
|
}
|
|
1533
|
-
function
|
|
1880
|
+
function ht(e, t) {
|
|
1534
1881
|
let n = e.state.selecting.get();
|
|
1535
|
-
if (n !== "all" || !
|
|
1882
|
+
if (n !== "all" || !ct(e)) {
|
|
1536
1883
|
n === "all" && e.state.selecting.set(void 0);
|
|
1537
1884
|
return;
|
|
1538
1885
|
}
|
|
1539
|
-
t.preventDefault(),
|
|
1540
|
-
}
|
|
1541
|
-
function Ge(e) {
|
|
1542
|
-
let t = window.getSelection(), n = e.refs.container;
|
|
1543
|
-
if (!t?.rangeCount || !n?.firstChild || !n?.lastChild) return !1;
|
|
1544
|
-
try {
|
|
1545
|
-
let e = t.getRangeAt(0);
|
|
1546
|
-
return n.contains(e.startContainer) && n.contains(e.endContainer) && e.toString().length > 0;
|
|
1547
|
-
} catch {
|
|
1548
|
-
return !1;
|
|
1549
|
-
}
|
|
1886
|
+
t.preventDefault(), gt(e, t.clipboardData?.getData("text/plain") ?? "");
|
|
1550
1887
|
}
|
|
1551
|
-
function
|
|
1888
|
+
function gt(e, t) {
|
|
1552
1889
|
e.nodes.focus.target = null, e.state.selecting.set(void 0), e.state.onChange.get()?.(t), e.state.value.get() === void 0 && e.state.tokens.set(e.state.parser.get()?.parse(t) ?? [{
|
|
1553
1890
|
type: "text",
|
|
1554
1891
|
content: t,
|
|
@@ -1557,29 +1894,29 @@ function Ke(e, t) {
|
|
|
1557
1894
|
end: t.length
|
|
1558
1895
|
}
|
|
1559
1896
|
}]), queueMicrotask(() => {
|
|
1560
|
-
let n = e.refs.container?.firstChild;
|
|
1561
|
-
|
|
1897
|
+
let n = e.refs.container?.firstChild, r = A(n) ? n : null;
|
|
1898
|
+
r && (e.state.recovery.set({
|
|
1562
1899
|
anchor: e.nodes.focus,
|
|
1563
1900
|
caret: t.length
|
|
1564
|
-
}),
|
|
1901
|
+
}), r.focus());
|
|
1565
1902
|
});
|
|
1566
1903
|
}
|
|
1567
|
-
function
|
|
1904
|
+
function _t(e, t) {
|
|
1568
1905
|
let n = e.refs.container;
|
|
1569
1906
|
if (!n) return;
|
|
1570
1907
|
let r = document.activeElement;
|
|
1571
|
-
if (!r || !n.contains(r)) return;
|
|
1572
|
-
let i =
|
|
1908
|
+
if (!A(r) || !n.contains(r)) return;
|
|
1909
|
+
let i = N(n), a = i.findIndex((e) => e === r || e.contains(r));
|
|
1573
1910
|
if (a === -1) return;
|
|
1574
|
-
let o = i[a], s =
|
|
1911
|
+
let o = i[a], s = e.state.tokens.get();
|
|
1575
1912
|
if (a >= s.length) return;
|
|
1576
|
-
let c = s[a], l = e.state.
|
|
1913
|
+
let c = s[a], l = e.state.previousValue.get() ?? e.state.value.get() ?? "", u = (t) => {
|
|
1577
1914
|
queueMicrotask(() => {
|
|
1578
|
-
let r = n
|
|
1915
|
+
let r = M(n, a);
|
|
1579
1916
|
if (!r) return;
|
|
1580
1917
|
r.focus();
|
|
1581
|
-
let i =
|
|
1582
|
-
|
|
1918
|
+
let i = e.state.tokens.get()[a];
|
|
1919
|
+
H(r, i, t);
|
|
1583
1920
|
});
|
|
1584
1921
|
};
|
|
1585
1922
|
switch (t.inputType) {
|
|
@@ -1587,9 +1924,9 @@ function qe(e, t) {
|
|
|
1587
1924
|
t.preventDefault();
|
|
1588
1925
|
let n = t.data ?? "", r = t.getTargetRanges(), i, a;
|
|
1589
1926
|
if (r.length > 0) {
|
|
1590
|
-
let e =
|
|
1927
|
+
let e = U(r[0].startContainer, r[0].startOffset, o, c), t = U(r[0].endContainer, r[0].endOffset, o, c);
|
|
1591
1928
|
[i, a] = e <= t ? [e, t] : [t, e];
|
|
1592
|
-
} else i = a =
|
|
1929
|
+
} else i = a = V(o, c);
|
|
1593
1930
|
e.applyValue(l.slice(0, i) + n + l.slice(a)), u(i + n.length);
|
|
1594
1931
|
break;
|
|
1595
1932
|
}
|
|
@@ -1598,9 +1935,9 @@ function qe(e, t) {
|
|
|
1598
1935
|
t.preventDefault();
|
|
1599
1936
|
let n = t.dataTransfer?.getData("text/plain") ?? "", r = t.getTargetRanges(), i, a;
|
|
1600
1937
|
if (r.length > 0) {
|
|
1601
|
-
let e =
|
|
1938
|
+
let e = U(r[0].startContainer, r[0].startOffset, o, c), t = U(r[0].endContainer, r[0].endOffset, o, c);
|
|
1602
1939
|
[i, a] = e <= t ? [e, t] : [t, e];
|
|
1603
|
-
} else i = a =
|
|
1940
|
+
} else i = a = V(o, c);
|
|
1604
1941
|
e.applyValue(l.slice(0, i) + n + l.slice(a)), u(i + n.length);
|
|
1605
1942
|
break;
|
|
1606
1943
|
}
|
|
@@ -1612,102 +1949,108 @@ function qe(e, t) {
|
|
|
1612
1949
|
case "deleteSoftLineForward": {
|
|
1613
1950
|
let n = t.getTargetRanges();
|
|
1614
1951
|
if (!n.length) return;
|
|
1615
|
-
let r =
|
|
1952
|
+
let r = U(n[0].startContainer, n[0].startOffset, o, c), i = U(n[0].endContainer, n[0].endOffset, o, c), [a, s] = r <= i ? [r, i] : [i, r];
|
|
1616
1953
|
if (a === s) return;
|
|
1617
1954
|
t.preventDefault(), e.applyValue(l.slice(0, a) + l.slice(s)), u(a);
|
|
1618
1955
|
break;
|
|
1619
1956
|
}
|
|
1620
1957
|
}
|
|
1621
1958
|
}
|
|
1622
|
-
function
|
|
1959
|
+
function vt(e) {
|
|
1960
|
+
return e.tagName === "SPAN" && (e.attributes.length === 0 || e.attributes.length === 1 && e.hasAttribute("contenteditable"));
|
|
1961
|
+
}
|
|
1962
|
+
function yt(e, t, n) {
|
|
1623
1963
|
let r = window.getSelection();
|
|
1624
1964
|
if (!r) return !1;
|
|
1625
|
-
if (!t.children || t.children.length === 0) {
|
|
1626
|
-
let i = t.nested?.start ?? t.position.start, a = t.nested?.end ?? t.position.end, o = Math.max(0, Math.min(n - i, a - i)), s = document.createTreeWalker(e, 4).nextNode();
|
|
1627
|
-
if (!s) return !1;
|
|
1628
|
-
let c = document.createRange();
|
|
1629
|
-
return c.setStart(s, Math.min(o, s.length)), c.collapse(!0), r.removeAllRanges(), r.addRange(c), !0;
|
|
1630
|
-
}
|
|
1631
1965
|
let i = 0;
|
|
1632
1966
|
for (let a of Array.from(e.childNodes)) {
|
|
1633
1967
|
if (i >= t.children.length) break;
|
|
1634
1968
|
let e = t.children[i];
|
|
1635
|
-
if (a
|
|
1969
|
+
if (A(a) && e.type === "text") {
|
|
1970
|
+
if (!vt(a)) continue;
|
|
1971
|
+
if (n >= e.position.start && n <= e.position.end) {
|
|
1972
|
+
let t = a.firstChild, i = j(t) ? t : null, o = n - e.position.start;
|
|
1973
|
+
if (i) {
|
|
1974
|
+
let e = document.createRange();
|
|
1975
|
+
e.setStart(i, Math.min(o, i.length)), e.collapse(!0), r.removeAllRanges(), r.addRange(e);
|
|
1976
|
+
} else {
|
|
1977
|
+
let e = document.createRange();
|
|
1978
|
+
e.setStart(a, 0), e.collapse(!0), r.removeAllRanges(), r.addRange(e);
|
|
1979
|
+
}
|
|
1980
|
+
return !0;
|
|
1981
|
+
}
|
|
1982
|
+
i++;
|
|
1983
|
+
} else if (j(a) && e.type === "text") {
|
|
1636
1984
|
if (n >= e.position.start && n <= e.position.end) {
|
|
1637
1985
|
let t = Math.min(n - e.position.start, a.length), i = document.createRange();
|
|
1638
1986
|
return i.setStart(a, t), i.collapse(!0), r.removeAllRanges(), r.addRange(i), !0;
|
|
1639
1987
|
}
|
|
1640
1988
|
i++;
|
|
1641
|
-
} else if (a
|
|
1989
|
+
} else if (A(a) && e.type === "mark") {
|
|
1642
1990
|
let r = i + 1 < t.children.length ? t.children[i + 1] : null;
|
|
1643
|
-
if (!(n === e.position.end && r?.position.start === n) && n >= e.position.start && n <= e.position.end) return
|
|
1991
|
+
if (!(n === e.position.end && r?.position.start === n) && n >= e.position.start && n <= e.position.end) return yt(a, e, n);
|
|
1644
1992
|
i++;
|
|
1645
1993
|
}
|
|
1646
1994
|
}
|
|
1647
1995
|
return !1;
|
|
1648
1996
|
}
|
|
1649
|
-
function
|
|
1997
|
+
function H(e, t, n) {
|
|
1650
1998
|
let r = window.getSelection();
|
|
1651
1999
|
if (!r) return;
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
i.setStart(t, n), i.collapse(!0), r.removeAllRanges(), r.addRange(i);
|
|
1663
|
-
return;
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
if (Je(o, a, n)) return;
|
|
1667
|
-
break;
|
|
1668
|
-
}
|
|
2000
|
+
if (t.type === "mark") {
|
|
2001
|
+
if (yt(e, t, n)) return;
|
|
2002
|
+
F.setCaretToEnd(e);
|
|
2003
|
+
return;
|
|
2004
|
+
}
|
|
2005
|
+
let i = n - t.position.start, a = P(document.createTreeWalker(e, 4));
|
|
2006
|
+
if (a) {
|
|
2007
|
+
let e = Math.min(i, a.length), t = document.createRange();
|
|
2008
|
+
t.setStart(a, e), t.collapse(!0), r.removeAllRanges(), r.addRange(t);
|
|
2009
|
+
return;
|
|
1669
2010
|
}
|
|
1670
|
-
|
|
2011
|
+
F.setCaretToEnd(e);
|
|
1671
2012
|
}
|
|
1672
|
-
function
|
|
2013
|
+
function U(e, t, n, r) {
|
|
1673
2014
|
if (e === n) {
|
|
1674
2015
|
let e = window.getSelection();
|
|
1675
|
-
return e?.focusNode && e.focusNode !== n ?
|
|
2016
|
+
return e?.focusNode && e.focusNode !== n ? U(e.focusNode, e.focusOffset, n, r) : r.position.end;
|
|
1676
2017
|
}
|
|
2018
|
+
if (e.nodeType === Node.TEXT_NODE && e.parentElement === n) return r.type === "mark" ? W(e, t, n, r) : r.position.start + Math.min(t, r.content.length);
|
|
1677
2019
|
let i = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
|
|
1678
2020
|
for (; i && i.parentElement !== n;) i = i.parentElement;
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
if (o < 0) return r.startPos;
|
|
1684
|
-
if (o >= r.tokens.length) return r.endPos;
|
|
1685
|
-
let s = r.tokens[o];
|
|
1686
|
-
return s.type === "text" ? s.position.start + Math.min(t, s.content.length) : Ye(e, t, i, s);
|
|
1687
|
-
}
|
|
1688
|
-
function Ye(e, t, n, r) {
|
|
1689
|
-
if (!r.children || r.children.length === 0) {
|
|
2021
|
+
return i ? r.type === "mark" ? W(e, t, n, r) : r.position.start + Math.min(t, r.content.length) : r.position.end;
|
|
2022
|
+
}
|
|
2023
|
+
function W(e, t, n, r) {
|
|
2024
|
+
if (r.children.length === 0) {
|
|
1690
2025
|
if (t === 0) return r.position.start;
|
|
1691
|
-
let e = r.
|
|
1692
|
-
return e > 0 && t >= e ? r.content.endsWith("\n\n") && r.
|
|
2026
|
+
let e = r.slot?.content.length ?? r.value.length;
|
|
2027
|
+
return e > 0 && t >= e ? r.content.endsWith("\n\n") && r.slot ? r.slot.end : r.position.end : (r.slot?.start ?? r.position.start) + Math.min(t, e);
|
|
1693
2028
|
}
|
|
1694
2029
|
let i = 0;
|
|
1695
2030
|
for (let a of Array.from(n.childNodes)) {
|
|
1696
2031
|
if (i >= r.children.length) break;
|
|
1697
2032
|
let n = r.children[i];
|
|
1698
|
-
if (a
|
|
2033
|
+
if (A(a) && n.type === "text") {
|
|
2034
|
+
if (!vt(a)) continue;
|
|
2035
|
+
if (e === a) {
|
|
2036
|
+
let e = t === 0 ? 0 : n.content.length;
|
|
2037
|
+
return n.position.start + Math.min(e, n.content.length);
|
|
2038
|
+
}
|
|
2039
|
+
if (a.contains(e)) return n.position.start + Math.min(t, n.content.length);
|
|
2040
|
+
i++;
|
|
2041
|
+
} else if (j(a) && n.type === "text") {
|
|
1699
2042
|
if (e === a) return n.position.start + Math.min(t, n.content.length);
|
|
1700
2043
|
i++;
|
|
1701
|
-
} else if (a
|
|
1702
|
-
if (a === e || a.contains(e)) return
|
|
2044
|
+
} else if (A(a) && n.type === "mark") {
|
|
2045
|
+
if (a === e || a.contains(e)) return W(e, t, a, n);
|
|
1703
2046
|
i++;
|
|
1704
2047
|
}
|
|
1705
2048
|
}
|
|
1706
|
-
return r.
|
|
2049
|
+
return r.slot?.end ?? r.position.end;
|
|
1707
2050
|
}
|
|
1708
2051
|
//#endregion
|
|
1709
|
-
//#region ../../common/core/src/features/FeatureManager.ts
|
|
1710
|
-
var
|
|
2052
|
+
//#region ../../common/core/src/features/feature-manager/FeatureManager.ts
|
|
2053
|
+
var bt = class {
|
|
1711
2054
|
#e = [];
|
|
1712
2055
|
#t = !1;
|
|
1713
2056
|
register(e) {
|
|
@@ -1719,21 +2062,21 @@ var Xe = class {
|
|
|
1719
2062
|
disableAll() {
|
|
1720
2063
|
this.#t && (this.#t = !1, this.#e.forEach((e) => e.disable()));
|
|
1721
2064
|
}
|
|
1722
|
-
},
|
|
2065
|
+
}, G = (e, t) => ({
|
|
1723
2066
|
name: e,
|
|
1724
2067
|
enable: () => t.enable(),
|
|
1725
2068
|
disable: () => t.disable()
|
|
1726
|
-
}),
|
|
1727
|
-
let t = new
|
|
1728
|
-
return t.register(
|
|
1729
|
-
},
|
|
2069
|
+
}), xt = (e) => {
|
|
2070
|
+
let t = new bt();
|
|
2071
|
+
return t.register(G("keydown", e.controllers.keydown)).register(G("system", e.controllers.system)).register(G("focus", e.controllers.focus)).register(G("textSelection", e.controllers.textSelection)).register(G("contentEditable", e.controllers.contentEditable)), t;
|
|
2072
|
+
}, St = class {
|
|
1730
2073
|
#e = [];
|
|
1731
2074
|
#t = !1;
|
|
1732
2075
|
constructor(e) {
|
|
1733
2076
|
this.store = e;
|
|
1734
2077
|
}
|
|
1735
2078
|
enable(e) {
|
|
1736
|
-
let { store: t } = this, n =
|
|
2079
|
+
let { store: t } = this, n = xt(t);
|
|
1737
2080
|
n.enableAll(), this.#e.push(() => n.disableAll()), this.#n(), e?.getTrigger && this.#r(e.getTrigger);
|
|
1738
2081
|
}
|
|
1739
2082
|
disable() {
|
|
@@ -1742,12 +2085,16 @@ var Xe = class {
|
|
|
1742
2085
|
}
|
|
1743
2086
|
syncParser(e, t) {
|
|
1744
2087
|
let { store: n } = this, r = t?.map((e) => e.markup);
|
|
1745
|
-
if (r
|
|
2088
|
+
if (r?.some(Boolean)) {
|
|
2089
|
+
let e = n.state.drag.get() ? { skipEmptyText: !0 } : void 0;
|
|
2090
|
+
n.state.parser.set(new xe(r, e));
|
|
2091
|
+
} else n.state.parser.set(void 0);
|
|
2092
|
+
if (this.#t) {
|
|
1746
2093
|
n.state.recovery.get() || n.events.parse();
|
|
1747
2094
|
return;
|
|
1748
2095
|
}
|
|
1749
2096
|
let i = e ?? n.state.defaultValue.get() ?? "";
|
|
1750
|
-
n.state.tokens.set(
|
|
2097
|
+
n.state.tokens.set(O(n, i)), this.#t = !0;
|
|
1751
2098
|
}
|
|
1752
2099
|
recoverFocus() {
|
|
1753
2100
|
this.store.controllers.contentEditable.sync(), this.store.state.Mark.get() && this.store.controllers.focus.recover();
|
|
@@ -1756,11 +2103,11 @@ var Xe = class {
|
|
|
1756
2103
|
let { store: e } = this;
|
|
1757
2104
|
this.#e.push(e.events.parse.on(() => {
|
|
1758
2105
|
if (e.state.recovery.get()) {
|
|
1759
|
-
let t =
|
|
1760
|
-
e.state.tokens.set(
|
|
2106
|
+
let t = T(e.state.tokens.get());
|
|
2107
|
+
e.state.tokens.set(O(e, t)), e.state.previousValue.set(t);
|
|
1761
2108
|
return;
|
|
1762
2109
|
}
|
|
1763
|
-
e.state.tokens.set(e.nodes.focus.target ?
|
|
2110
|
+
e.state.tokens.set(e.nodes.focus.target ? Te(e) : Ee(e));
|
|
1764
2111
|
}));
|
|
1765
2112
|
}
|
|
1766
2113
|
#r(e) {
|
|
@@ -1772,13 +2119,13 @@ var Xe = class {
|
|
|
1772
2119
|
};
|
|
1773
2120
|
//#endregion
|
|
1774
2121
|
//#region ../../common/core/src/features/overlay/filterSuggestions.ts
|
|
1775
|
-
function
|
|
2122
|
+
function Ct(e, t) {
|
|
1776
2123
|
let n = t.toLowerCase();
|
|
1777
2124
|
return e.filter((e) => e.toLowerCase().includes(n));
|
|
1778
2125
|
}
|
|
1779
2126
|
//#endregion
|
|
1780
2127
|
//#region ../../common/core/src/features/overlay/createMarkFromOverlay.ts
|
|
1781
|
-
function
|
|
2128
|
+
function wt(e, t, n) {
|
|
1782
2129
|
let r = e.option.markup;
|
|
1783
2130
|
if (!r) throw Error("createMarkFromOverlay: option.markup is required");
|
|
1784
2131
|
return {
|
|
@@ -1795,17 +2142,17 @@ function et(e, t, n) {
|
|
|
1795
2142
|
index: 0,
|
|
1796
2143
|
segments: [],
|
|
1797
2144
|
gapTypes: [],
|
|
1798
|
-
|
|
2145
|
+
hasSlot: !1,
|
|
1799
2146
|
hasTwoValues: !1,
|
|
1800
2147
|
segmentGlobalIndices: []
|
|
1801
2148
|
},
|
|
1802
2149
|
children: [],
|
|
1803
|
-
|
|
2150
|
+
slot: void 0
|
|
1804
2151
|
};
|
|
1805
2152
|
}
|
|
1806
2153
|
//#endregion
|
|
1807
2154
|
//#region ../../common/core/src/features/overlay/OverlayController.ts
|
|
1808
|
-
var
|
|
2155
|
+
var Tt = class {
|
|
1809
2156
|
#e;
|
|
1810
2157
|
#t;
|
|
1811
2158
|
#n;
|
|
@@ -1822,55 +2169,61 @@ var tt = class {
|
|
|
1822
2169
|
this.#e = this.store.events.clearOverlay.on(() => {
|
|
1823
2170
|
t(void 0);
|
|
1824
2171
|
}), this.#t = this.store.events.checkOverlay.on(() => {
|
|
1825
|
-
t(
|
|
2172
|
+
t(Ge.find(this.store.state.options.get(), e));
|
|
1826
2173
|
}), this.#n = this.store.events.change.on(() => {
|
|
1827
|
-
let e = this.store.state.showOverlayOn.get()
|
|
2174
|
+
let e = this.store.state.showOverlayOn.get();
|
|
2175
|
+
if (!e) return;
|
|
2176
|
+
let t = "change";
|
|
1828
2177
|
(e === t || Array.isArray(e) && e.includes(t)) && this.store.events.checkOverlay();
|
|
1829
|
-
})
|
|
1830
|
-
|
|
2178
|
+
});
|
|
2179
|
+
let n = () => {
|
|
2180
|
+
let e = this.store.state.showOverlayOn.get();
|
|
2181
|
+
if (!e) return;
|
|
2182
|
+
let t = "selectionChange";
|
|
1831
2183
|
(e === t || Array.isArray(e) && e.includes(t)) && this.store.events.checkOverlay();
|
|
1832
|
-
}
|
|
1833
|
-
|
|
2184
|
+
};
|
|
2185
|
+
this.#r = n, this.#i = () => {
|
|
2186
|
+
document.addEventListener("selectionchange", n);
|
|
1834
2187
|
}, this.#a = () => {
|
|
1835
|
-
document.removeEventListener("selectionchange",
|
|
2188
|
+
document.removeEventListener("selectionchange", n);
|
|
1836
2189
|
};
|
|
1837
|
-
let
|
|
1838
|
-
|
|
2190
|
+
let r = this.store.refs.container;
|
|
2191
|
+
r && (r.addEventListener("focusin", this.#i), r.addEventListener("focusout", this.#a));
|
|
1839
2192
|
}
|
|
1840
2193
|
enableClose() {
|
|
1841
2194
|
this.#o || (this.#o = (e) => {
|
|
1842
|
-
e.key ===
|
|
2195
|
+
e.key === y.ESC && this.store.events.clearOverlay();
|
|
1843
2196
|
}, this.#s = (e) => {
|
|
1844
|
-
let t = e.target;
|
|
2197
|
+
let t = e.target instanceof HTMLElement ? e.target : null;
|
|
1845
2198
|
this.store.refs.overlay?.contains(t) || this.store.refs.container?.contains(t) || this.store.events.clearOverlay();
|
|
1846
2199
|
}, window.addEventListener("keydown", this.#o), document.addEventListener("click", this.#s, !0));
|
|
1847
2200
|
}
|
|
1848
2201
|
disableClose() {
|
|
1849
|
-
this.#o && (window.removeEventListener("keydown", this.#o), document.removeEventListener("click", this.#s, !0), this.#o = void 0, this.#s = void 0);
|
|
2202
|
+
this.#o && (window.removeEventListener("keydown", this.#o), this.#s && document.removeEventListener("click", this.#s, !0), this.#o = void 0, this.#s = void 0);
|
|
1850
2203
|
}
|
|
1851
2204
|
disable() {
|
|
1852
2205
|
let e = this.store.refs.container;
|
|
1853
|
-
e && this.#i && (e.removeEventListener("focusin", this.#i), e.removeEventListener("focusout", this.#a)), this.#r && document.removeEventListener("selectionchange", this.#r), this.disableClose(), this.#e?.(), this.#t?.(), this.#n?.(), this.#e = void 0, this.#t = void 0, this.#n = void 0, this.#r = void 0, this.#i = void 0, this.#a = void 0;
|
|
2206
|
+
e && this.#i && (e.removeEventListener("focusin", this.#i), this.#a && e.removeEventListener("focusout", this.#a)), this.#r && document.removeEventListener("selectionchange", this.#r), this.disableClose(), this.#e?.(), this.#t?.(), this.#n?.(), this.#e = void 0, this.#t = void 0, this.#n = void 0, this.#r = void 0, this.#i = void 0, this.#a = void 0;
|
|
1854
2207
|
}
|
|
1855
2208
|
};
|
|
1856
2209
|
//#endregion
|
|
1857
2210
|
//#region ../../common/core/src/features/overlay/suggestionNavigation.ts
|
|
1858
|
-
function
|
|
2211
|
+
function Et(e, t, n) {
|
|
1859
2212
|
if (n === 0) return {
|
|
1860
2213
|
action: "none",
|
|
1861
2214
|
index: t
|
|
1862
2215
|
};
|
|
1863
2216
|
let r = !isNaN(t);
|
|
1864
2217
|
switch (e) {
|
|
1865
|
-
case
|
|
2218
|
+
case y.UP: return {
|
|
1866
2219
|
action: "up",
|
|
1867
2220
|
index: r ? (n + (t - 1) % n) % n : 0
|
|
1868
2221
|
};
|
|
1869
|
-
case
|
|
2222
|
+
case y.DOWN: return {
|
|
1870
2223
|
action: "down",
|
|
1871
2224
|
index: r ? (t + 1) % n : 0
|
|
1872
2225
|
};
|
|
1873
|
-
case
|
|
2226
|
+
case y.ENTER: return r ? {
|
|
1874
2227
|
action: "select",
|
|
1875
2228
|
index: t
|
|
1876
2229
|
} : {
|
|
@@ -1885,29 +2238,33 @@ function nt(e, t, n) {
|
|
|
1885
2238
|
}
|
|
1886
2239
|
//#endregion
|
|
1887
2240
|
//#region ../../common/core/src/features/store/Store.ts
|
|
1888
|
-
var
|
|
1889
|
-
key = new
|
|
2241
|
+
var Dt = class {
|
|
2242
|
+
key = new Be();
|
|
2243
|
+
blocks;
|
|
1890
2244
|
nodes = {
|
|
1891
|
-
focus: new
|
|
1892
|
-
input: new
|
|
2245
|
+
focus: new Ke(void 0, this),
|
|
2246
|
+
input: new Ke(void 0, this)
|
|
1893
2247
|
};
|
|
1894
2248
|
state;
|
|
1895
|
-
|
|
2249
|
+
slot;
|
|
2250
|
+
events = Me();
|
|
1896
2251
|
refs = {
|
|
1897
2252
|
container: null,
|
|
1898
2253
|
overlay: null
|
|
1899
2254
|
};
|
|
1900
2255
|
controllers = {
|
|
1901
|
-
overlay: new
|
|
1902
|
-
focus: new
|
|
1903
|
-
keydown: new
|
|
1904
|
-
system: new
|
|
1905
|
-
textSelection: new
|
|
1906
|
-
contentEditable: new
|
|
2256
|
+
overlay: new Tt(this),
|
|
2257
|
+
focus: new at(this),
|
|
2258
|
+
keydown: new ft(this),
|
|
2259
|
+
system: new it(this),
|
|
2260
|
+
textSelection: new ut(this),
|
|
2261
|
+
contentEditable: new nt(this),
|
|
2262
|
+
drag: new $e(this)
|
|
1907
2263
|
};
|
|
1908
|
-
lifecycle = new
|
|
2264
|
+
lifecycle = new St(this);
|
|
2265
|
+
_defaultSpan;
|
|
1909
2266
|
constructor(e) {
|
|
1910
|
-
this.state =
|
|
2267
|
+
this._defaultSpan = e.defaultSpan, this.blocks = new ze(e.createUseHook), this.state = Ae({
|
|
1911
2268
|
tokens: [],
|
|
1912
2269
|
parser: void 0,
|
|
1913
2270
|
previousValue: void 0,
|
|
@@ -1920,6 +2277,7 @@ var rt = class {
|
|
|
1920
2277
|
readOnly: !1,
|
|
1921
2278
|
options: void 0,
|
|
1922
2279
|
showOverlayOn: void 0,
|
|
2280
|
+
Span: void 0,
|
|
1923
2281
|
Mark: void 0,
|
|
1924
2282
|
Overlay: void 0,
|
|
1925
2283
|
className: void 0,
|
|
@@ -1927,12 +2285,33 @@ var rt = class {
|
|
|
1927
2285
|
slots: void 0,
|
|
1928
2286
|
slotProps: void 0,
|
|
1929
2287
|
drag: !1
|
|
1930
|
-
}, e.createUseHook)
|
|
2288
|
+
}, e.createUseHook, { equals: { style: p } }), this.slot = {
|
|
2289
|
+
container: {
|
|
2290
|
+
use: () => [_("container", this.state.slots.use()), v("container", this.state.slotProps.use())],
|
|
2291
|
+
get: () => [_("container", this.state.slots.get()), v("container", this.state.slotProps.get())]
|
|
2292
|
+
},
|
|
2293
|
+
block: {
|
|
2294
|
+
use: () => [_("block", this.state.slots.use()), v("block", this.state.slotProps.use())],
|
|
2295
|
+
get: () => [_("block", this.state.slots.get()), v("block", this.state.slotProps.get())]
|
|
2296
|
+
},
|
|
2297
|
+
span: {
|
|
2298
|
+
use: () => [_("span", this.state.slots.use()), v("span", this.state.slotProps.use())],
|
|
2299
|
+
get: () => [_("span", this.state.slots.get()), v("span", this.state.slotProps.get())]
|
|
2300
|
+
},
|
|
2301
|
+
overlay: {
|
|
2302
|
+
use: (e, t) => ne(this.state.Overlay.use(), e, t),
|
|
2303
|
+
get: (e, t) => ne(this.state.Overlay.get(), e, t)
|
|
2304
|
+
},
|
|
2305
|
+
mark: {
|
|
2306
|
+
use: (e) => re(e, this.state.options.get(), this.state.Mark.use(), this.state.Span.use(), this._defaultSpan),
|
|
2307
|
+
get: (e) => re(e, this.state.options.get(), this.state.Mark.get(), this.state.Span.get(), this._defaultSpan)
|
|
2308
|
+
}
|
|
2309
|
+
};
|
|
1931
2310
|
}
|
|
1932
2311
|
applyValue(e) {
|
|
1933
2312
|
let t = this.state.onChange.get();
|
|
1934
2313
|
if (!t) return;
|
|
1935
|
-
let n =
|
|
2314
|
+
let n = O(this, e);
|
|
1936
2315
|
this.state.tokens.set(n), this.state.previousValue.set(e), t(e);
|
|
1937
2316
|
}
|
|
1938
2317
|
createHandler() {
|
|
@@ -1949,7 +2328,7 @@ var rt = class {
|
|
|
1949
2328
|
}
|
|
1950
2329
|
};
|
|
1951
2330
|
}
|
|
1952
|
-
},
|
|
2331
|
+
}, Ot = class {
|
|
1953
2332
|
ref;
|
|
1954
2333
|
#e;
|
|
1955
2334
|
#t;
|
|
@@ -1981,14 +2360,17 @@ var rt = class {
|
|
|
1981
2360
|
set meta(e) {
|
|
1982
2361
|
this.#t.meta = e, this.#r();
|
|
1983
2362
|
}
|
|
2363
|
+
get slot() {
|
|
2364
|
+
return this.#t.slot?.content;
|
|
2365
|
+
}
|
|
1984
2366
|
get depth() {
|
|
1985
|
-
return
|
|
2367
|
+
return E(this.#e.state.tokens.get(), this.#t)?.depth ?? 0;
|
|
1986
2368
|
}
|
|
1987
2369
|
get hasChildren() {
|
|
1988
|
-
return this.#t.children.
|
|
2370
|
+
return this.#t.children.some((e) => e.type === "mark");
|
|
1989
2371
|
}
|
|
1990
2372
|
get parent() {
|
|
1991
|
-
return
|
|
2373
|
+
return E(this.#e.state.tokens.get(), this.#t)?.parent;
|
|
1992
2374
|
}
|
|
1993
2375
|
get tokens() {
|
|
1994
2376
|
return this.#t.children;
|
|
@@ -2000,387 +2382,203 @@ var rt = class {
|
|
|
2000
2382
|
#r() {
|
|
2001
2383
|
this.#e.events.change();
|
|
2002
2384
|
}
|
|
2003
|
-
},
|
|
2004
|
-
let
|
|
2005
|
-
return
|
|
2385
|
+
}, kt = (e) => {
|
|
2386
|
+
let t = (t) => e.on(t), n = () => e.get();
|
|
2387
|
+
return () => u(t, n, n);
|
|
2006
2388
|
};
|
|
2007
2389
|
//#endregion
|
|
2008
2390
|
//#region src/lib/hooks/useCoreFeatures.ts
|
|
2009
|
-
function
|
|
2010
|
-
|
|
2011
|
-
let n = e.state.value.use(), r = e.state.Mark.use(),
|
|
2012
|
-
|
|
2013
|
-
e.lifecycle.syncParser(n,
|
|
2014
|
-
}, [n,
|
|
2391
|
+
function At(e, t) {
|
|
2392
|
+
a(t, () => e.createHandler(), [e]), i(() => (e.lifecycle.enable({ getTrigger: (e) => e.overlay?.trigger }), () => e.lifecycle.disable()), []);
|
|
2393
|
+
let n = e.state.value.use(), r = e.state.Mark.use(), s = e.state.options.use(), c = s?.some((e) => e.Mark != null), l = r || c ? s : void 0, u = e.state.tokens.use();
|
|
2394
|
+
i(() => {
|
|
2395
|
+
e.lifecycle.syncParser(n, l);
|
|
2396
|
+
}, [n, l]), o(() => {
|
|
2397
|
+
e.controllers.contentEditable.sync();
|
|
2398
|
+
}, [u]), i(() => {
|
|
2015
2399
|
e.lifecycle.recoverFocus();
|
|
2016
|
-
}, [
|
|
2400
|
+
}, [u]);
|
|
2017
2401
|
}
|
|
2018
2402
|
//#endregion
|
|
2019
2403
|
//#region src/lib/providers/StoreContext.ts
|
|
2020
|
-
var
|
|
2021
|
-
|
|
2022
|
-
function
|
|
2023
|
-
let e =
|
|
2404
|
+
var K = e(void 0);
|
|
2405
|
+
K.displayName = "StoreContext";
|
|
2406
|
+
function q() {
|
|
2407
|
+
let e = r(K);
|
|
2024
2408
|
if (e === void 0) throw Error("Store not found. Make sure to wrap component in StoreContext.");
|
|
2025
2409
|
return e;
|
|
2026
2410
|
}
|
|
2027
|
-
var
|
|
2028
|
-
Container: "
|
|
2029
|
-
Icon: "
|
|
2030
|
-
IconGrip: "
|
|
2031
|
-
IconAdd: "
|
|
2032
|
-
IconDuplicate: "
|
|
2033
|
-
IconTrash: "
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
o
|
|
2057
|
-
]), D = r((e) => {
|
|
2058
|
-
e.preventDefault(), y.current && s?.(t, y.current.getBoundingClientRect());
|
|
2059
|
-
}, [t, s]), O = {
|
|
2060
|
-
position: "relative",
|
|
2061
|
-
marginLeft: 0,
|
|
2062
|
-
paddingLeft: i ? 0 : 32,
|
|
2063
|
-
transition: "opacity 0.2s ease",
|
|
2064
|
-
opacity: m ? .4 : 1,
|
|
2065
|
-
background: "transparent",
|
|
2066
|
-
borderRadius: 3,
|
|
2067
|
-
minHeight: "1.2em",
|
|
2068
|
-
userSelect: "none",
|
|
2069
|
-
outline: "none"
|
|
2070
|
-
}, k = {
|
|
2071
|
-
position: "absolute",
|
|
2072
|
-
left: 4,
|
|
2073
|
-
top: 0,
|
|
2074
|
-
bottom: 0,
|
|
2075
|
-
width: 24,
|
|
2076
|
-
display: "flex",
|
|
2077
|
-
alignItems: "center",
|
|
2078
|
-
opacity: a || c && !m ? 1 : 0,
|
|
2079
|
-
transition: a ? void 0 : "opacity 0.15s ease",
|
|
2080
|
-
pointerEvents: a || c ? "auto" : "none"
|
|
2081
|
-
}, A = {
|
|
2082
|
-
width: 24,
|
|
2083
|
-
height: 24,
|
|
2084
|
-
display: "flex",
|
|
2085
|
-
alignItems: "center",
|
|
2086
|
-
justifyContent: "center",
|
|
2087
|
-
cursor: "pointer",
|
|
2088
|
-
borderRadius: 4,
|
|
2089
|
-
color: "#9ca3af",
|
|
2090
|
-
background: "none",
|
|
2091
|
-
border: "none",
|
|
2092
|
-
padding: 0,
|
|
2093
|
-
margin: 0,
|
|
2094
|
-
font: "inherit",
|
|
2095
|
-
lineHeight: 1,
|
|
2096
|
-
flexShrink: 0,
|
|
2097
|
-
userSelect: "none"
|
|
2098
|
-
}, j = {
|
|
2099
|
-
position: "absolute",
|
|
2100
|
-
left: i ? 0 : 32,
|
|
2101
|
-
right: 0,
|
|
2102
|
-
height: 2,
|
|
2103
|
-
backgroundColor: "#3b82f6",
|
|
2104
|
-
borderRadius: 1,
|
|
2105
|
-
pointerEvents: "none",
|
|
2106
|
-
zIndex: 10
|
|
2107
|
-
};
|
|
2108
|
-
return /* @__PURE__ */ p("div", {
|
|
2109
|
-
ref: v,
|
|
2110
|
-
"data-testid": "block",
|
|
2111
|
-
style: O,
|
|
2112
|
-
onMouseEnter: b,
|
|
2113
|
-
onMouseLeave: x,
|
|
2114
|
-
onDragOver: w,
|
|
2115
|
-
onDragLeave: T,
|
|
2116
|
-
onDrop: E,
|
|
2411
|
+
var J = {
|
|
2412
|
+
Container: "_Container_5gsai_1",
|
|
2413
|
+
Icon: "_Icon_5gsai_5",
|
|
2414
|
+
IconGrip: "_IconGrip_5gsai_16",
|
|
2415
|
+
IconAdd: "_IconAdd_5gsai_20",
|
|
2416
|
+
IconDuplicate: "_IconDuplicate_5gsai_21",
|
|
2417
|
+
IconTrash: "_IconTrash_5gsai_22",
|
|
2418
|
+
Block: "_Block_5gsai_38",
|
|
2419
|
+
SidePanel: "_SidePanel_5gsai_48",
|
|
2420
|
+
SidePanelVisible: "_SidePanelVisible_5gsai_60",
|
|
2421
|
+
SidePanelAlways: "_SidePanelAlways_5gsai_65",
|
|
2422
|
+
GripButton: "_GripButton_5gsai_71",
|
|
2423
|
+
GripButtonDragging: "_GripButtonDragging_5gsai_90",
|
|
2424
|
+
BlockMenu: "_BlockMenu_5gsai_94",
|
|
2425
|
+
BlockMenuItem: "_BlockMenuItem_5gsai_106",
|
|
2426
|
+
BlockMenuItemDelete: "_BlockMenuItemDelete_5gsai_123",
|
|
2427
|
+
BlockMenuSeparator: "_BlockMenuSeparator_5gsai_131",
|
|
2428
|
+
DropIndicator: "_DropIndicator_5gsai_137",
|
|
2429
|
+
Suggestions: "_Suggestions_5gsai_153",
|
|
2430
|
+
suggestionActive: "_suggestionActive_5gsai_181"
|
|
2431
|
+
}, Y = t(({ token: e }) => {
|
|
2432
|
+
let t = q().blocks.get(e), n = t.state.menuOpen.use(), r = t.state.menuPosition.use();
|
|
2433
|
+
return n ? /* @__PURE__ */ f("div", {
|
|
2434
|
+
ref: (e) => t.attachMenu(e),
|
|
2435
|
+
className: J.BlockMenu,
|
|
2436
|
+
style: {
|
|
2437
|
+
top: r.top,
|
|
2438
|
+
left: r.left
|
|
2439
|
+
},
|
|
2117
2440
|
children: [
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
children: /* @__PURE__ */
|
|
2125
|
-
ref: y,
|
|
2126
|
-
type: "button",
|
|
2127
|
-
draggable: !0,
|
|
2128
|
-
onDragStart: S,
|
|
2129
|
-
onDragEnd: C,
|
|
2130
|
-
onClick: D,
|
|
2131
|
-
style: {
|
|
2132
|
-
...A,
|
|
2133
|
-
cursor: m ? "grabbing" : "grab"
|
|
2134
|
-
},
|
|
2135
|
-
"aria-label": "Drag to reorder or click for options",
|
|
2136
|
-
children: /* @__PURE__ */ f("span", { className: ct })
|
|
2137
|
-
})
|
|
2441
|
+
/* @__PURE__ */ f("button", {
|
|
2442
|
+
type: "button",
|
|
2443
|
+
className: J.BlockMenuItem,
|
|
2444
|
+
onMouseDown: (e) => {
|
|
2445
|
+
e.preventDefault(), t.addBlock();
|
|
2446
|
+
},
|
|
2447
|
+
children: [/* @__PURE__ */ d("span", { className: m(J.Icon, J.IconAdd) }), /* @__PURE__ */ d("span", { children: "Add below" })]
|
|
2138
2448
|
}),
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2449
|
+
/* @__PURE__ */ f("button", {
|
|
2450
|
+
type: "button",
|
|
2451
|
+
className: J.BlockMenuItem,
|
|
2452
|
+
onMouseDown: (e) => {
|
|
2453
|
+
e.preventDefault(), t.duplicateBlock();
|
|
2454
|
+
},
|
|
2455
|
+
children: [/* @__PURE__ */ d("span", { className: m(J.Icon, J.IconDuplicate) }), /* @__PURE__ */ d("span", { children: "Duplicate" })]
|
|
2456
|
+
}),
|
|
2457
|
+
/* @__PURE__ */ d("div", { className: J.BlockMenuSeparator }),
|
|
2458
|
+
/* @__PURE__ */ f("button", {
|
|
2459
|
+
type: "button",
|
|
2460
|
+
className: m(J.BlockMenuItem, J.BlockMenuItemDelete),
|
|
2461
|
+
onMouseDown: (e) => {
|
|
2462
|
+
e.preventDefault(), t.deleteBlock();
|
|
2463
|
+
},
|
|
2464
|
+
children: [/* @__PURE__ */ d("span", { className: m(J.Icon, J.IconTrash) }), /* @__PURE__ */ d("span", { children: "Delete" })]
|
|
2465
|
+
})
|
|
2144
2466
|
]
|
|
2467
|
+
}) : null;
|
|
2468
|
+
});
|
|
2469
|
+
Y.displayName = "BlockMenu";
|
|
2470
|
+
//#endregion
|
|
2471
|
+
//#region src/components/DragHandle.tsx
|
|
2472
|
+
var jt = `${J.Icon} ${J.IconGrip}`, Mt = t(({ token: e, blockIndex: t }) => {
|
|
2473
|
+
let n = q(), r = n.state.readOnly.use(), i = n.state.drag.use(), a = n.blocks.get(e), o = a.state.isDragging.use(), c = a.state.isHovered.use(), l = s(() => et(i), [i]);
|
|
2474
|
+
return r ? null : /* @__PURE__ */ d("div", {
|
|
2475
|
+
className: m(J.SidePanel, l ? J.SidePanelAlways : c && !o && J.SidePanelVisible),
|
|
2476
|
+
children: /* @__PURE__ */ d("button", {
|
|
2477
|
+
ref: (e) => a.attachGrip(e, t, n.controllers.drag),
|
|
2478
|
+
type: "button",
|
|
2479
|
+
draggable: !0,
|
|
2480
|
+
className: m(J.GripButton, o && J.GripButtonDragging),
|
|
2481
|
+
"aria-label": "Drag to reorder or click for options",
|
|
2482
|
+
children: /* @__PURE__ */ d("span", { className: jt })
|
|
2483
|
+
})
|
|
2145
2484
|
});
|
|
2146
2485
|
});
|
|
2147
|
-
|
|
2486
|
+
Mt.displayName = "DragHandle";
|
|
2487
|
+
//#endregion
|
|
2488
|
+
//#region src/components/DropIndicator.tsx
|
|
2489
|
+
var X = t(({ token: e, position: t }) => q().blocks.get(e).state.dropPosition.use() === t ? /* @__PURE__ */ d("div", {
|
|
2490
|
+
className: J.DropIndicator,
|
|
2491
|
+
style: t === "before" ? { top: -1 } : { bottom: -1 }
|
|
2492
|
+
}) : null);
|
|
2493
|
+
X.displayName = "DropIndicator";
|
|
2148
2494
|
//#endregion
|
|
2149
2495
|
//#region src/lib/providers/TokenContext.ts
|
|
2150
|
-
var
|
|
2151
|
-
|
|
2152
|
-
function
|
|
2153
|
-
let e =
|
|
2496
|
+
var Z = e(void 0);
|
|
2497
|
+
Z.displayName = "TokenProvider";
|
|
2498
|
+
function Nt() {
|
|
2499
|
+
let e = r(Z);
|
|
2154
2500
|
if (e === void 0) throw Error("Token not found. Make sure to wrap component in TokenContext.Provider.");
|
|
2155
2501
|
return e;
|
|
2156
2502
|
}
|
|
2157
2503
|
//#endregion
|
|
2158
|
-
//#region src/
|
|
2159
|
-
|
|
2160
|
-
let
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
let e = ut(), t = X(), n = t.state.options.use(), r = t.key, i = n?.[e.descriptor.index], a = e.children.map((e) => /* @__PURE__ */ f($, {
|
|
2168
|
-
mark: e,
|
|
2169
|
-
isNested: !0
|
|
2170
|
-
}, r.get(e))), [o, s] = dt("mark", i, {
|
|
2171
|
-
value: e.value,
|
|
2172
|
-
meta: e.meta,
|
|
2173
|
-
nested: e.nested?.content,
|
|
2174
|
-
children: e.children.length > 0 ? a : void 0
|
|
2175
|
-
});
|
|
2176
|
-
return /* @__PURE__ */ f(o, { ...s });
|
|
2177
|
-
}
|
|
2178
|
-
//#endregion
|
|
2179
|
-
//#region src/components/TextSpan.tsx
|
|
2180
|
-
var pt = () => {
|
|
2181
|
-
let e = ut(), t = X(), n = l(null), r = t.state.slots.use(), i = t.state.slotProps.use(), a = c(() => y("span", r), [r]), o = c(() => b("span", i), [i]);
|
|
2182
|
-
if (e.type !== "text") throw Error("TextSpan component expects a TextToken");
|
|
2183
|
-
return s(() => {
|
|
2184
|
-
n.current && n.current.textContent !== e.content && (n.current.textContent = e.content);
|
|
2185
|
-
}, [e.content]), /* @__PURE__ */ f(a, {
|
|
2186
|
-
...o,
|
|
2187
|
-
ref: n
|
|
2504
|
+
//#region src/components/Token.tsx
|
|
2505
|
+
var Q = t(({ mark: e }) => {
|
|
2506
|
+
let t = q(), [n, r] = t.slot.mark.use(e);
|
|
2507
|
+
return /* @__PURE__ */ d(Z, {
|
|
2508
|
+
value: e,
|
|
2509
|
+
children: /* @__PURE__ */ d(n, {
|
|
2510
|
+
children: e.type === "mark" && e.children.length > 0 ? e.children.map((e) => /* @__PURE__ */ d(Q, { mark: e }, t.key.get(e))) : void 0,
|
|
2511
|
+
...r
|
|
2512
|
+
})
|
|
2188
2513
|
});
|
|
2189
|
-
}
|
|
2190
|
-
|
|
2191
|
-
children: /* @__PURE__ */ f(ft, {})
|
|
2192
|
-
}) : t ? /* @__PURE__ */ f(d, { children: e.content }) : /* @__PURE__ */ f(Q, {
|
|
2193
|
-
value: e,
|
|
2194
|
-
children: /* @__PURE__ */ f(pt, {})
|
|
2195
|
-
}));
|
|
2196
|
-
$.displayName = "Token";
|
|
2514
|
+
});
|
|
2515
|
+
Q.displayName = "Token";
|
|
2197
2516
|
//#endregion
|
|
2198
|
-
//#region src/components/
|
|
2199
|
-
var
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
margin: "4px 0"
|
|
2208
|
-
}, gt = n(({ position: e, onAdd: t, onDelete: n, onDuplicate: r, onClose: i }) => {
|
|
2209
|
-
let o = l(null), [s, c] = u(null), d = l(i);
|
|
2210
|
-
d.current = i, a(() => {
|
|
2211
|
-
let e = (e) => {
|
|
2212
|
-
o.current && !o.current.contains(e.target) && d.current();
|
|
2213
|
-
}, t = (e) => {
|
|
2214
|
-
e.key === "Escape" && d.current();
|
|
2215
|
-
};
|
|
2216
|
-
return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
|
|
2217
|
-
document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
|
|
2218
|
-
};
|
|
2219
|
-
}, []);
|
|
2220
|
-
let m = {
|
|
2221
|
-
position: "fixed",
|
|
2222
|
-
top: e.top,
|
|
2223
|
-
left: e.left,
|
|
2224
|
-
background: "white",
|
|
2225
|
-
border: "1px solid rgba(55, 53, 47, 0.16)",
|
|
2226
|
-
borderRadius: 6,
|
|
2227
|
-
boxShadow: "0 4px 16px rgba(15, 15, 15, 0.12)",
|
|
2228
|
-
padding: 4,
|
|
2229
|
-
zIndex: 9999,
|
|
2230
|
-
minWidth: 160,
|
|
2231
|
-
fontSize: 14
|
|
2232
|
-
}, g = (e) => ({
|
|
2233
|
-
display: "flex",
|
|
2234
|
-
alignItems: "center",
|
|
2235
|
-
gap: 8,
|
|
2236
|
-
padding: "6px 10px",
|
|
2237
|
-
borderRadius: 4,
|
|
2238
|
-
cursor: "pointer",
|
|
2239
|
-
color: e === "delete" ? "#eb5757" : "rgba(55, 53, 47, 0.85)",
|
|
2240
|
-
background: s === e ? e === "delete" ? "rgba(235, 87, 87, 0.06)" : "rgba(55, 53, 47, 0.06)" : "transparent",
|
|
2241
|
-
transition: "background 0.1s ease",
|
|
2242
|
-
userSelect: "none",
|
|
2243
|
-
lineHeight: 1
|
|
2244
|
-
});
|
|
2245
|
-
return /* @__PURE__ */ p("div", {
|
|
2246
|
-
ref: o,
|
|
2247
|
-
style: m,
|
|
2517
|
+
//#region src/components/Block.tsx
|
|
2518
|
+
var Pt = t(({ token: e, blockIndex: t }) => {
|
|
2519
|
+
let n = q(), [r, i] = n.slot.block.use(), a = n.blocks.get(e), o = a.state.isDragging.use();
|
|
2520
|
+
return /* @__PURE__ */ f(r, {
|
|
2521
|
+
ref: (e) => a.attachContainer(e, t, n.controllers.drag),
|
|
2522
|
+
"data-testid": "block",
|
|
2523
|
+
...i,
|
|
2524
|
+
className: J.Block,
|
|
2525
|
+
style: { opacity: o ? .4 : 1 },
|
|
2248
2526
|
children: [
|
|
2249
|
-
/* @__PURE__ */
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
onMouseLeave: () => c(null),
|
|
2253
|
-
onMouseDown: (e) => {
|
|
2254
|
-
e.preventDefault(), t(), i();
|
|
2255
|
-
},
|
|
2256
|
-
children: [/* @__PURE__ */ f("span", { className: h(Z.Icon, Z.IconAdd) }), /* @__PURE__ */ f("span", { children: "Add below" })]
|
|
2527
|
+
/* @__PURE__ */ d(X, {
|
|
2528
|
+
token: e,
|
|
2529
|
+
position: "before"
|
|
2257
2530
|
}),
|
|
2258
|
-
/* @__PURE__ */
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
onMouseLeave: () => c(null),
|
|
2262
|
-
onMouseDown: (e) => {
|
|
2263
|
-
e.preventDefault(), r(), i();
|
|
2264
|
-
},
|
|
2265
|
-
children: [/* @__PURE__ */ f("span", { className: h(Z.Icon, Z.IconDuplicate) }), /* @__PURE__ */ f("span", { children: "Duplicate" })]
|
|
2531
|
+
/* @__PURE__ */ d(Mt, {
|
|
2532
|
+
token: e,
|
|
2533
|
+
blockIndex: t
|
|
2266
2534
|
}),
|
|
2267
|
-
/* @__PURE__ */
|
|
2268
|
-
/* @__PURE__ */
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
e.preventDefault(), n(), i();
|
|
2274
|
-
},
|
|
2275
|
-
children: [/* @__PURE__ */ f("span", { className: h(Z.Icon, Z.IconTrash) }), /* @__PURE__ */ f("span", { children: "Delete" })]
|
|
2276
|
-
})
|
|
2535
|
+
/* @__PURE__ */ d(Q, { mark: e }),
|
|
2536
|
+
/* @__PURE__ */ d(X, {
|
|
2537
|
+
token: e,
|
|
2538
|
+
position: "after"
|
|
2539
|
+
}),
|
|
2540
|
+
/* @__PURE__ */ d(Y, { token: e })
|
|
2277
2541
|
]
|
|
2278
2542
|
});
|
|
2279
2543
|
});
|
|
2280
|
-
|
|
2281
|
-
var _t = n(() => {
|
|
2282
|
-
let e = X(), t = e.state.tokens.use(), n = e.state.slots.use(), i = e.state.slotProps.use(), a = e.state.className.use(), o = e.state.style.use(), s = e.state.readOnly.use(), m = De(e.state.drag.use()), h = e.state.value.use(), g = e.state.onChange.use(), _ = e.key, v = e.refs, [x, S] = u(null), C = c(() => y("container", n), [n]), w = c(() => b("container", i), [i]), T = c(() => {
|
|
2283
|
-
let e = G(t);
|
|
2284
|
-
return e.length > 0 ? e : [mt];
|
|
2285
|
-
}, [t]), E = l(T);
|
|
2286
|
-
E.current = T;
|
|
2287
|
-
let D = r((t, n) => {
|
|
2288
|
-
if (h == null || !g) return;
|
|
2289
|
-
let r = Ne(h, E.current, t, n);
|
|
2290
|
-
r !== h && e.applyValue(r);
|
|
2291
|
-
}, [
|
|
2292
|
-
e,
|
|
2293
|
-
h,
|
|
2294
|
-
g
|
|
2295
|
-
]), O = r((t) => {
|
|
2296
|
-
h == null || !g || (e.applyValue(ke(h, E.current, t)), queueMicrotask(() => {
|
|
2297
|
-
let n = e.refs.container;
|
|
2298
|
-
if (!n) return;
|
|
2299
|
-
let r = t + 1;
|
|
2300
|
-
n.children[r]?.focus();
|
|
2301
|
-
}));
|
|
2302
|
-
}, [
|
|
2303
|
-
e,
|
|
2304
|
-
h,
|
|
2305
|
-
g
|
|
2306
|
-
]), k = r((t) => {
|
|
2307
|
-
h == null || !g || e.applyValue(Ae(h, E.current, t));
|
|
2308
|
-
}, [
|
|
2309
|
-
e,
|
|
2310
|
-
h,
|
|
2311
|
-
g
|
|
2312
|
-
]), A = r((t) => {
|
|
2313
|
-
h == null || !g || e.applyValue(je(h, E.current, t));
|
|
2314
|
-
}, [
|
|
2315
|
-
e,
|
|
2316
|
-
h,
|
|
2317
|
-
g
|
|
2318
|
-
]), j = r((e, t) => {
|
|
2319
|
-
S({
|
|
2320
|
-
index: e,
|
|
2321
|
-
position: {
|
|
2322
|
-
top: t.bottom + 4,
|
|
2323
|
-
left: t.left
|
|
2324
|
-
}
|
|
2325
|
-
});
|
|
2326
|
-
}, []), M = r(() => S(null), []);
|
|
2327
|
-
return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(C, {
|
|
2328
|
-
ref: (e) => v.container = e,
|
|
2329
|
-
...w,
|
|
2330
|
-
className: a,
|
|
2331
|
-
style: o,
|
|
2332
|
-
children: T.map((e, t) => /* @__PURE__ */ f(lt, {
|
|
2333
|
-
blockIndex: t,
|
|
2334
|
-
readOnly: s,
|
|
2335
|
-
alwaysShowHandle: m,
|
|
2336
|
-
onReorder: D,
|
|
2337
|
-
onRequestMenu: j,
|
|
2338
|
-
children: e.tokens.map((e) => /* @__PURE__ */ f($, { mark: e }, _.get(e)))
|
|
2339
|
-
}, e.id))
|
|
2340
|
-
}), x && /* @__PURE__ */ f(gt, {
|
|
2341
|
-
position: x.position,
|
|
2342
|
-
onAdd: () => {
|
|
2343
|
-
O(x.index), M();
|
|
2344
|
-
},
|
|
2345
|
-
onDelete: () => {
|
|
2346
|
-
k(x.index), M();
|
|
2347
|
-
},
|
|
2348
|
-
onDuplicate: () => {
|
|
2349
|
-
A(x.index), M();
|
|
2350
|
-
},
|
|
2351
|
-
onClose: M
|
|
2352
|
-
})] });
|
|
2353
|
-
});
|
|
2354
|
-
_t.displayName = "BlockContainer";
|
|
2544
|
+
Pt.displayName = "Block";
|
|
2355
2545
|
//#endregion
|
|
2356
2546
|
//#region src/components/Container.tsx
|
|
2357
|
-
var
|
|
2358
|
-
let e =
|
|
2359
|
-
return /* @__PURE__ */
|
|
2547
|
+
var Ft = t(() => {
|
|
2548
|
+
let e = q(), t = e.state.drag.use(), n = e.state.tokens.use(), r = e.state.className.use(), i = e.state.style.use(), a = e.state.readOnly.use(), o = e.key, s = e.refs, [c, l] = e.slot.container.use();
|
|
2549
|
+
return /* @__PURE__ */ d(c, {
|
|
2360
2550
|
ref: (e) => s.container = e,
|
|
2361
|
-
...
|
|
2362
|
-
className:
|
|
2363
|
-
style: a
|
|
2364
|
-
|
|
2551
|
+
...l,
|
|
2552
|
+
className: r,
|
|
2553
|
+
style: t && !a ? {
|
|
2554
|
+
paddingLeft: 24,
|
|
2555
|
+
...i
|
|
2556
|
+
} : i,
|
|
2557
|
+
children: t ? n.map((e, t) => /* @__PURE__ */ d(Pt, {
|
|
2558
|
+
token: e,
|
|
2559
|
+
blockIndex: t
|
|
2560
|
+
}, o.get(e))) : n.map((e) => /* @__PURE__ */ d(Q, { mark: e }, o.get(e)))
|
|
2365
2561
|
});
|
|
2366
2562
|
});
|
|
2367
|
-
|
|
2563
|
+
Ft.displayName = "Container";
|
|
2368
2564
|
//#endregion
|
|
2369
2565
|
//#region src/lib/hooks/useOverlay.tsx
|
|
2370
|
-
function
|
|
2371
|
-
let e =
|
|
2566
|
+
function It() {
|
|
2567
|
+
let e = q(), t = e.state.overlayMatch.use();
|
|
2568
|
+
if (!t) throw Error("useOverlay requires an active overlay match");
|
|
2569
|
+
let r = s(() => F.getAbsolutePosition(), [t]), i = n(() => e.events.clearOverlay(), []);
|
|
2372
2570
|
return {
|
|
2373
2571
|
match: t,
|
|
2374
|
-
style:
|
|
2375
|
-
select:
|
|
2376
|
-
let r =
|
|
2572
|
+
style: r,
|
|
2573
|
+
select: n((n) => {
|
|
2574
|
+
let r = wt(t, n.value, n.meta);
|
|
2377
2575
|
e.events.select({
|
|
2378
2576
|
mark: r,
|
|
2379
2577
|
match: t
|
|
2380
2578
|
}), e.events.clearOverlay();
|
|
2381
2579
|
}, [t]),
|
|
2382
2580
|
close: i,
|
|
2383
|
-
ref:
|
|
2581
|
+
ref: s(() => ({
|
|
2384
2582
|
get current() {
|
|
2385
2583
|
return e.refs.overlay;
|
|
2386
2584
|
},
|
|
@@ -2392,19 +2590,19 @@ function yt() {
|
|
|
2392
2590
|
}
|
|
2393
2591
|
//#endregion
|
|
2394
2592
|
//#region src/components/Suggestions/Suggestions.tsx
|
|
2395
|
-
var
|
|
2396
|
-
let e =
|
|
2593
|
+
var Lt = () => {
|
|
2594
|
+
let e = q(), { match: t, select: n, style: r, ref: a } = It(), [o, u] = l(NaN), f = t.option.overlay?.data ?? [], p = s(() => Ct(f, t.value), [t.value, f]), m = p.length, h = c(o);
|
|
2397
2595
|
h.current = o;
|
|
2398
|
-
let g =
|
|
2399
|
-
return g.current = p,
|
|
2596
|
+
let g = c(p);
|
|
2597
|
+
return g.current = p, i(() => {
|
|
2400
2598
|
let t = e.refs.container;
|
|
2401
2599
|
if (!t) return;
|
|
2402
2600
|
let r = (e) => {
|
|
2403
|
-
let t =
|
|
2601
|
+
let t = Et(e.key, h.current, m);
|
|
2404
2602
|
switch (t.action) {
|
|
2405
2603
|
case "up":
|
|
2406
2604
|
case "down":
|
|
2407
|
-
e.preventDefault(),
|
|
2605
|
+
e.preventDefault(), u(t.index);
|
|
2408
2606
|
break;
|
|
2409
2607
|
case "select": {
|
|
2410
2608
|
e.preventDefault();
|
|
@@ -2415,16 +2613,19 @@ var bt = () => {
|
|
|
2415
2613
|
});
|
|
2416
2614
|
break;
|
|
2417
2615
|
}
|
|
2616
|
+
case "none": break;
|
|
2418
2617
|
}
|
|
2419
2618
|
};
|
|
2420
2619
|
return t.addEventListener("keydown", r), () => t.removeEventListener("keydown", r);
|
|
2421
|
-
}, [m, n]), p.length ? /* @__PURE__ */
|
|
2422
|
-
ref:
|
|
2423
|
-
|
|
2620
|
+
}, [m, n]), p.length ? /* @__PURE__ */ d("ul", {
|
|
2621
|
+
ref: (e) => {
|
|
2622
|
+
a.current = e;
|
|
2623
|
+
},
|
|
2624
|
+
className: J.Suggestions,
|
|
2424
2625
|
style: r,
|
|
2425
2626
|
children: p.map((e, t) => {
|
|
2426
|
-
let r = t === o ?
|
|
2427
|
-
return /* @__PURE__ */
|
|
2627
|
+
let r = t === o ? J.suggestionActive : void 0;
|
|
2628
|
+
return /* @__PURE__ */ d("li", {
|
|
2428
2629
|
ref: (e) => {
|
|
2429
2630
|
r && e && e.scrollIntoView(!1);
|
|
2430
2631
|
},
|
|
@@ -2437,54 +2638,61 @@ var bt = () => {
|
|
|
2437
2638
|
}, e);
|
|
2438
2639
|
})
|
|
2439
2640
|
}) : null;
|
|
2440
|
-
},
|
|
2441
|
-
let e =
|
|
2442
|
-
if (n) return /* @__PURE__ */
|
|
2641
|
+
}, Rt = t(() => {
|
|
2642
|
+
let e = q(), t = e.state.overlayMatch.use(), n = s(() => t ? e.key.get(t.option) : void 0, [t]), [r, i] = e.slot.overlay.use(t?.option, Lt);
|
|
2643
|
+
if (n) return /* @__PURE__ */ d(r, { ...i }, n);
|
|
2443
2644
|
});
|
|
2444
|
-
|
|
2645
|
+
Rt.displayName = "OverlayRenderer";
|
|
2646
|
+
//#endregion
|
|
2647
|
+
//#region src/components/Span.tsx
|
|
2648
|
+
var $ = (e) => /* @__PURE__ */ d("span", {});
|
|
2445
2649
|
//#endregion
|
|
2446
2650
|
//#region src/components/MarkedInput.tsx
|
|
2447
|
-
function
|
|
2448
|
-
let { ref: t
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2651
|
+
function zt(e) {
|
|
2652
|
+
let { ref: t } = e, n = m(J.Container, e.className, e.slotProps?.container?.className), r = h(e.style, e.slotProps?.container?.style), [i] = l(() => new Dt({
|
|
2653
|
+
createUseHook: kt,
|
|
2654
|
+
defaultSpan: $
|
|
2655
|
+
}));
|
|
2656
|
+
return i.state.set({
|
|
2657
|
+
value: e.value,
|
|
2658
|
+
defaultValue: e.defaultValue,
|
|
2659
|
+
onChange: e.onChange,
|
|
2660
|
+
readOnly: e.readOnly ?? !1,
|
|
2661
|
+
drag: e.drag ?? !1,
|
|
2662
|
+
options: e.options ?? ie,
|
|
2663
|
+
showOverlayOn: e.showOverlayOn ?? "change",
|
|
2664
|
+
Span: e.Span,
|
|
2665
|
+
Mark: e.Mark,
|
|
2666
|
+
Overlay: e.Overlay,
|
|
2667
|
+
className: n,
|
|
2668
|
+
style: r,
|
|
2669
|
+
slots: e.slots,
|
|
2670
|
+
slotProps: e.slotProps
|
|
2671
|
+
}), At(i, t), /* @__PURE__ */ f(K, {
|
|
2672
|
+
value: i,
|
|
2673
|
+
children: [/* @__PURE__ */ d(Ft, {}), /* @__PURE__ */ d(Rt, {})]
|
|
2466
2674
|
});
|
|
2467
2675
|
}
|
|
2468
2676
|
//#endregion
|
|
2469
2677
|
//#region src/lib/hooks/useMark.tsx
|
|
2470
|
-
var
|
|
2471
|
-
let t =
|
|
2472
|
-
if (n.type !== "mark") throw Error("useMark
|
|
2473
|
-
let [
|
|
2678
|
+
var Bt = (e = {}) => {
|
|
2679
|
+
let t = q(), n = Nt();
|
|
2680
|
+
if (n.type !== "mark") throw Error("useMark must be called within a mark token context");
|
|
2681
|
+
let r = c(null), [a] = l(() => new Ot({
|
|
2474
2682
|
ref: r,
|
|
2475
2683
|
store: t,
|
|
2476
2684
|
token: n
|
|
2477
2685
|
}));
|
|
2478
|
-
|
|
2686
|
+
Vt(r, e, n);
|
|
2479
2687
|
let o = t.state.readOnly.use();
|
|
2480
|
-
return
|
|
2481
|
-
|
|
2482
|
-
}, [o]),
|
|
2688
|
+
return i(() => {
|
|
2689
|
+
a.readOnly = o;
|
|
2690
|
+
}, [o]), a;
|
|
2483
2691
|
};
|
|
2484
|
-
function
|
|
2485
|
-
|
|
2486
|
-
|
|
2692
|
+
function Vt(e, t, n) {
|
|
2693
|
+
i(() => {
|
|
2694
|
+
!t.controlled && e.current && (e.current.textContent = n.content);
|
|
2487
2695
|
}, []);
|
|
2488
2696
|
}
|
|
2489
2697
|
//#endregion
|
|
2490
|
-
export {
|
|
2698
|
+
export { Ot as MarkHandler, zt as MarkedInput, $ as Span, w as annotate, Se as denote, Bt as useMark, It as useOverlay };
|