@connectedxm/entity-editor 0.0.12 → 0.0.13
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/dist/index.es.js +651 -795
- package/package.json +7 -7
- package/dist/src/Editor.d.ts +0 -32
- package/dist/src/__tests__/Editor.test.d.ts +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1,796 +1,652 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
function
|
|
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
|
-
let
|
|
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
|
-
if (b ? (!T || b.startIndex !== T.startIndex || b.endIndex !== T.endIndex || b.search !== T.search) && z(b) : T && z(null), P) return;
|
|
653
|
-
let d = !0, g = !0, E = !0, p = !0;
|
|
654
|
-
if (h === I)
|
|
655
|
-
if (h > 0) {
|
|
656
|
-
const _ = A(x, h - 1);
|
|
657
|
-
d = ae(_), g = fe(_), E = Ee(_), p = de(_);
|
|
658
|
-
} else {
|
|
659
|
-
const _ = A(x, h);
|
|
660
|
-
d = ae(_), g = fe(_), E = Ee(_), p = de(_);
|
|
661
|
-
}
|
|
662
|
-
else
|
|
663
|
-
for (let _ = h; _ < I; _++) {
|
|
664
|
-
const le = A(x, _);
|
|
665
|
-
d = ae(le) ? d : !1, g = fe(le) ? g : !1, E = Ee(le) ? E : !1, p = de(le) ? p : !1;
|
|
666
|
-
}
|
|
667
|
-
oe({
|
|
668
|
-
bold: d,
|
|
669
|
-
italic: g,
|
|
670
|
-
underline: E,
|
|
671
|
-
strike: p
|
|
672
|
-
});
|
|
673
|
-
}, [ce, x, v, P]);
|
|
674
|
-
const ve = (h) => {
|
|
675
|
-
if (!w.current) return;
|
|
676
|
-
if (h.target.textContent.length === 0) {
|
|
677
|
-
D(""), j([]), P && V(!1);
|
|
678
|
-
return;
|
|
679
|
-
}
|
|
680
|
-
const I = h.target.innerText || "", b = Fe(v, I);
|
|
681
|
-
if (b) {
|
|
682
|
-
let d = Ke(x, b, O);
|
|
683
|
-
if (b.deletedLength === 0 && b.insertedText === " " && b.position > 0) {
|
|
684
|
-
const g = b.position;
|
|
685
|
-
if (f.links && !me(A(d, g - 1))) {
|
|
686
|
-
const E = ze(I, g);
|
|
687
|
-
if (E && E.endIndex === g) {
|
|
688
|
-
const p = `${E.startIndex}:${E.endIndex}:${E.search}`;
|
|
689
|
-
if (S.current !== p) {
|
|
690
|
-
for (let N = E.startIndex; N < E.endIndex; N++)
|
|
691
|
-
d[N] = Ne(d, N, "link");
|
|
692
|
-
if (S.current = p, K.current) {
|
|
693
|
-
const N = {
|
|
694
|
-
type: "link",
|
|
695
|
-
startIndex: E.startIndex,
|
|
696
|
-
endIndex: E.endIndex,
|
|
697
|
-
marks: [],
|
|
698
|
-
href: E.search
|
|
699
|
-
};
|
|
700
|
-
K.current(N);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
if (f.interests && !Ie(A(d, g - 1))) {
|
|
706
|
-
const E = Je(I, g);
|
|
707
|
-
if (E && E.endIndex === g) {
|
|
708
|
-
const p = `${E.startIndex}:${E.endIndex}:${E.search}`;
|
|
709
|
-
if (F.current !== p) {
|
|
710
|
-
for (let N = E.startIndex; N < E.endIndex; N++)
|
|
711
|
-
d[N] = Ne(d, N, "interest");
|
|
712
|
-
if (F.current = p, k.current) {
|
|
713
|
-
const N = {
|
|
714
|
-
type: "interest",
|
|
715
|
-
startIndex: E.startIndex,
|
|
716
|
-
endIndex: E.endIndex,
|
|
717
|
-
marks: [],
|
|
718
|
-
interest: E.search.replace(Se, "").toLowerCase()
|
|
719
|
-
};
|
|
720
|
-
k.current(N);
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
j(d), J.current = !0, setTimeout(() => {
|
|
727
|
-
J.current = !1;
|
|
728
|
-
}, 50);
|
|
729
|
-
} else P && V(!1);
|
|
730
|
-
D(I);
|
|
731
|
-
}, Xe = (h) => {
|
|
732
|
-
w.current && rt(h, U);
|
|
733
|
-
}, qe = () => {
|
|
734
|
-
ie(!0);
|
|
735
|
-
}, Ge = () => {
|
|
736
|
-
ie(!1);
|
|
737
|
-
};
|
|
738
|
-
a.useEffect(() => {
|
|
739
|
-
const h = () => {
|
|
740
|
-
if (n.current) return;
|
|
741
|
-
const I = De(w.current) ?? {
|
|
742
|
-
start: 0,
|
|
743
|
-
end: 0
|
|
744
|
-
}, b = M.current;
|
|
745
|
-
(I.start !== b.start || I.end !== b.end) && (M.current = I, H.current && !J.current && V(!1), $.current && clearTimeout($.current), $.current = setTimeout(() => {
|
|
746
|
-
be(I);
|
|
747
|
-
}, 500));
|
|
748
|
-
};
|
|
749
|
-
return document.addEventListener("selectionchange", h), () => {
|
|
750
|
-
document.removeEventListener("selectionchange", h), $.current && clearTimeout($.current);
|
|
751
|
-
};
|
|
752
|
-
}, []);
|
|
753
|
-
const He = v.length === 0 && y && !we;
|
|
754
|
-
return /* @__PURE__ */ B.jsxs(B.Fragment, { children: [
|
|
755
|
-
/* @__PURE__ */ B.jsxs("div", { style: { position: "relative" }, children: [
|
|
756
|
-
/* @__PURE__ */ B.jsx(
|
|
757
|
-
"div",
|
|
758
|
-
{
|
|
759
|
-
ref: w,
|
|
760
|
-
style: { ...W.style, position: "relative", zIndex: 2 },
|
|
761
|
-
className: W.className,
|
|
762
|
-
contentEditable: !0,
|
|
763
|
-
onKeyDown: Xe,
|
|
764
|
-
onInput: ve,
|
|
765
|
-
onFocus: qe,
|
|
766
|
-
onBlur: Ge,
|
|
767
|
-
role: "textbox",
|
|
768
|
-
"aria-multiline": "true",
|
|
769
|
-
autoCapitalize: "off",
|
|
770
|
-
autoFocus: !1
|
|
771
|
-
}
|
|
772
|
-
),
|
|
773
|
-
He && /* @__PURE__ */ B.jsx(
|
|
774
|
-
"div",
|
|
775
|
-
{
|
|
776
|
-
style: {
|
|
777
|
-
...W.style,
|
|
778
|
-
position: "absolute",
|
|
779
|
-
top: 0,
|
|
780
|
-
left: 0,
|
|
781
|
-
right: 0,
|
|
782
|
-
bottom: 0,
|
|
783
|
-
color: "#9ca3af",
|
|
784
|
-
pointerEvents: "none"
|
|
785
|
-
},
|
|
786
|
-
"aria-hidden": "true",
|
|
787
|
-
children: /* @__PURE__ */ B.jsx("p", { style: { margin: 0 }, children: y })
|
|
788
|
-
}
|
|
789
|
-
)
|
|
790
|
-
] }),
|
|
791
|
-
se && /* @__PURE__ */ B.jsx("div", { style: {}, children: /* @__PURE__ */ B.jsx("pre", { children: JSON.stringify(x) }) })
|
|
792
|
-
] });
|
|
793
|
-
};
|
|
794
|
-
export {
|
|
795
|
-
bt as Editor
|
|
1
|
+
import e from "react";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var t = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), n = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
4
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
5
|
+
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
6
|
+
}), r = (e) => {
|
|
7
|
+
let t = window.getSelection();
|
|
8
|
+
if (!t || !e) return {
|
|
9
|
+
start: 0,
|
|
10
|
+
end: 0
|
|
11
|
+
};
|
|
12
|
+
if (t.anchorNode && e.contains(t.anchorNode)) {
|
|
13
|
+
let n = t.getRangeAt(0), r = n.cloneRange();
|
|
14
|
+
r.selectNodeContents(e), r.setEnd(n.startContainer, n.startOffset);
|
|
15
|
+
let i = r.toString().length, a = n.cloneRange();
|
|
16
|
+
return a.selectNodeContents(e), a.setEnd(n.endContainer, n.endOffset), {
|
|
17
|
+
start: i,
|
|
18
|
+
end: a.toString().length
|
|
19
|
+
};
|
|
20
|
+
} else return null;
|
|
21
|
+
}, i = (e, t) => {
|
|
22
|
+
let n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0, i = n.nextNode(), a = null, o = null, s = 0, c = 0;
|
|
23
|
+
for (; i;) {
|
|
24
|
+
let e = r + (i.textContent?.length || 0);
|
|
25
|
+
if (!a && e >= t.start && (a = i, s = t.start - r), !o && e >= t.end) {
|
|
26
|
+
o = i, c = t.end - r;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
r = e, i = n.nextNode();
|
|
30
|
+
}
|
|
31
|
+
if (a && o) {
|
|
32
|
+
let e = document.createRange();
|
|
33
|
+
e.setStart(a, Math.min(s, a.textContent?.length || 0)), e.setEnd(o, Math.min(c, o.textContent?.length || 0));
|
|
34
|
+
let t = window.getSelection();
|
|
35
|
+
t?.removeAllRanges(), t?.addRange(e);
|
|
36
|
+
}
|
|
37
|
+
}, a = (e, t, n) => {
|
|
38
|
+
let r = "", i = "", a = "", o = "";
|
|
39
|
+
t.includes("bold") && (i = "bold"), t.includes("italic") && (a = "italic"), (t.includes("underline") || e === "link") && (o += "underline"), t.includes("strike") && (o += " line-through"), e !== "segment" && (r = "#1da1f2", e === "mention" && n.mentionColor ? r = n.mentionColor : e === "interest" && n.interestColor ? r = n.interestColor : e === "link" && n.linkColor && (r = n.linkColor));
|
|
40
|
+
let s = "";
|
|
41
|
+
return r && (s += `color: ${r}; `), i && (s += `font-weight: ${i}; `), a && (s += `font-style: ${a}; `), o && (s += `text-decoration: ${o}; `), s;
|
|
42
|
+
}, o = (e, t, n) => {
|
|
43
|
+
if (t.length === 0) return e;
|
|
44
|
+
let r = "", i = 0;
|
|
45
|
+
return t.forEach((t) => {
|
|
46
|
+
i < t.startIndex && (r += e.slice(i, t.startIndex));
|
|
47
|
+
let o = e.slice(t.startIndex, t.endIndex), s = a(t.type, t.marks, n);
|
|
48
|
+
r += `<span style="${s}">${o}</span>`, i = t.endIndex;
|
|
49
|
+
}), r += e.slice(i), r;
|
|
50
|
+
}, s = (e, t) => {
|
|
51
|
+
let n = !1;
|
|
52
|
+
e.key === "Enter" && !e.shiftKey ? (e.preventDefault(), document.execCommand("insertLineBreak"), n = !0) : (e.metaKey || e.ctrlKey) && (e.key === "b" ? (t("bold"), n = !0) : e.key === "i" ? (t("italic"), n = !0) : e.key === "u" ? (t("underline"), n = !0) : e.key === "s" && (t("strike"), n = !0)), n && e.preventDefault();
|
|
53
|
+
}, c = "()[]{}", l = /* @__PURE__ */ RegExp("^(?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$", "i"), u = (e, t) => {
|
|
54
|
+
let n = k(e, t, c, "");
|
|
55
|
+
return n?.search.match(l) ? n : null;
|
|
56
|
+
}, d = (e) => (e & 128) != 0, f = (e, t) => t ? e | 128 : e & -129, p = /^@[a-zA-Z0-9_'-]+$/, m = ".,!?;()[]{}\"'<>#", h = (e, t) => {
|
|
57
|
+
let n = k(e, t, m, "@");
|
|
58
|
+
return n?.search.match(p) ? {
|
|
59
|
+
type: "mention",
|
|
60
|
+
...n
|
|
61
|
+
} : null;
|
|
62
|
+
}, g = (e) => (e & 32) != 0, _ = (e, t) => t ? e | 32 : e & -33, v = (e) => (e & 2) != 0, y = (e, t) => t ? e | 2 : e & -3, b = (e) => (e & 4) != 0, x = (e, t) => t ? e | 4 : e & -5, S = (e) => (e & 16) != 0, C = (e, t) => t ? e | 16 : e & -17, w = (e) => (e & 8) != 0, T = (e, t) => t ? e | 8 : e & -9, E = (e, t) => {
|
|
63
|
+
if (e === t) return null;
|
|
64
|
+
let n = 0;
|
|
65
|
+
for (; n < e.length && n < t.length && e[n] === t[n];) n++;
|
|
66
|
+
let r = e.length, i = t.length;
|
|
67
|
+
for (; r > n && i > n && e[r - 1] === t[i - 1];) r--, i--;
|
|
68
|
+
return {
|
|
69
|
+
position: n,
|
|
70
|
+
deletedLength: r - n,
|
|
71
|
+
insertedText: t.slice(n, i)
|
|
72
|
+
};
|
|
73
|
+
}, D = (e, t, n, r) => {
|
|
74
|
+
let i = t;
|
|
75
|
+
for (; i < e.length;) {
|
|
76
|
+
let t = R(e, i);
|
|
77
|
+
if (n(t)) e[i] = r(t, !1);
|
|
78
|
+
else break;
|
|
79
|
+
i++;
|
|
80
|
+
}
|
|
81
|
+
let a = t - 1;
|
|
82
|
+
for (; a >= 0;) {
|
|
83
|
+
let t = R(e, a);
|
|
84
|
+
if (n(t)) e[a] = r(t, !1);
|
|
85
|
+
else break;
|
|
86
|
+
a--;
|
|
87
|
+
}
|
|
88
|
+
return e;
|
|
89
|
+
}, ee = (e, t, n) => {
|
|
90
|
+
if (!t) return e;
|
|
91
|
+
let { position: r, deletedLength: i, insertedText: a } = t, o = a.length, s = [...e], c = R(s, r);
|
|
92
|
+
if (g(c) ? s = D(s, r, g, _) : N(c) ? s = D(s, r, N, P) : d(c) && (s = D(s, r, d, f)), i > 0 && s.splice(r, i), o > 0) {
|
|
93
|
+
let e = 0;
|
|
94
|
+
n.bold && (e = y(e, !0)), n.italic && (e = x(e, !0)), n.underline && (e = T(e, !0)), n.strike && (e = C(e, !0));
|
|
95
|
+
let t = Array(o).fill(e);
|
|
96
|
+
s.splice(r, 0, ...t);
|
|
97
|
+
}
|
|
98
|
+
return s;
|
|
99
|
+
}, O = (e) => /\s/.test(e) || /[\u2000-\u200B\u2028\u2029\u3000]/.test(e), k = (e, t, n, r) => {
|
|
100
|
+
if (t <= 0 || t > e.length) return null;
|
|
101
|
+
let i = "", a = t - 1, o = t, s = (e) => O(e) || n.includes(e);
|
|
102
|
+
for (let t = a; t >= 0; t--) {
|
|
103
|
+
if (s(e[t])) {
|
|
104
|
+
a = t + 1;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
t === 0 && (a = 0), i = e[t] + i;
|
|
108
|
+
}
|
|
109
|
+
for (let t = o; t < e.length; t++) {
|
|
110
|
+
if (s(e[t])) {
|
|
111
|
+
o = t;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
if (r && e[t] === r) {
|
|
115
|
+
o = t;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
t === e.length - 1 && (o = e.length), i += e[t];
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
search: e.slice(a, o),
|
|
122
|
+
startIndex: a,
|
|
123
|
+
endIndex: o
|
|
124
|
+
};
|
|
125
|
+
}, A = ".,!?;()[]{}\"'<>@", j = /^#[a-zA-Z0-9-]+$/, M = (e, t) => {
|
|
126
|
+
let n = k(e, t, A, "#");
|
|
127
|
+
return n?.search.match(j) ? n : null;
|
|
128
|
+
}, N = (e) => (e & 64) != 0, P = (e, t) => t ? e | 64 : e & -65, F = (e, t) => e.find((e) => e.startIndex <= t && e.endIndex > t), I = (e, t, n) => {
|
|
129
|
+
let r = [], i = 0;
|
|
130
|
+
for (; i < t.length;) {
|
|
131
|
+
let a = R(t, i);
|
|
132
|
+
if (a === 0 || a === 1) {
|
|
133
|
+
i++;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
let o = i, s = i;
|
|
137
|
+
for (; s + 1 < t.length && R(t, s + 1) === a;) s++;
|
|
138
|
+
let c = L(a, n), l = te(a), d = {
|
|
139
|
+
type: c,
|
|
140
|
+
startIndex: o,
|
|
141
|
+
endIndex: s + 1,
|
|
142
|
+
marks: l,
|
|
143
|
+
username: c === "mention" ? h(e, s)?.search.replace("@", "") : void 0,
|
|
144
|
+
interest: c === "interest" ? M(e, s)?.search.replace("#", "").toLowerCase() : void 0,
|
|
145
|
+
href: c === "link" ? u(e, s)?.search : void 0
|
|
146
|
+
};
|
|
147
|
+
r.push(d), i = s + 1;
|
|
148
|
+
}
|
|
149
|
+
return r;
|
|
150
|
+
}, L = (e, t) => e & 32 && t.mentions ? "mention" : e & 64 && t.interests ? "interest" : e & 128 && t.links ? "link" : (e & 30, "segment"), te = (e) => {
|
|
151
|
+
let t = [];
|
|
152
|
+
return e & 2 && t.push("bold"), e & 4 && t.push("italic"), e & 8 && t.push("underline"), e & 16 && t.push("strike"), t;
|
|
153
|
+
}, R = (e, t) => {
|
|
154
|
+
let n = e[t];
|
|
155
|
+
return typeof n == "number" ? n : 0;
|
|
156
|
+
}, z = (e, t, n) => {
|
|
157
|
+
let r = R(e, t);
|
|
158
|
+
switch (n) {
|
|
159
|
+
case "mention": return _(r, !0);
|
|
160
|
+
case "interest": return P(r, !0);
|
|
161
|
+
case "link": return f(r, !0);
|
|
162
|
+
}
|
|
163
|
+
return r;
|
|
164
|
+
}, B = (e, t, n, r) => {
|
|
165
|
+
let i = R(e, t);
|
|
166
|
+
switch (n) {
|
|
167
|
+
case "bold":
|
|
168
|
+
i = y(i, r);
|
|
169
|
+
break;
|
|
170
|
+
case "italic":
|
|
171
|
+
i = x(i, r);
|
|
172
|
+
break;
|
|
173
|
+
case "underline":
|
|
174
|
+
i = T(i, r);
|
|
175
|
+
break;
|
|
176
|
+
case "strike":
|
|
177
|
+
i = C(i, r);
|
|
178
|
+
break;
|
|
179
|
+
default: return e;
|
|
180
|
+
}
|
|
181
|
+
return e[t] = i, e;
|
|
182
|
+
}, V = (e, t, n) => {
|
|
183
|
+
let r = R(e, t);
|
|
184
|
+
switch (n) {
|
|
185
|
+
case "bold": return v(r);
|
|
186
|
+
case "italic": return b(r);
|
|
187
|
+
case "underline": return w(r);
|
|
188
|
+
case "strike": return S(r);
|
|
189
|
+
default: throw Error(`Invalid mark type: ${n}`);
|
|
190
|
+
}
|
|
191
|
+
}, H = (e, t, n, r) => {
|
|
192
|
+
for (let i = e; i < t; i++) if (!V(r, i, n)) return !1;
|
|
193
|
+
return !0;
|
|
194
|
+
}, ne = (e) => g(e) || N(e) || d(e), re = (e, t, n, r) => {
|
|
195
|
+
let i = [...e];
|
|
196
|
+
for (; ne(R(e, t - 1)) && t > 0;) t--;
|
|
197
|
+
for (; ne(R(e, n)) && n < e.length;) n++;
|
|
198
|
+
let a = !0;
|
|
199
|
+
H(t, n, r, i) && (a = !1);
|
|
200
|
+
for (let e = t; e < n; e++) i = B(i, e, r, a);
|
|
201
|
+
return i;
|
|
202
|
+
}, U = (e, t) => {
|
|
203
|
+
let n = Array(e.length).fill(0);
|
|
204
|
+
for (let r = 0; r < e.length; r++) {
|
|
205
|
+
let e = 0, i = F(t, r);
|
|
206
|
+
if (i) {
|
|
207
|
+
i.type === "mention" ? e = _(e, !0) : i.type === "interest" ? e = P(e, !0) : i.type === "link" && (e = f(e, !0));
|
|
208
|
+
for (let t of i.marks) t === "bold" ? e = y(e, !0) : t === "italic" ? e = x(e, !0) : t === "underline" ? e = T(e, !0) : t === "strike" && (e = C(e, !0));
|
|
209
|
+
}
|
|
210
|
+
n[r] = e;
|
|
211
|
+
}
|
|
212
|
+
return n;
|
|
213
|
+
}, ie = /* @__PURE__ */ t(((e) => {
|
|
214
|
+
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
215
|
+
function r(e, n, r) {
|
|
216
|
+
var i = null;
|
|
217
|
+
if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
|
|
218
|
+
else r = n;
|
|
219
|
+
return n = r.ref, {
|
|
220
|
+
$$typeof: t,
|
|
221
|
+
type: e,
|
|
222
|
+
key: i,
|
|
223
|
+
ref: n === void 0 ? null : n,
|
|
224
|
+
props: r
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
e.Fragment = n, e.jsx = r, e.jsxs = r;
|
|
228
|
+
})), W = /* @__PURE__ */ t(((e) => {
|
|
229
|
+
process.env.NODE_ENV !== "production" && (function() {
|
|
230
|
+
function t(e) {
|
|
231
|
+
if (e == null) return null;
|
|
232
|
+
if (typeof e == "function") return e.$$typeof === O ? null : e.displayName || e.name || null;
|
|
233
|
+
if (typeof e == "string") return e;
|
|
234
|
+
switch (e) {
|
|
235
|
+
case v: return "Fragment";
|
|
236
|
+
case b: return "Profiler";
|
|
237
|
+
case y: return "StrictMode";
|
|
238
|
+
case w: return "Suspense";
|
|
239
|
+
case T: return "SuspenseList";
|
|
240
|
+
case ee: return "Activity";
|
|
241
|
+
}
|
|
242
|
+
if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
|
|
243
|
+
case _: return "Portal";
|
|
244
|
+
case S: return e.displayName || "Context";
|
|
245
|
+
case x: return (e._context.displayName || "Context") + ".Consumer";
|
|
246
|
+
case C:
|
|
247
|
+
var n = e.render;
|
|
248
|
+
return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
|
|
249
|
+
case E: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
|
|
250
|
+
case D:
|
|
251
|
+
n = e._payload, e = e._init;
|
|
252
|
+
try {
|
|
253
|
+
return t(e(n));
|
|
254
|
+
} catch {}
|
|
255
|
+
}
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
function r(e) {
|
|
259
|
+
return "" + e;
|
|
260
|
+
}
|
|
261
|
+
function i(e) {
|
|
262
|
+
try {
|
|
263
|
+
r(e);
|
|
264
|
+
var t = !1;
|
|
265
|
+
} catch {
|
|
266
|
+
t = !0;
|
|
267
|
+
}
|
|
268
|
+
if (t) {
|
|
269
|
+
t = console;
|
|
270
|
+
var n = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
271
|
+
return n.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), r(e);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function a(e) {
|
|
275
|
+
if (e === v) return "<>";
|
|
276
|
+
if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
|
|
277
|
+
try {
|
|
278
|
+
var n = t(e);
|
|
279
|
+
return n ? "<" + n + ">" : "<...>";
|
|
280
|
+
} catch {
|
|
281
|
+
return "<...>";
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function o() {
|
|
285
|
+
var e = k.A;
|
|
286
|
+
return e === null ? null : e.getOwner();
|
|
287
|
+
}
|
|
288
|
+
function s() {
|
|
289
|
+
return Error("react-stack-top-frame");
|
|
290
|
+
}
|
|
291
|
+
function c(e) {
|
|
292
|
+
if (A.call(e, "key")) {
|
|
293
|
+
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
294
|
+
if (t && t.isReactWarning) return !1;
|
|
295
|
+
}
|
|
296
|
+
return e.key !== void 0;
|
|
297
|
+
}
|
|
298
|
+
function l(e, t) {
|
|
299
|
+
function n() {
|
|
300
|
+
N || (N = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
|
|
301
|
+
}
|
|
302
|
+
n.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
303
|
+
get: n,
|
|
304
|
+
configurable: !0
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
function u() {
|
|
308
|
+
var e = t(this.type);
|
|
309
|
+
return P[e] || (P[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
|
|
310
|
+
}
|
|
311
|
+
function d(e, t, n, r, i, a) {
|
|
312
|
+
var o = n.ref;
|
|
313
|
+
return e = {
|
|
314
|
+
$$typeof: g,
|
|
315
|
+
type: e,
|
|
316
|
+
key: t,
|
|
317
|
+
props: n,
|
|
318
|
+
_owner: r
|
|
319
|
+
}, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
|
|
320
|
+
enumerable: !1,
|
|
321
|
+
value: null
|
|
322
|
+
}) : Object.defineProperty(e, "ref", {
|
|
323
|
+
enumerable: !1,
|
|
324
|
+
get: u
|
|
325
|
+
}), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
326
|
+
configurable: !1,
|
|
327
|
+
enumerable: !1,
|
|
328
|
+
writable: !0,
|
|
329
|
+
value: 0
|
|
330
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
331
|
+
configurable: !1,
|
|
332
|
+
enumerable: !1,
|
|
333
|
+
writable: !0,
|
|
334
|
+
value: null
|
|
335
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
336
|
+
configurable: !1,
|
|
337
|
+
enumerable: !1,
|
|
338
|
+
writable: !0,
|
|
339
|
+
value: i
|
|
340
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
341
|
+
configurable: !1,
|
|
342
|
+
enumerable: !1,
|
|
343
|
+
writable: !0,
|
|
344
|
+
value: a
|
|
345
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
346
|
+
}
|
|
347
|
+
function f(e, n, r, a, s, u) {
|
|
348
|
+
var f = n.children;
|
|
349
|
+
if (f !== void 0) if (a) if (j(f)) {
|
|
350
|
+
for (a = 0; a < f.length; a++) p(f[a]);
|
|
351
|
+
Object.freeze && Object.freeze(f);
|
|
352
|
+
} else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
353
|
+
else p(f);
|
|
354
|
+
if (A.call(n, "key")) {
|
|
355
|
+
f = t(e);
|
|
356
|
+
var m = Object.keys(n).filter(function(e) {
|
|
357
|
+
return e !== "key";
|
|
358
|
+
});
|
|
359
|
+
a = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", L[f + a] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", a, f, m, f), L[f + a] = !0);
|
|
360
|
+
}
|
|
361
|
+
if (f = null, r !== void 0 && (i(r), f = "" + r), c(n) && (i(n.key), f = "" + n.key), "key" in n) for (var h in r = {}, n) h !== "key" && (r[h] = n[h]);
|
|
362
|
+
else r = n;
|
|
363
|
+
return f && l(r, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), d(e, f, r, o(), s, u);
|
|
364
|
+
}
|
|
365
|
+
function p(e) {
|
|
366
|
+
m(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? m(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
367
|
+
}
|
|
368
|
+
function m(e) {
|
|
369
|
+
return typeof e == "object" && !!e && e.$$typeof === g;
|
|
370
|
+
}
|
|
371
|
+
var h = n("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), ee = Symbol.for("react.activity"), O = Symbol.for("react.client.reference"), k = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, A = Object.prototype.hasOwnProperty, j = Array.isArray, M = console.createTask ? console.createTask : function() {
|
|
372
|
+
return null;
|
|
373
|
+
};
|
|
374
|
+
h = { react_stack_bottom_frame: function(e) {
|
|
375
|
+
return e();
|
|
376
|
+
} };
|
|
377
|
+
var N, P = {}, F = h.react_stack_bottom_frame.bind(h, s)(), I = M(a(s)), L = {};
|
|
378
|
+
e.Fragment = v, e.jsx = function(e, t, n) {
|
|
379
|
+
var r = 1e4 > k.recentlyCreatedOwnerStacks++;
|
|
380
|
+
return f(e, t, n, !1, r ? Error("react-stack-top-frame") : F, r ? M(a(e)) : I);
|
|
381
|
+
}, e.jsxs = function(e, t, n) {
|
|
382
|
+
var r = 1e4 > k.recentlyCreatedOwnerStacks++;
|
|
383
|
+
return f(e, t, n, !0, r ? Error("react-stack-top-frame") : F, r ? M(a(e)) : I);
|
|
384
|
+
};
|
|
385
|
+
})();
|
|
386
|
+
})), G = (/* @__PURE__ */ t(((e, t) => {
|
|
387
|
+
process.env.NODE_ENV === "production" ? t.exports = ie() : t.exports = W();
|
|
388
|
+
})))(), ae = {}, oe = {}, K = ({ ref: t, initialPlainText: n = "", initialEntities: a = [], onMentionSearch: c, onMarkStateChange: l, onLinkCreated: f, onInterestCreated: p, onGetState: m, options: _ = ae, entityStyles: y = oe, placeholder: x = "", debug: C = !1, ...T }) => {
|
|
389
|
+
let D = e.useRef(null), [O, k] = e.useState(n), [A, j] = e.useState({
|
|
390
|
+
bold: !1,
|
|
391
|
+
italic: !1,
|
|
392
|
+
underline: !1,
|
|
393
|
+
strike: !1
|
|
394
|
+
}), [P, F] = e.useState(null), [L, te] = e.useState({
|
|
395
|
+
start: 0,
|
|
396
|
+
end: 0
|
|
397
|
+
}), [B, V] = e.useState(!1), [H, ne] = e.useState(!1), [ie, W] = e.useState(!1), [K, q] = e.useState(U(n, a)), J = e.useMemo(() => I(O, K, _), [
|
|
398
|
+
O,
|
|
399
|
+
K,
|
|
400
|
+
_
|
|
401
|
+
]), Y = e.useRef(c), se = e.useRef(l), ce = e.useRef(B), X = e.useRef(!1), Z = e.useRef({
|
|
402
|
+
start: 0,
|
|
403
|
+
end: 0
|
|
404
|
+
}), Q = e.useRef(null), le = e.useRef(!1), $ = e.useRef(null), ue = e.useRef(!1), de = e.useRef(null), fe = e.useRef(null), pe = e.useRef(f), me = e.useRef(p), he = e.useRef(m);
|
|
405
|
+
e.useEffect(() => {
|
|
406
|
+
Y.current = c;
|
|
407
|
+
}, [c]), e.useEffect(() => {
|
|
408
|
+
se.current = l;
|
|
409
|
+
}, [l]), e.useEffect(() => {
|
|
410
|
+
pe.current = f;
|
|
411
|
+
}, [f]), e.useEffect(() => {
|
|
412
|
+
me.current = p;
|
|
413
|
+
}, [p]), e.useEffect(() => {
|
|
414
|
+
he.current = m;
|
|
415
|
+
}, [m]), e.useEffect(() => {
|
|
416
|
+
ce.current = B;
|
|
417
|
+
}, [B]), e.useEffect(() => {
|
|
418
|
+
if ($.current && clearTimeout($.current), P === null) {
|
|
419
|
+
Y.current?.(null);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
return $.current = setTimeout(() => {
|
|
423
|
+
Y.current?.(P);
|
|
424
|
+
}, 300), () => {
|
|
425
|
+
$.current && clearTimeout($.current);
|
|
426
|
+
};
|
|
427
|
+
}, [P]), e.useEffect(() => {
|
|
428
|
+
se.current?.(A);
|
|
429
|
+
}, [A]);
|
|
430
|
+
let ge = e.useCallback((e) => {
|
|
431
|
+
if (V(!0), !D.current) return;
|
|
432
|
+
let { start: t, end: n } = Z.current;
|
|
433
|
+
t !== n && q(re(K, t, n, e)), j((t) => {
|
|
434
|
+
let n = { ...t };
|
|
435
|
+
return e === "bold" ? n.bold = !t.bold : e === "italic" ? n.italic = !t.italic : e === "underline" ? n.underline = !t.underline : e === "strike" && (n.strike = !t.strike), n;
|
|
436
|
+
});
|
|
437
|
+
}, [K]);
|
|
438
|
+
e.useImperativeHandle(t, () => ({
|
|
439
|
+
selectEntity: (e, t, n, r) => {
|
|
440
|
+
if (!D.current) return;
|
|
441
|
+
let i = [...K];
|
|
442
|
+
e === "mention" ? r = "@" + r : e === "interest" ? r = "#" + r : e === "link" && (r = "" + r);
|
|
443
|
+
let a = O.slice(0, t) + r + O.slice(n), o = E(O, a);
|
|
444
|
+
i = o ? ee(K, o, A) : U(a, J);
|
|
445
|
+
for (let n = t; n < t + r.length; n++) i[n] = z(i, n, e);
|
|
446
|
+
let s = t + r.length;
|
|
447
|
+
Z.current = {
|
|
448
|
+
start: s,
|
|
449
|
+
end: s
|
|
450
|
+
}, ue.current = !0, k(a), q(i), F(null);
|
|
451
|
+
},
|
|
452
|
+
toggleMark: ge,
|
|
453
|
+
clear: () => {
|
|
454
|
+
k(""), q([]);
|
|
455
|
+
},
|
|
456
|
+
reset: () => {
|
|
457
|
+
k(n), q(U(n, a)), F(null);
|
|
458
|
+
},
|
|
459
|
+
focus: () => {
|
|
460
|
+
D.current?.focus();
|
|
461
|
+
},
|
|
462
|
+
getState: () => (he.current && he.current({
|
|
463
|
+
plainText: O,
|
|
464
|
+
entities: J,
|
|
465
|
+
markState: A
|
|
466
|
+
}), {
|
|
467
|
+
plainText: O,
|
|
468
|
+
entities: J,
|
|
469
|
+
markState: A
|
|
470
|
+
})
|
|
471
|
+
}), [
|
|
472
|
+
K,
|
|
473
|
+
O,
|
|
474
|
+
J,
|
|
475
|
+
A,
|
|
476
|
+
ge
|
|
477
|
+
]), e.useEffect(() => {
|
|
478
|
+
if (D.current && !H) {
|
|
479
|
+
D.current.textContent = O;
|
|
480
|
+
let e = o(O, J, y);
|
|
481
|
+
D.current.innerHTML = e, ne(!0);
|
|
482
|
+
}
|
|
483
|
+
}, []), e.useLayoutEffect(() => {
|
|
484
|
+
if (!D.current || !H) return;
|
|
485
|
+
let e = ue.current ? Z.current : r(D.current) ?? Z.current;
|
|
486
|
+
ue.current = !1;
|
|
487
|
+
let t = o(O, J, y);
|
|
488
|
+
le.current = !0, D.current.innerHTML = t, i(D.current, e), queueMicrotask(() => {
|
|
489
|
+
le.current = !1;
|
|
490
|
+
});
|
|
491
|
+
}, [
|
|
492
|
+
J,
|
|
493
|
+
y,
|
|
494
|
+
H
|
|
495
|
+
]), e.useEffect(() => {
|
|
496
|
+
let { start: e, end: t } = L, n = null;
|
|
497
|
+
if (_.mentions && !g(R(K, e - 1))) {
|
|
498
|
+
let t = h(O, e);
|
|
499
|
+
t && (n = {
|
|
500
|
+
type: "mention",
|
|
501
|
+
search: t.search.replace("@", ""),
|
|
502
|
+
startIndex: t.startIndex,
|
|
503
|
+
endIndex: t.endIndex
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
if (n ? (!P || n.startIndex !== P.startIndex || n.endIndex !== P.endIndex || n.search !== P.search) && F(n) : P && F(null), B) return;
|
|
507
|
+
let r = !0, i = !0, a = !0, o = !0;
|
|
508
|
+
if (e === t) if (e > 0) {
|
|
509
|
+
let t = R(K, e - 1);
|
|
510
|
+
r = v(t), i = b(t), a = w(t), o = S(t);
|
|
511
|
+
} else {
|
|
512
|
+
let t = R(K, e);
|
|
513
|
+
r = v(t), i = b(t), a = w(t), o = S(t);
|
|
514
|
+
}
|
|
515
|
+
else for (let n = e; n < t; n++) {
|
|
516
|
+
let e = R(K, n);
|
|
517
|
+
r = v(e) ? r : !1, i = b(e) ? i : !1, a = w(e) ? a : !1, o = S(e) ? o : !1;
|
|
518
|
+
}
|
|
519
|
+
j({
|
|
520
|
+
bold: r,
|
|
521
|
+
italic: i,
|
|
522
|
+
underline: a,
|
|
523
|
+
strike: o
|
|
524
|
+
});
|
|
525
|
+
}, [
|
|
526
|
+
L,
|
|
527
|
+
K,
|
|
528
|
+
O,
|
|
529
|
+
B
|
|
530
|
+
]);
|
|
531
|
+
let _e = (e) => {
|
|
532
|
+
if (!D.current) return;
|
|
533
|
+
let t = e.currentTarget;
|
|
534
|
+
if (t.textContent?.length === 0) {
|
|
535
|
+
k(""), q([]), B && V(!1);
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
let n = t.innerText || "", r = E(O, n);
|
|
539
|
+
if (r) {
|
|
540
|
+
let e = ee(K, r, A);
|
|
541
|
+
if (r.deletedLength === 0 && r.insertedText === " " && r.position > 0) {
|
|
542
|
+
let t = r.position;
|
|
543
|
+
if (_.links && !d(R(e, t - 1))) {
|
|
544
|
+
let r = u(n, t);
|
|
545
|
+
if (r && r.endIndex === t) {
|
|
546
|
+
let t = `${r.startIndex}:${r.endIndex}:${r.search}`;
|
|
547
|
+
if (de.current !== t) {
|
|
548
|
+
for (let t = r.startIndex; t < r.endIndex; t++) e[t] = z(e, t, "link");
|
|
549
|
+
if (de.current = t, pe.current) {
|
|
550
|
+
let e = {
|
|
551
|
+
type: "link",
|
|
552
|
+
startIndex: r.startIndex,
|
|
553
|
+
endIndex: r.endIndex,
|
|
554
|
+
marks: [],
|
|
555
|
+
href: r.search
|
|
556
|
+
};
|
|
557
|
+
pe.current(e);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
if (_.interests && !N(R(e, t - 1))) {
|
|
563
|
+
let r = M(n, t);
|
|
564
|
+
if (r && r.endIndex === t) {
|
|
565
|
+
let t = `${r.startIndex}:${r.endIndex}:${r.search}`;
|
|
566
|
+
if (fe.current !== t) {
|
|
567
|
+
for (let t = r.startIndex; t < r.endIndex; t++) e[t] = z(e, t, "interest");
|
|
568
|
+
if (fe.current = t, me.current) {
|
|
569
|
+
let e = {
|
|
570
|
+
type: "interest",
|
|
571
|
+
startIndex: r.startIndex,
|
|
572
|
+
endIndex: r.endIndex,
|
|
573
|
+
marks: [],
|
|
574
|
+
interest: r.search.replace("#", "").toLowerCase()
|
|
575
|
+
};
|
|
576
|
+
me.current(e);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
q(e), X.current = !0, setTimeout(() => {
|
|
583
|
+
X.current = !1;
|
|
584
|
+
}, 50);
|
|
585
|
+
} else B && V(!1);
|
|
586
|
+
k(n);
|
|
587
|
+
}, ve = (e) => {
|
|
588
|
+
D.current && s(e, ge);
|
|
589
|
+
}, ye = () => {
|
|
590
|
+
W(!0);
|
|
591
|
+
}, be = () => {
|
|
592
|
+
W(!1);
|
|
593
|
+
};
|
|
594
|
+
e.useEffect(() => {
|
|
595
|
+
let e = () => {
|
|
596
|
+
if (le.current) return;
|
|
597
|
+
let e = r(D.current) ?? {
|
|
598
|
+
start: 0,
|
|
599
|
+
end: 0
|
|
600
|
+
}, t = Z.current;
|
|
601
|
+
(e.start !== t.start || e.end !== t.end) && (Z.current = e, ce.current && !X.current && V(!1), Q.current && clearTimeout(Q.current), Q.current = setTimeout(() => {
|
|
602
|
+
te(e);
|
|
603
|
+
}, 500));
|
|
604
|
+
};
|
|
605
|
+
return document.addEventListener("selectionchange", e), () => {
|
|
606
|
+
document.removeEventListener("selectionchange", e), Q.current && clearTimeout(Q.current);
|
|
607
|
+
};
|
|
608
|
+
}, []);
|
|
609
|
+
let xe = O.length === 0 && x && !ie;
|
|
610
|
+
return /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [/* @__PURE__ */ (0, G.jsxs)("div", {
|
|
611
|
+
style: { position: "relative" },
|
|
612
|
+
children: [/* @__PURE__ */ (0, G.jsx)("div", {
|
|
613
|
+
ref: D,
|
|
614
|
+
style: {
|
|
615
|
+
...T.style,
|
|
616
|
+
position: "relative",
|
|
617
|
+
zIndex: 2
|
|
618
|
+
},
|
|
619
|
+
className: T.className,
|
|
620
|
+
contentEditable: !0,
|
|
621
|
+
onKeyDown: ve,
|
|
622
|
+
onInput: _e,
|
|
623
|
+
onFocus: ye,
|
|
624
|
+
onBlur: be,
|
|
625
|
+
role: "textbox",
|
|
626
|
+
"aria-multiline": "true",
|
|
627
|
+
autoCapitalize: "off",
|
|
628
|
+
autoFocus: !1
|
|
629
|
+
}), xe && /* @__PURE__ */ (0, G.jsx)("div", {
|
|
630
|
+
style: {
|
|
631
|
+
...T.style,
|
|
632
|
+
position: "absolute",
|
|
633
|
+
top: 0,
|
|
634
|
+
left: 0,
|
|
635
|
+
right: 0,
|
|
636
|
+
bottom: 0,
|
|
637
|
+
color: "#9ca3af",
|
|
638
|
+
pointerEvents: "none"
|
|
639
|
+
},
|
|
640
|
+
"aria-hidden": "true",
|
|
641
|
+
children: /* @__PURE__ */ (0, G.jsx)("p", {
|
|
642
|
+
style: { margin: 0 },
|
|
643
|
+
children: x
|
|
644
|
+
})
|
|
645
|
+
})]
|
|
646
|
+
}), C && /* @__PURE__ */ (0, G.jsx)("div", {
|
|
647
|
+
style: {},
|
|
648
|
+
children: /* @__PURE__ */ (0, G.jsx)("pre", { children: JSON.stringify(K) })
|
|
649
|
+
})] });
|
|
796
650
|
};
|
|
651
|
+
//#endregion
|
|
652
|
+
export { K as Editor };
|