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