bridgerte 0.9.21 → 0.9.22
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/dom.cjs +1 -1
- package/dist/dom.js +2 -2
- package/dist/{index-BJMFpGLi.js → index-BiehJaHJ.js} +1007 -1001
- package/dist/index-BiehJaHJ.js.map +1 -0
- package/dist/{index-B1raum97.js → index-DARGQA9p.js} +2 -2
- package/dist/{index-B1raum97.js.map → index-DARGQA9p.js.map} +1 -1
- package/dist/index-DL8eNafR.cjs +4 -0
- package/dist/index-DL8eNafR.cjs.map +1 -0
- package/dist/{index-D1a91Ek0.cjs → index-McnGKzmi.cjs} +2 -2
- package/dist/{index-D1a91Ek0.cjs.map → index-McnGKzmi.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/style.css +1 -1
- package/dist/webview.cjs +1 -1
- package/dist/webview.js +1 -1
- package/package.json +1 -1
- package/dist/index-BJMFpGLi.js.map +0 -1
- package/dist/index-BnlTw-Yj.cjs +0 -4
- package/dist/index-BnlTw-Yj.cjs.map +0 -1
|
@@ -3,7 +3,7 @@ var cr = (e, t, n) => t in e ? lr(e, t, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var $e = (e, t, n) => cr(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { BRIDGE_CONTENT_CHANGE_DEBOUNCE_MS as dr, isBridgeMessage as ur, BRIDGE_HEIGHT_CHANGE_THROTTLE_MS as mr, defaultBridgeEventTiming as gr } from "./bridge.js";
|
|
5
5
|
import { B as Ae, b as tn, a as nn } from "./index-CuNKUHed.js";
|
|
6
|
-
import { DecoratorNode as rn, $applyNodeReplacement as rt, $getRoot as F, $isElementNode as ie, $createParagraphNode as z, KEY_BACKSPACE_COMMAND as on, COMMAND_PRIORITY_HIGH as G, KEY_DELETE_COMMAND as an, DELETE_CHARACTER_COMMAND as sn, $getSelection as D, $isNodeSelection as hr, $isRangeSelection as O, TextNode as Y, $isParagraphNode as pr, $insertNodes as W, FORMAT_ELEMENT_COMMAND as fr, $createTextNode as Be, FORMAT_TEXT_COMMAND as br, REDO_COMMAND as yr, UNDO_COMMAND as vr, OUTDENT_CONTENT_COMMAND as wr, INDENT_CONTENT_COMMAND as Cr, SKIP_SCROLL_INTO_VIEW_TAG as _r, $getNodeByKey as he, $setSelection as kr, SELECTION_CHANGE_COMMAND as ln, COMMAND_PRIORITY_LOW as j, KEY_ESCAPE_COMMAND as cn, KEY_ARROW_DOWN_COMMAND as
|
|
6
|
+
import { DecoratorNode as rn, $applyNodeReplacement as rt, $getRoot as F, $isElementNode as ie, $createParagraphNode as z, KEY_BACKSPACE_COMMAND as on, COMMAND_PRIORITY_HIGH as G, KEY_DELETE_COMMAND as an, DELETE_CHARACTER_COMMAND as sn, $getSelection as D, $isNodeSelection as hr, $isRangeSelection as O, TextNode as Y, $isParagraphNode as pr, $insertNodes as W, FORMAT_ELEMENT_COMMAND as fr, $createTextNode as Be, FORMAT_TEXT_COMMAND as br, REDO_COMMAND as yr, UNDO_COMMAND as vr, OUTDENT_CONTENT_COMMAND as wr, INDENT_CONTENT_COMMAND as Cr, SKIP_SCROLL_INTO_VIEW_TAG as _r, $getNodeByKey as he, $setSelection as kr, SELECTION_CHANGE_COMMAND as ln, COMMAND_PRIORITY_LOW as j, KEY_ESCAPE_COMMAND as cn, KEY_ARROW_DOWN_COMMAND as xr, KEY_ARROW_UP_COMMAND as Er, KEY_ENTER_COMMAND as Mr, mergeRegister as dn, INSERT_PARAGRAPH_COMMAND as Tr, INSERT_LINE_BREAK_COMMAND as Lr, $isLineBreakNode as un, $getNearestNodeFromDOMNode as Sr, CAN_UNDO_COMMAND as Nr, CAN_REDO_COMMAND as Pr, createEditor as Ir, CLEAR_HISTORY_COMMAND as Rr } from "lexical";
|
|
7
7
|
import { $isHeadingNode as Ar, $isQuoteNode as mn, $createQuoteNode as Br, $createHeadingNode as Dr, registerRichText as Hr, HeadingNode as Or, QuoteNode as $r } from "@lexical/rich-text";
|
|
8
8
|
import { $isCodeNode as X, $createCodeNode as Fr, $isCodeHighlightNode as zr, $createCodeHighlightNode as Vr, CodeNode as gn, CodeHighlightNode as Wr } from "@lexical/code";
|
|
9
9
|
import { $isListNode as Ur, ListNode as hn, INSERT_CHECK_LIST_COMMAND as jr, INSERT_UNORDERED_LIST_COMMAND as Kr, INSERT_ORDERED_LIST_COMMAND as qr, $isListItemNode as Gr, registerList as Xr, registerCheckList as Yr, ListItemNode as Jr } from "@lexical/list";
|
|
@@ -13,11 +13,11 @@ import { registerHistory as bo, createEmptyHistoryState as yo } from "@lexical/h
|
|
|
13
13
|
import { $generateNodesFromDOM as fn, $generateHtmlFromNodes as vo } from "@lexical/html";
|
|
14
14
|
import { $getSelectionStyleValueForProperty as wo, $setBlocksType as Fe, $patchStyleText as yt, $trimTextContentFromAnchor as vt } from "@lexical/selection";
|
|
15
15
|
import { $getNearestNodeOfType as Co, $findMatchingParent as _o, $insertNodeToNearestRoot as bn } from "@lexical/utils";
|
|
16
|
-
import { codeBlockLanguagePanel as Xe, isCommandStateForCommand as ko, resolveToolbarMenu as ot, defaultMenuSchema as De, tableHeaderMenuItems as
|
|
16
|
+
import { codeBlockLanguagePanel as Xe, isCommandStateForCommand as ko, resolveToolbarMenu as ot, defaultMenuSchema as De, tableHeaderMenuItems as xo } from "./native-spec.js";
|
|
17
17
|
import { r as yn } from "./index-sbZNOcCB.js";
|
|
18
|
-
import { computePosition as vn, platform as wn, offset as Cn, flip as _n, shift as kn, autoUpdate as
|
|
19
|
-
import { normalizeCodeLanguage as Mo, getCodeLanguageOptions as To, ShikiTokenizer as wt, isCodeLanguageLoaded as
|
|
20
|
-
const Ct = "bridgerte-media",
|
|
18
|
+
import { computePosition as vn, platform as wn, offset as Cn, flip as _n, shift as kn, autoUpdate as Eo } from "@floating-ui/dom";
|
|
19
|
+
import { normalizeCodeLanguage as Mo, getCodeLanguageOptions as To, ShikiTokenizer as wt, isCodeLanguageLoaded as xn, loadCodeLanguage as Lo, loadCodeTheme as So, registerCodeHighlighting as No } from "@lexical/code-shiki";
|
|
20
|
+
const Ct = "bridgerte-media", En = "Loading", _t = (e, t) => `${e}:${t}`, oe = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? Math.floor(e) : void 0, kt = (e) => typeof e == "number" && Number.isFinite(e) ? Math.min(Math.max(e, 0), 100) : void 0, Po = (e) => e === 20 || e === 50 || e === 100, xt = (e) => Po(e) ? e : void 0, Et = (e) => e === "center" || e === "right" ? e : void 0, Io = (e) => e.status === "error" ? e.errorMessage ?? "媒体加载失败" : En, Ro = (e, t) => !t || e.status === void 0 || e.status === "success", ze = (e, t, n) => {
|
|
21
21
|
n && e.setAttribute(t, n);
|
|
22
22
|
}, Mt = (e, t, n) => {
|
|
23
23
|
n !== void 0 && e.setAttribute(t, String(n));
|
|
@@ -33,8 +33,8 @@ class le extends rn {
|
|
|
33
33
|
height: oe(n.height),
|
|
34
34
|
duration: oe(n.duration),
|
|
35
35
|
progress: kt(n.progress),
|
|
36
|
-
displayWidthPercent:
|
|
37
|
-
align:
|
|
36
|
+
displayWidthPercent: xt(n.displayWidthPercent),
|
|
37
|
+
align: Et(n.align)
|
|
38
38
|
}, this.__payload.displayWidthPercent === void 0 && delete this.__payload.displayWidthPercent, this.__payload.align === void 0 && delete this.__payload.align;
|
|
39
39
|
}
|
|
40
40
|
static getType() {
|
|
@@ -112,8 +112,8 @@ class le extends rn {
|
|
|
112
112
|
displayWidthPercent: Object.prototype.hasOwnProperty.call(
|
|
113
113
|
n,
|
|
114
114
|
"displayWidthPercent"
|
|
115
|
-
) ?
|
|
116
|
-
align: Object.prototype.hasOwnProperty.call(n, "align") ?
|
|
115
|
+
) ? xt(n.displayWidthPercent) : r.__payload.displayWidthPercent,
|
|
116
|
+
align: Object.prototype.hasOwnProperty.call(n, "align") ? Et(n.align) : r.__payload.align
|
|
117
117
|
}, r.__payload.displayWidthPercent === void 0 && delete r.__payload.displayWidthPercent, r.__payload.align === void 0 && delete r.__payload.align;
|
|
118
118
|
}
|
|
119
119
|
createMediaElement(n) {
|
|
@@ -133,14 +133,14 @@ class le extends rn {
|
|
|
133
133
|
), a.addEventListener("error", () => {
|
|
134
134
|
o.dataset.loadState = "error";
|
|
135
135
|
}, { once: !0 }));
|
|
136
|
-
const
|
|
137
|
-
if (r.mediaType === "image" ? (
|
|
138
|
-
const d = document.createElement("div"),
|
|
139
|
-
d.className = "bridgerte__media-placeholder", d.setAttribute("aria-hidden", "true"),
|
|
136
|
+
const i = Ro(r, n);
|
|
137
|
+
if (r.mediaType === "image" ? (i && a.setAttribute("src", r.url), a.setAttribute("loading", "lazy"), ze(a, "alt", r.alt ?? r.title)) : (i && a.setAttribute("src", r.url), a.setAttribute("controls", "true"), a.setAttribute("preload", "metadata"), ze(a, "poster", r.poster)), ze(a, "title", r.title), Mt(a, "width", r.width), Mt(a, "height", r.height), n) {
|
|
138
|
+
const d = document.createElement("div"), l = document.createElement("span"), g = document.createElement("span");
|
|
139
|
+
d.className = "bridgerte__media-placeholder", d.setAttribute("aria-hidden", "true"), l.className = "bridgerte__media-placeholder-icon", l.textContent = r.mediaType === "image" ? "IMG" : "VIDEO", g.className = "bridgerte__media-placeholder-text", g.textContent = Io(r), d.append(l, g), o.append(d);
|
|
140
140
|
}
|
|
141
141
|
if (o.append(a), r.status === "uploading" || r.status === "error") {
|
|
142
142
|
const d = document.createElement("figcaption");
|
|
143
|
-
d.className = "bridgerte__media-status", d.textContent = r.status === "error" ? r.errorMessage ?? "上传失败" :
|
|
143
|
+
d.className = "bridgerte__media-status", d.textContent = r.status === "error" ? r.errorMessage ?? "上传失败" : En, o.append(d);
|
|
144
144
|
}
|
|
145
145
|
return o;
|
|
146
146
|
}
|
|
@@ -322,8 +322,8 @@ const qo = (e) => e.toJSON(), Go = (e) => {
|
|
|
322
322
|
const n = t.anchor, r = n.getNode(), o = ta(r);
|
|
323
323
|
if (!o || !ie(o)) return null;
|
|
324
324
|
if (ie(r)) {
|
|
325
|
-
const
|
|
326
|
-
return
|
|
325
|
+
const i = r.isEmpty() && n.offset === 0, d = r === o && n.offset === 0, l = r === o && n.offset === o.getChildrenSize();
|
|
326
|
+
return i || (e ? d : l) ? o : null;
|
|
327
327
|
}
|
|
328
328
|
if (!(r instanceof Y)) return null;
|
|
329
329
|
const a = e ? o.getFirstDescendant() : o.getLastDescendant(), s = e ? 0 : r.getTextContentSize();
|
|
@@ -487,6 +487,12 @@ const ia = (e) => {
|
|
|
487
487
|
const n = e.getEditorState().read(ca);
|
|
488
488
|
t.dataset.empty = String(n);
|
|
489
489
|
}, ua = ({
|
|
490
|
+
contentElement: e,
|
|
491
|
+
placeholderElement: t
|
|
492
|
+
}) => {
|
|
493
|
+
const n = window.getComputedStyle(e).padding, r = e.style.padding, o = n || r;
|
|
494
|
+
o && (t.style.padding = o);
|
|
495
|
+
}, ma = ({
|
|
490
496
|
editor: e,
|
|
491
497
|
contentElement: t,
|
|
492
498
|
isReadonly: n
|
|
@@ -501,7 +507,7 @@ const ia = (e) => {
|
|
|
501
507
|
return t.addEventListener("pointerdown", r), () => {
|
|
502
508
|
t.removeEventListener("pointerdown", r);
|
|
503
509
|
};
|
|
504
|
-
},
|
|
510
|
+
}, ga = [
|
|
505
511
|
{ command: "format.bold", format: "bold" },
|
|
506
512
|
{ command: "format.italic", format: "italic" },
|
|
507
513
|
{ command: "format.underline", format: "underline" },
|
|
@@ -509,17 +515,17 @@ const ia = (e) => {
|
|
|
509
515
|
{ command: "format.inlineCode", format: "code" },
|
|
510
516
|
{ command: "format.superscript", format: "superscript" },
|
|
511
517
|
{ command: "format.subscript", format: "subscript" }
|
|
512
|
-
],
|
|
518
|
+
], ha = [
|
|
513
519
|
{ command: "format.color", property: "color" },
|
|
514
520
|
{ command: "format.backgroundColor", property: "background-color" },
|
|
515
521
|
{ command: "format.fontSize", property: "font-size" },
|
|
516
522
|
{ command: "format.fontFamily", property: "font-family" },
|
|
517
523
|
{ command: "format.lineHeight", property: "line-height" }
|
|
518
|
-
],
|
|
524
|
+
], pa = [
|
|
519
525
|
{ command: "list.ordered", listType: "ordered" },
|
|
520
526
|
{ command: "list.unordered", listType: "unordered" },
|
|
521
527
|
{ command: "list.todo", listType: "todo" }
|
|
522
|
-
],
|
|
528
|
+
], fa = [
|
|
523
529
|
"media.pickImage",
|
|
524
530
|
"media.pickVideo"
|
|
525
531
|
], An = () => {
|
|
@@ -527,7 +533,7 @@ const ia = (e) => {
|
|
|
527
533
|
if (!O(e)) return null;
|
|
528
534
|
const t = e.anchor.getNode();
|
|
529
535
|
return t.getKey() === "root" ? t : t.getTopLevelElementOrThrow();
|
|
530
|
-
},
|
|
536
|
+
}, ba = () => {
|
|
531
537
|
const e = An();
|
|
532
538
|
if (!e) return null;
|
|
533
539
|
if (Ar(e)) {
|
|
@@ -551,44 +557,44 @@ const ia = (e) => {
|
|
|
551
557
|
return {
|
|
552
558
|
command: "block.paragraph"
|
|
553
559
|
};
|
|
554
|
-
},
|
|
560
|
+
}, ya = () => {
|
|
555
561
|
const e = An();
|
|
556
562
|
if (!e || !("getFormatType" in e)) return;
|
|
557
563
|
const t = e.getFormatType();
|
|
558
564
|
return t === "" ? void 0 : t;
|
|
559
|
-
},
|
|
565
|
+
}, va = () => {
|
|
560
566
|
const e = D();
|
|
561
567
|
if (!O(e)) return null;
|
|
562
568
|
const t = e.anchor.getNode(), n = Ur(t) ? t : Co(t, hn);
|
|
563
569
|
return n ? n.getListType() === "check" ? "todo" : n.getTag() === "ol" ? "ordered" : "unordered" : null;
|
|
564
|
-
},
|
|
570
|
+
}, wa = (e) => {
|
|
565
571
|
const t = D();
|
|
566
572
|
if (!O(t)) return;
|
|
567
573
|
const n = wo(t, e);
|
|
568
574
|
return n === "" ? void 0 : n;
|
|
569
|
-
},
|
|
575
|
+
}, Ca = () => {
|
|
570
576
|
const e = D();
|
|
571
577
|
if (!O(e)) return !1;
|
|
572
578
|
const t = e.anchor.getNode(), n = t.getParent();
|
|
573
579
|
return Se(t) || Se(n);
|
|
574
|
-
},
|
|
575
|
-
const t = D(), n = O(t), r =
|
|
580
|
+
}, _a = (e) => {
|
|
581
|
+
const t = D(), n = O(t), r = ba(), o = va(), a = ya(), s = Ca(), i = e.readonly || !n, d = ga.map((b) => ({
|
|
576
582
|
command: b.command,
|
|
577
583
|
active: n && t.hasFormat(b.format),
|
|
578
|
-
disabled:
|
|
579
|
-
})),
|
|
580
|
-
const T =
|
|
584
|
+
disabled: i
|
|
585
|
+
})), l = ha.map((b) => {
|
|
586
|
+
const T = wa(b.property);
|
|
581
587
|
return {
|
|
582
588
|
command: b.command,
|
|
583
589
|
active: T !== void 0,
|
|
584
|
-
disabled:
|
|
590
|
+
disabled: i,
|
|
585
591
|
value: T
|
|
586
592
|
};
|
|
587
|
-
}), g =
|
|
593
|
+
}), g = pa.map((b) => ({
|
|
588
594
|
command: b.command,
|
|
589
595
|
active: o === b.listType,
|
|
590
|
-
disabled:
|
|
591
|
-
})),
|
|
596
|
+
disabled: i
|
|
597
|
+
})), f = fa.map((b) => ({
|
|
592
598
|
command: b,
|
|
593
599
|
active: !1,
|
|
594
600
|
disabled: e.readonly || !e.canUploadMedia
|
|
@@ -598,24 +604,24 @@ const ia = (e) => {
|
|
|
598
604
|
{
|
|
599
605
|
command: "format.clear",
|
|
600
606
|
active: !1,
|
|
601
|
-
disabled:
|
|
607
|
+
disabled: i
|
|
602
608
|
},
|
|
603
|
-
...
|
|
609
|
+
...l,
|
|
604
610
|
{
|
|
605
611
|
command: "block.heading",
|
|
606
612
|
active: (r == null ? void 0 : r.command) === "block.heading",
|
|
607
|
-
disabled:
|
|
613
|
+
disabled: i,
|
|
608
614
|
value: (r == null ? void 0 : r.command) === "block.heading" ? r.value : void 0
|
|
609
615
|
},
|
|
610
616
|
{
|
|
611
617
|
command: "block.paragraph",
|
|
612
618
|
active: (r == null ? void 0 : r.command) === "block.paragraph",
|
|
613
|
-
disabled:
|
|
619
|
+
disabled: i
|
|
614
620
|
},
|
|
615
621
|
{
|
|
616
622
|
command: "block.quote",
|
|
617
623
|
active: (r == null ? void 0 : r.command) === "block.quote",
|
|
618
|
-
disabled:
|
|
624
|
+
disabled: i
|
|
619
625
|
},
|
|
620
626
|
{
|
|
621
627
|
command: "block.divider",
|
|
@@ -632,18 +638,18 @@ const ia = (e) => {
|
|
|
632
638
|
{
|
|
633
639
|
command: "align",
|
|
634
640
|
active: a !== void 0,
|
|
635
|
-
disabled:
|
|
641
|
+
disabled: i,
|
|
636
642
|
value: a
|
|
637
643
|
},
|
|
638
644
|
{
|
|
639
645
|
command: "link.set",
|
|
640
646
|
active: s,
|
|
641
|
-
disabled:
|
|
647
|
+
disabled: i
|
|
642
648
|
},
|
|
643
649
|
{
|
|
644
650
|
command: "link.unset",
|
|
645
651
|
active: !1,
|
|
646
|
-
disabled:
|
|
652
|
+
disabled: i || !s
|
|
647
653
|
},
|
|
648
654
|
{
|
|
649
655
|
command: "link.open",
|
|
@@ -653,12 +659,12 @@ const ia = (e) => {
|
|
|
653
659
|
{
|
|
654
660
|
command: "indent.increase",
|
|
655
661
|
active: !1,
|
|
656
|
-
disabled:
|
|
662
|
+
disabled: i
|
|
657
663
|
},
|
|
658
664
|
{
|
|
659
665
|
command: "indent.decrease",
|
|
660
666
|
active: !1,
|
|
661
|
-
disabled:
|
|
667
|
+
disabled: i
|
|
662
668
|
},
|
|
663
669
|
{
|
|
664
670
|
command: "history.undo",
|
|
@@ -675,7 +681,7 @@ const ia = (e) => {
|
|
|
675
681
|
active: !1,
|
|
676
682
|
disabled: e.readonly
|
|
677
683
|
},
|
|
678
|
-
...
|
|
684
|
+
...f,
|
|
679
685
|
{
|
|
680
686
|
command: "table.insert",
|
|
681
687
|
active: !1,
|
|
@@ -687,7 +693,7 @@ const ia = (e) => {
|
|
|
687
693
|
disabled: !1
|
|
688
694
|
}
|
|
689
695
|
];
|
|
690
|
-
},
|
|
696
|
+
}, ka = (e, t) => e.length === t.length && e.every((n, r) => {
|
|
691
697
|
const o = t[r];
|
|
692
698
|
return o !== void 0 && n.command === o.command && n.active === o.active && n.disabled === o.disabled && n.value === o.value;
|
|
693
699
|
}), K = (e, t, n, r) => {
|
|
@@ -697,7 +703,7 @@ const ia = (e) => {
|
|
|
697
703
|
} catch (a) {
|
|
698
704
|
console.error("[BridgeRTE] onError callback failed.", a);
|
|
699
705
|
}
|
|
700
|
-
},
|
|
706
|
+
}, xa = (e, t) => {
|
|
701
707
|
var n;
|
|
702
708
|
try {
|
|
703
709
|
(n = e.onChange) == null || n.call(e, t);
|
|
@@ -716,7 +722,7 @@ const ia = (e) => {
|
|
|
716
722
|
r
|
|
717
723
|
);
|
|
718
724
|
}
|
|
719
|
-
},
|
|
725
|
+
}, Ma = (e, t) => {
|
|
720
726
|
var n;
|
|
721
727
|
try {
|
|
722
728
|
(n = e.onCommandStateChange) == null || n.call(e, [...t]);
|
|
@@ -728,40 +734,40 @@ const ia = (e) => {
|
|
|
728
734
|
r
|
|
729
735
|
);
|
|
730
736
|
}
|
|
731
|
-
},
|
|
737
|
+
}, Ta = (e) => {
|
|
732
738
|
var t;
|
|
733
739
|
try {
|
|
734
740
|
(t = e.onFocus) == null || t.call(e);
|
|
735
741
|
} catch (n) {
|
|
736
742
|
K(e, "callback.onFocus", "onFocus callback failed.", n);
|
|
737
743
|
}
|
|
738
|
-
},
|
|
744
|
+
}, La = (e) => {
|
|
739
745
|
var t;
|
|
740
746
|
try {
|
|
741
747
|
(t = e.onBlur) == null || t.call(e);
|
|
742
748
|
} catch (n) {
|
|
743
749
|
K(e, "callback.onBlur", "onBlur callback failed.", n);
|
|
744
750
|
}
|
|
745
|
-
},
|
|
751
|
+
}, Sa = (e, t) => {
|
|
746
752
|
var n;
|
|
747
753
|
try {
|
|
748
754
|
(n = e.onReady) == null || n.call(e, t);
|
|
749
755
|
} catch (r) {
|
|
750
756
|
K(e, "callback.onReady", "onReady callback failed.", r);
|
|
751
757
|
}
|
|
752
|
-
},
|
|
758
|
+
}, Na = ({
|
|
753
759
|
lexicalEditor: e,
|
|
754
760
|
options: t,
|
|
755
761
|
isDestroyed: n,
|
|
756
762
|
canUploadMedia: r,
|
|
757
763
|
isReadonly: o
|
|
758
764
|
}) => {
|
|
759
|
-
let a = !1, s = !1,
|
|
760
|
-
const d = /* @__PURE__ */ new Set(),
|
|
761
|
-
const
|
|
765
|
+
let a = !1, s = !1, i = [];
|
|
766
|
+
const d = /* @__PURE__ */ new Set(), l = () => {
|
|
767
|
+
const f = [...i];
|
|
762
768
|
d.forEach((b) => {
|
|
763
769
|
try {
|
|
764
|
-
b(
|
|
770
|
+
b(f);
|
|
765
771
|
} catch (T) {
|
|
766
772
|
K(
|
|
767
773
|
t,
|
|
@@ -771,50 +777,50 @@ const ia = (e) => {
|
|
|
771
777
|
);
|
|
772
778
|
}
|
|
773
779
|
});
|
|
774
|
-
}, g = (
|
|
780
|
+
}, g = (f = !0) => {
|
|
775
781
|
if (n()) return;
|
|
776
|
-
const b =
|
|
782
|
+
const b = i;
|
|
777
783
|
e.getEditorState().read(() => {
|
|
778
|
-
|
|
784
|
+
i = _a({
|
|
779
785
|
canUndo: a,
|
|
780
786
|
canRedo: s,
|
|
781
787
|
readonly: o(),
|
|
782
788
|
canUploadMedia: r()
|
|
783
789
|
});
|
|
784
|
-
}),
|
|
790
|
+
}), f && !ka(b, i) && (Ma(t, i), l());
|
|
785
791
|
};
|
|
786
792
|
return {
|
|
787
793
|
refreshCommandStates: g,
|
|
788
794
|
getCommandStates() {
|
|
789
|
-
return g(!1), [...
|
|
795
|
+
return g(!1), [...i];
|
|
790
796
|
},
|
|
791
|
-
subscribeCommandStateChange(
|
|
797
|
+
subscribeCommandStateChange(f) {
|
|
792
798
|
return n() ? () => {
|
|
793
|
-
} : (d.add(
|
|
794
|
-
d.delete(
|
|
799
|
+
} : (d.add(f), f([...i]), () => {
|
|
800
|
+
d.delete(f);
|
|
795
801
|
});
|
|
796
802
|
},
|
|
797
|
-
setCanUndo(
|
|
798
|
-
a =
|
|
803
|
+
setCanUndo(f) {
|
|
804
|
+
a = f, g();
|
|
799
805
|
},
|
|
800
|
-
setCanRedo(
|
|
801
|
-
s =
|
|
806
|
+
setCanRedo(f) {
|
|
807
|
+
s = f, g();
|
|
802
808
|
},
|
|
803
|
-
setHistoryAvailability(
|
|
804
|
-
a =
|
|
809
|
+
setHistoryAvailability(f, b) {
|
|
810
|
+
a = f, s = b, g();
|
|
805
811
|
},
|
|
806
812
|
destroy() {
|
|
807
813
|
d.clear();
|
|
808
814
|
}
|
|
809
815
|
};
|
|
810
|
-
},
|
|
816
|
+
}, Pa = (e) => `upload:${e}:${Date.now()}:${Math.random().toString(36).slice(2)}`, Ia = (e) => typeof URL.createObjectURL == "function" ? URL.createObjectURL(e) : e.name, we = (e) => {
|
|
811
817
|
typeof URL.revokeObjectURL == "function" && e.startsWith("blob:") && URL.revokeObjectURL(e);
|
|
812
818
|
}, St = (e) => ({
|
|
813
819
|
name: e.name,
|
|
814
820
|
mimeType: e.type || void 0,
|
|
815
821
|
size: e.size,
|
|
816
822
|
data: e
|
|
817
|
-
}),
|
|
823
|
+
}), Ra = (e) => typeof DOMException < "u" && e instanceof DOMException && e.name === "AbortError", Aa = (e) => new Promise((t) => {
|
|
818
824
|
const n = new Image(), r = () => {
|
|
819
825
|
n.onload = null, n.onerror = null;
|
|
820
826
|
};
|
|
@@ -827,7 +833,7 @@ const ia = (e) => {
|
|
|
827
833
|
}, n.onerror = () => {
|
|
828
834
|
r(), t({});
|
|
829
835
|
}, n.src = e;
|
|
830
|
-
}),
|
|
836
|
+
}), Ba = (e) => new Promise((t) => {
|
|
831
837
|
const n = document.createElement("video"), r = () => {
|
|
832
838
|
n.removeAttribute("src"), n.load(), n.onloadedmetadata = null, n.onerror = null;
|
|
833
839
|
};
|
|
@@ -841,12 +847,12 @@ const ia = (e) => {
|
|
|
841
847
|
}, n.onerror = () => {
|
|
842
848
|
r(), t({});
|
|
843
849
|
}, n.src = e, n.load();
|
|
844
|
-
}),
|
|
850
|
+
}), Da = (e, t) => t.startsWith("blob:") ? e === "image" ? Aa(t) : Ba(t) : Promise.resolve({}), Ha = (e, t) => ({
|
|
845
851
|
...e,
|
|
846
852
|
width: e.width ?? t.width,
|
|
847
853
|
height: e.height ?? t.height,
|
|
848
854
|
duration: e.duration ?? t.duration
|
|
849
|
-
}),
|
|
855
|
+
}), Oa = ({
|
|
850
856
|
container: e,
|
|
851
857
|
lexicalEditor: t,
|
|
852
858
|
options: n,
|
|
@@ -859,7 +865,7 @@ const ia = (e) => {
|
|
|
859
865
|
var E;
|
|
860
866
|
(E = ge(u)) == null || E.updatePayload(p);
|
|
861
867
|
});
|
|
862
|
-
},
|
|
868
|
+
}, i = (u) => {
|
|
863
869
|
let p = null;
|
|
864
870
|
return t.update(() => {
|
|
865
871
|
const E = ge(u);
|
|
@@ -885,13 +891,13 @@ const ia = (e) => {
|
|
|
885
891
|
}, d = (u, p) => {
|
|
886
892
|
const E = o.get(u);
|
|
887
893
|
return (E == null ? void 0 : E.runId) === p;
|
|
888
|
-
},
|
|
894
|
+
}, l = (u) => {
|
|
889
895
|
var p;
|
|
890
896
|
(p = u.abortController) == null || p.abort();
|
|
891
897
|
}, g = (u, p) => {
|
|
892
898
|
const E = o.get(u);
|
|
893
|
-
return E ? (
|
|
894
|
-
},
|
|
899
|
+
return E ? (l(E), we(E.previewUrl), o.delete(u), !0) : !1;
|
|
900
|
+
}, f = (u, p, E, _) => {
|
|
895
901
|
t.update(
|
|
896
902
|
() => {
|
|
897
903
|
const B = ce({
|
|
@@ -924,7 +930,7 @@ const ia = (e) => {
|
|
|
924
930
|
}), we(E);
|
|
925
931
|
}, T = (u, p, E) => {
|
|
926
932
|
var _;
|
|
927
|
-
|
|
933
|
+
Ra(E) || (s(p, {
|
|
928
934
|
mediaType: u,
|
|
929
935
|
status: "error",
|
|
930
936
|
errorMessage: "上传失败"
|
|
@@ -933,7 +939,7 @@ const ia = (e) => {
|
|
|
933
939
|
type: u,
|
|
934
940
|
cause: E
|
|
935
941
|
}));
|
|
936
|
-
},
|
|
942
|
+
}, v = (u) => {
|
|
937
943
|
const p = n.uploadAdapter;
|
|
938
944
|
if (!p) return;
|
|
939
945
|
const E = typeof AbortController == "function" ? new AbortController() : null, _ = a + 1;
|
|
@@ -950,7 +956,7 @@ const ia = (e) => {
|
|
|
950
956
|
}
|
|
951
957
|
};
|
|
952
958
|
let H = {};
|
|
953
|
-
const I =
|
|
959
|
+
const I = Da(u.type, u.previewUrl);
|
|
954
960
|
let w;
|
|
955
961
|
try {
|
|
956
962
|
w = u.type === "image" ? p.uploadImage(St(u.file), B) : p.uploadVideo(St(u.file), B);
|
|
@@ -970,14 +976,14 @@ const ia = (e) => {
|
|
|
970
976
|
u.type,
|
|
971
977
|
u.assetId,
|
|
972
978
|
u.previewUrl,
|
|
973
|
-
|
|
979
|
+
Ha(c, H)
|
|
974
980
|
), o.delete(u.assetId));
|
|
975
981
|
}).catch((c) => {
|
|
976
982
|
r() || !d(u.assetId, _) || T(u.type, u.assetId, c);
|
|
977
983
|
});
|
|
978
984
|
}, y = (u, p) => {
|
|
979
985
|
if (!n.uploadAdapter) return;
|
|
980
|
-
const E =
|
|
986
|
+
const E = Pa(u), _ = Ia(p), B = {
|
|
981
987
|
assetId: E,
|
|
982
988
|
type: u,
|
|
983
989
|
file: p,
|
|
@@ -985,7 +991,7 @@ const ia = (e) => {
|
|
|
985
991
|
runId: 0,
|
|
986
992
|
abortController: null
|
|
987
993
|
};
|
|
988
|
-
|
|
994
|
+
f(u, p, E, _), v(B);
|
|
989
995
|
};
|
|
990
996
|
return {
|
|
991
997
|
pickMediaFile: (u) => {
|
|
@@ -999,33 +1005,33 @@ const ia = (e) => {
|
|
|
999
1005
|
},
|
|
1000
1006
|
uploadMediaFile: y,
|
|
1001
1007
|
removeMedia(u) {
|
|
1002
|
-
const p =
|
|
1008
|
+
const p = i(u);
|
|
1003
1009
|
!g(u) && (p != null && p.url.startsWith("blob:")) && we(p.url);
|
|
1004
1010
|
},
|
|
1005
1011
|
retryMedia(u) {
|
|
1006
1012
|
const p = o.get(u);
|
|
1007
|
-
!p || !n.uploadAdapter || (
|
|
1013
|
+
!p || !n.uploadAdapter || (l(p), s(u, {
|
|
1008
1014
|
mediaType: p.type,
|
|
1009
1015
|
url: p.previewUrl,
|
|
1010
1016
|
status: "uploading",
|
|
1011
1017
|
progress: 0,
|
|
1012
1018
|
errorMessage: void 0
|
|
1013
|
-
}),
|
|
1019
|
+
}), v(p));
|
|
1014
1020
|
},
|
|
1015
1021
|
destroy() {
|
|
1016
1022
|
o.forEach((u) => {
|
|
1017
|
-
|
|
1023
|
+
l(u), we(u.previewUrl);
|
|
1018
1024
|
}), o.clear();
|
|
1019
1025
|
}
|
|
1020
1026
|
};
|
|
1021
|
-
}, Bn = (e) => Fr(e),
|
|
1027
|
+
}, Bn = (e) => Fr(e), $a = {
|
|
1022
1028
|
1: "h1",
|
|
1023
1029
|
2: "h2",
|
|
1024
1030
|
3: "h3",
|
|
1025
1031
|
4: "h4",
|
|
1026
1032
|
5: "h5",
|
|
1027
1033
|
6: "h6"
|
|
1028
|
-
},
|
|
1034
|
+
}, Fa = {
|
|
1029
1035
|
code: "bridgerte__code-block",
|
|
1030
1036
|
codeHighlight: {
|
|
1031
1037
|
attr: "bridgerte__code-token bridgerte__code-token--attr",
|
|
@@ -1086,68 +1092,68 @@ const ia = (e) => {
|
|
|
1086
1092
|
tableCellHeader: "bridgerte__table-cell bridgerte__table-cell--header",
|
|
1087
1093
|
tableRow: "bridgerte__table-row",
|
|
1088
1094
|
tableScrollableWrapper: "bridgerte__table-wrapper"
|
|
1089
|
-
},
|
|
1090
|
-
setBlockHeading: (
|
|
1095
|
+
}, za = (e) => ({
|
|
1096
|
+
setBlockHeading: (l) => {
|
|
1091
1097
|
e.update(() => {
|
|
1092
1098
|
const g = D();
|
|
1093
|
-
O(g) && Fe(g, () => Dr(
|
|
1099
|
+
O(g) && Fe(g, () => Dr($a[l]));
|
|
1094
1100
|
});
|
|
1095
1101
|
},
|
|
1096
1102
|
setParagraphBlock: () => {
|
|
1097
1103
|
e.update(() => {
|
|
1098
|
-
const
|
|
1099
|
-
O(
|
|
1104
|
+
const l = D();
|
|
1105
|
+
O(l) && Fe(l, () => z());
|
|
1100
1106
|
});
|
|
1101
1107
|
},
|
|
1102
1108
|
setQuoteBlock: () => {
|
|
1103
1109
|
e.update(() => {
|
|
1104
|
-
const
|
|
1105
|
-
O(
|
|
1110
|
+
const l = D();
|
|
1111
|
+
O(l) && Fe(l, () => Br());
|
|
1106
1112
|
});
|
|
1107
1113
|
},
|
|
1108
1114
|
insertDividerBlock: () => {
|
|
1109
1115
|
e.update(() => {
|
|
1110
|
-
const
|
|
1111
|
-
W([at(),
|
|
1116
|
+
const l = z();
|
|
1117
|
+
W([at(), l]), l.selectStart();
|
|
1112
1118
|
});
|
|
1113
1119
|
},
|
|
1114
|
-
insertCodeBlock: (
|
|
1120
|
+
insertCodeBlock: (l) => {
|
|
1115
1121
|
e.update(() => {
|
|
1116
|
-
const g = Bn(
|
|
1117
|
-
W([g,
|
|
1122
|
+
const g = Bn(l), f = z();
|
|
1123
|
+
W([g, f]), g.selectEnd();
|
|
1118
1124
|
});
|
|
1119
1125
|
},
|
|
1120
|
-
setSelectedCodeBlockLanguage: (
|
|
1126
|
+
setSelectedCodeBlockLanguage: (l) => {
|
|
1121
1127
|
e.update(() => {
|
|
1122
1128
|
const g = D();
|
|
1123
1129
|
if (!O(g)) return;
|
|
1124
|
-
const
|
|
1125
|
-
X(b) && b.setLanguage(
|
|
1130
|
+
const f = g.anchor.getNode(), b = f.getKey() === "root" ? f : f.getTopLevelElementOrThrow();
|
|
1131
|
+
X(b) && b.setLanguage(l);
|
|
1126
1132
|
});
|
|
1127
1133
|
},
|
|
1128
1134
|
clearContent: () => {
|
|
1129
1135
|
e.update(() => {
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1136
|
+
const l = F();
|
|
1137
|
+
l.clear(), l.append(z());
|
|
1132
1138
|
});
|
|
1133
1139
|
},
|
|
1134
|
-
formatAlign: (
|
|
1135
|
-
e.dispatchCommand(fr,
|
|
1140
|
+
formatAlign: (l) => {
|
|
1141
|
+
e.dispatchCommand(fr, l);
|
|
1136
1142
|
}
|
|
1137
|
-
}),
|
|
1143
|
+
}), Va = (e) => ({
|
|
1138
1144
|
setLink: (o, a) => {
|
|
1139
1145
|
e.update(() => {
|
|
1140
|
-
const s = D(),
|
|
1146
|
+
const s = D(), i = mo(o), d = (a == null ? void 0 : a.trim()) || o.trim();
|
|
1141
1147
|
if (!(!O(s) || !o.trim())) {
|
|
1142
1148
|
if (s.isCollapsed()) {
|
|
1143
|
-
const
|
|
1149
|
+
const l = go(i, {
|
|
1144
1150
|
rel: "noreferrer noopener",
|
|
1145
1151
|
target: "_blank"
|
|
1146
1152
|
});
|
|
1147
|
-
|
|
1153
|
+
l.append(Be(d)), W([l]);
|
|
1148
1154
|
return;
|
|
1149
1155
|
}
|
|
1150
|
-
ft(
|
|
1156
|
+
ft(i, {
|
|
1151
1157
|
rel: "noreferrer noopener",
|
|
1152
1158
|
target: "_blank"
|
|
1153
1159
|
});
|
|
@@ -1164,52 +1170,52 @@ const ia = (e) => {
|
|
|
1164
1170
|
const o = e.getEditorState().read(() => {
|
|
1165
1171
|
const a = D();
|
|
1166
1172
|
if (!O(a)) return null;
|
|
1167
|
-
const s = a.anchor.getNode(),
|
|
1168
|
-
return
|
|
1169
|
-
target:
|
|
1170
|
-
url:
|
|
1173
|
+
const s = a.anchor.getNode(), i = Se(s) ? s : _o(s, Se);
|
|
1174
|
+
return i ? {
|
|
1175
|
+
target: i.getTarget() ?? "_blank",
|
|
1176
|
+
url: i.sanitizeUrl(i.getURL())
|
|
1171
1177
|
} : null;
|
|
1172
1178
|
});
|
|
1173
1179
|
o && window.open(o.url, o.target, "noopener,noreferrer");
|
|
1174
1180
|
}
|
|
1175
|
-
}),
|
|
1181
|
+
}), Wa = (e) => ({
|
|
1176
1182
|
insertImage: (s) => {
|
|
1177
1183
|
s.url.trim() && e.update(() => {
|
|
1178
|
-
const
|
|
1179
|
-
W([Do(s),
|
|
1184
|
+
const i = z();
|
|
1185
|
+
W([Do(s), i]), i.selectStart();
|
|
1180
1186
|
});
|
|
1181
1187
|
},
|
|
1182
1188
|
insertVideo: (s) => {
|
|
1183
1189
|
s.url.trim() && e.update(() => {
|
|
1184
|
-
const
|
|
1185
|
-
W([Ho(s),
|
|
1190
|
+
const i = z();
|
|
1191
|
+
W([Ho(s), i]), i.selectStart();
|
|
1186
1192
|
});
|
|
1187
1193
|
},
|
|
1188
1194
|
resizeMedia: (s) => {
|
|
1189
1195
|
e.update(() => {
|
|
1190
|
-
var
|
|
1191
|
-
(
|
|
1196
|
+
var i;
|
|
1197
|
+
(i = ge(s.assetId)) == null || i.updatePayload({
|
|
1192
1198
|
displayWidthPercent: s.widthPercent
|
|
1193
1199
|
});
|
|
1194
1200
|
});
|
|
1195
1201
|
},
|
|
1196
1202
|
resetMediaSize: (s) => {
|
|
1197
1203
|
e.update(() => {
|
|
1198
|
-
var
|
|
1199
|
-
(
|
|
1204
|
+
var i;
|
|
1205
|
+
(i = ge(s)) == null || i.updatePayload({
|
|
1200
1206
|
displayWidthPercent: void 0
|
|
1201
1207
|
});
|
|
1202
1208
|
});
|
|
1203
1209
|
},
|
|
1204
1210
|
alignMedia: (s) => {
|
|
1205
1211
|
e.update(() => {
|
|
1206
|
-
var
|
|
1207
|
-
(
|
|
1212
|
+
var i;
|
|
1213
|
+
(i = ge(s.assetId)) == null || i.updatePayload({
|
|
1208
1214
|
align: s.value === "left" ? void 0 : s.value
|
|
1209
1215
|
});
|
|
1210
1216
|
});
|
|
1211
1217
|
}
|
|
1212
|
-
}),
|
|
1218
|
+
}), Ua = (e) => ({
|
|
1213
1219
|
insertMention: (n) => {
|
|
1214
1220
|
e.update(() => {
|
|
1215
1221
|
const r = D();
|
|
@@ -1219,7 +1225,7 @@ const ia = (e) => {
|
|
|
1219
1225
|
]);
|
|
1220
1226
|
});
|
|
1221
1227
|
}
|
|
1222
|
-
}),
|
|
1228
|
+
}), ja = (e) => ({
|
|
1223
1229
|
clearSelectionFormat: () => {
|
|
1224
1230
|
e.update(() => {
|
|
1225
1231
|
const r = D();
|
|
@@ -1240,14 +1246,14 @@ const ia = (e) => {
|
|
|
1240
1246
|
});
|
|
1241
1247
|
});
|
|
1242
1248
|
}
|
|
1243
|
-
}),
|
|
1249
|
+
}), Ka = 20, Nt = (e, t) => Number.isFinite(e) && e > 0 ? Math.min(Math.floor(e), t) : 1, Ce = (e) => Number.isFinite(e) && (e ?? 0) > 0 ? Math.min(Math.floor(e ?? 1), Ka) : 1, _e = () => {
|
|
1244
1250
|
const e = D();
|
|
1245
1251
|
return !O(e) && !pn(e) ? !1 : oo(e.anchor.getNode()) !== null;
|
|
1246
|
-
},
|
|
1247
|
-
insertTable: (
|
|
1248
|
-
const
|
|
1252
|
+
}, qa = (e) => ({
|
|
1253
|
+
insertTable: (i, d) => {
|
|
1254
|
+
const l = Nt(i, tn), g = Nt(d, nn);
|
|
1249
1255
|
e.dispatchCommand(ro, {
|
|
1250
|
-
rows: String(
|
|
1256
|
+
rows: String(l),
|
|
1251
1257
|
columns: String(g),
|
|
1252
1258
|
/*
|
|
1253
1259
|
* BridgeRTE 默认表格更贴近文档编辑场景:首行作为表头,首列保持普通单元格。
|
|
@@ -1259,35 +1265,35 @@ const ia = (e) => {
|
|
|
1259
1265
|
}
|
|
1260
1266
|
});
|
|
1261
1267
|
},
|
|
1262
|
-
insertTableRow: (
|
|
1268
|
+
insertTableRow: (i) => {
|
|
1263
1269
|
e.update(() => {
|
|
1264
1270
|
if (!_e()) return;
|
|
1265
|
-
const d = Ce(
|
|
1266
|
-
for (let
|
|
1267
|
-
no(
|
|
1271
|
+
const d = Ce(i.count);
|
|
1272
|
+
for (let l = 0; l < d; l += 1)
|
|
1273
|
+
no(i.direction !== "before");
|
|
1268
1274
|
});
|
|
1269
1275
|
},
|
|
1270
|
-
insertTableColumn: (
|
|
1276
|
+
insertTableColumn: (i) => {
|
|
1271
1277
|
e.update(() => {
|
|
1272
1278
|
if (!_e()) return;
|
|
1273
|
-
const d = Ce(
|
|
1274
|
-
for (let
|
|
1275
|
-
to(
|
|
1279
|
+
const d = Ce(i.count);
|
|
1280
|
+
for (let l = 0; l < d; l += 1)
|
|
1281
|
+
to(i.direction !== "before");
|
|
1276
1282
|
});
|
|
1277
1283
|
},
|
|
1278
|
-
deleteTableRow: (
|
|
1284
|
+
deleteTableRow: (i) => {
|
|
1279
1285
|
e.update(() => {
|
|
1280
|
-
const d = Ce(
|
|
1281
|
-
for (let
|
|
1286
|
+
const d = Ce(i.count);
|
|
1287
|
+
for (let l = 0; l < d; l += 1) {
|
|
1282
1288
|
if (!_e()) return;
|
|
1283
1289
|
eo();
|
|
1284
1290
|
}
|
|
1285
1291
|
});
|
|
1286
1292
|
},
|
|
1287
|
-
deleteTableColumn: (
|
|
1293
|
+
deleteTableColumn: (i) => {
|
|
1288
1294
|
e.update(() => {
|
|
1289
|
-
const d = Ce(
|
|
1290
|
-
for (let
|
|
1295
|
+
const d = Ce(i.count);
|
|
1296
|
+
for (let l = 0; l < d; l += 1) {
|
|
1291
1297
|
if (!_e()) return;
|
|
1292
1298
|
Zr();
|
|
1293
1299
|
}
|
|
@@ -1295,16 +1301,16 @@ const ia = (e) => {
|
|
|
1295
1301
|
},
|
|
1296
1302
|
deleteTable: () => {
|
|
1297
1303
|
e.update(() => {
|
|
1298
|
-
const
|
|
1299
|
-
if (!O(
|
|
1300
|
-
const d = Qr(
|
|
1304
|
+
const i = D();
|
|
1305
|
+
if (!O(i) && !pn(i)) return;
|
|
1306
|
+
const d = Qr(i.anchor.getNode());
|
|
1301
1307
|
if (!d) return;
|
|
1302
|
-
const
|
|
1303
|
-
d.insertAfter(
|
|
1308
|
+
const l = z();
|
|
1309
|
+
d.insertAfter(l), d.remove(), l.selectStart();
|
|
1304
1310
|
});
|
|
1305
1311
|
}
|
|
1306
|
-
}),
|
|
1307
|
-
const t =
|
|
1312
|
+
}), Ga = (e) => {
|
|
1313
|
+
const t = qa(e);
|
|
1308
1314
|
return {
|
|
1309
1315
|
insertTable: (n) => {
|
|
1310
1316
|
t.insertTable(n.rows, n.cols);
|
|
@@ -1325,7 +1331,7 @@ const ia = (e) => {
|
|
|
1325
1331
|
t.deleteTable();
|
|
1326
1332
|
}
|
|
1327
1333
|
};
|
|
1328
|
-
},
|
|
1334
|
+
}, Xa = {
|
|
1329
1335
|
"format.bold": "bold",
|
|
1330
1336
|
"format.italic": "italic",
|
|
1331
1337
|
"format.underline": "underline",
|
|
@@ -1333,22 +1339,22 @@ const ia = (e) => {
|
|
|
1333
1339
|
"format.inlineCode": "code",
|
|
1334
1340
|
"format.superscript": "superscript",
|
|
1335
1341
|
"format.subscript": "subscript"
|
|
1336
|
-
},
|
|
1342
|
+
}, Ya = {
|
|
1337
1343
|
"list.ordered": qr,
|
|
1338
1344
|
"list.unordered": Kr,
|
|
1339
1345
|
"list.todo": jr
|
|
1340
|
-
},
|
|
1346
|
+
}, Ja = {
|
|
1341
1347
|
"indent.increase": Cr,
|
|
1342
1348
|
"indent.decrease": wr,
|
|
1343
1349
|
"history.undo": vr,
|
|
1344
1350
|
"history.redo": yr
|
|
1345
|
-
},
|
|
1351
|
+
}, Qa = {
|
|
1346
1352
|
"format.color": "color",
|
|
1347
1353
|
"format.backgroundColor": "background-color",
|
|
1348
1354
|
"format.fontSize": "font-size",
|
|
1349
1355
|
"format.fontFamily": "font-family",
|
|
1350
1356
|
"format.lineHeight": "line-height"
|
|
1351
|
-
},
|
|
1357
|
+
}, Za = ({
|
|
1352
1358
|
container: e,
|
|
1353
1359
|
lexicalEditor: t,
|
|
1354
1360
|
options: n,
|
|
@@ -1356,12 +1362,12 @@ const ia = (e) => {
|
|
|
1356
1362
|
isReadonly: o,
|
|
1357
1363
|
reportError: a
|
|
1358
1364
|
}) => {
|
|
1359
|
-
const s =
|
|
1365
|
+
const s = Oa({
|
|
1360
1366
|
container: e,
|
|
1361
1367
|
lexicalEditor: t,
|
|
1362
1368
|
options: n,
|
|
1363
1369
|
isDestroyed: r
|
|
1364
|
-
}),
|
|
1370
|
+
}), i = za(t), d = Va(t), l = Wa(t), g = Ua(t), f = ja(t), b = Ga(t), T = () => {
|
|
1365
1371
|
var x, u;
|
|
1366
1372
|
if (document.fullscreenElement) {
|
|
1367
1373
|
(x = document.exitFullscreen) == null || x.call(document).catch((p) => {
|
|
@@ -1372,52 +1378,52 @@ const ia = (e) => {
|
|
|
1372
1378
|
(u = e.requestFullscreen) == null || u.call(e).catch((p) => {
|
|
1373
1379
|
a(n, "fullscreen.enter", "Enter fullscreen failed.", p);
|
|
1374
1380
|
});
|
|
1375
|
-
},
|
|
1381
|
+
}, v = ((y) => {
|
|
1376
1382
|
if (r() || o()) return;
|
|
1377
|
-
const x =
|
|
1383
|
+
const x = Xa[y.type];
|
|
1378
1384
|
if (x) {
|
|
1379
1385
|
t.dispatchCommand(br, x);
|
|
1380
1386
|
return;
|
|
1381
1387
|
}
|
|
1382
|
-
const u =
|
|
1388
|
+
const u = Ya[y.type];
|
|
1383
1389
|
if (u) {
|
|
1384
1390
|
t.dispatchCommand(u, void 0);
|
|
1385
1391
|
return;
|
|
1386
1392
|
}
|
|
1387
|
-
const p =
|
|
1393
|
+
const p = Ja[y.type];
|
|
1388
1394
|
if (p) {
|
|
1389
1395
|
t.dispatchCommand(p, void 0);
|
|
1390
1396
|
return;
|
|
1391
1397
|
}
|
|
1392
|
-
const E =
|
|
1398
|
+
const E = Qa[y.type];
|
|
1393
1399
|
if (E && "value" in y) {
|
|
1394
|
-
|
|
1400
|
+
f.setSelectionStyle(E, y.value);
|
|
1395
1401
|
return;
|
|
1396
1402
|
}
|
|
1397
1403
|
switch (y.type) {
|
|
1398
1404
|
case "format.clear":
|
|
1399
|
-
|
|
1405
|
+
f.clearSelectionFormat();
|
|
1400
1406
|
return;
|
|
1401
1407
|
case "block.heading":
|
|
1402
|
-
|
|
1408
|
+
i.setBlockHeading(y.level);
|
|
1403
1409
|
return;
|
|
1404
1410
|
case "block.paragraph":
|
|
1405
|
-
|
|
1411
|
+
i.setParagraphBlock();
|
|
1406
1412
|
return;
|
|
1407
1413
|
case "block.quote":
|
|
1408
|
-
|
|
1414
|
+
i.setQuoteBlock();
|
|
1409
1415
|
return;
|
|
1410
1416
|
case "block.divider":
|
|
1411
|
-
|
|
1417
|
+
i.insertDividerBlock();
|
|
1412
1418
|
return;
|
|
1413
1419
|
case "block.code":
|
|
1414
|
-
|
|
1420
|
+
i.insertCodeBlock(y.language);
|
|
1415
1421
|
return;
|
|
1416
1422
|
case "block.setCodeLanguage":
|
|
1417
|
-
|
|
1423
|
+
i.setSelectedCodeBlockLanguage(y.language);
|
|
1418
1424
|
return;
|
|
1419
1425
|
case "align":
|
|
1420
|
-
|
|
1426
|
+
i.formatAlign(y.value);
|
|
1421
1427
|
return;
|
|
1422
1428
|
case "link.set":
|
|
1423
1429
|
d.setLink(y.href, y.text);
|
|
@@ -1432,7 +1438,7 @@ const ia = (e) => {
|
|
|
1432
1438
|
g.insertMention(y.item);
|
|
1433
1439
|
return;
|
|
1434
1440
|
case "content.clear":
|
|
1435
|
-
|
|
1441
|
+
i.clearContent();
|
|
1436
1442
|
return;
|
|
1437
1443
|
case "table.insert":
|
|
1438
1444
|
b.insertTable(y);
|
|
@@ -1453,10 +1459,10 @@ const ia = (e) => {
|
|
|
1453
1459
|
b.deleteTable();
|
|
1454
1460
|
return;
|
|
1455
1461
|
case "media.insertImage":
|
|
1456
|
-
|
|
1462
|
+
l.insertImage(y);
|
|
1457
1463
|
return;
|
|
1458
1464
|
case "media.insertVideo":
|
|
1459
|
-
|
|
1465
|
+
l.insertVideo(y);
|
|
1460
1466
|
return;
|
|
1461
1467
|
case "media.pickImage":
|
|
1462
1468
|
s.pickMediaFile("image");
|
|
@@ -1471,23 +1477,23 @@ const ia = (e) => {
|
|
|
1471
1477
|
s.removeMedia(y.assetId);
|
|
1472
1478
|
return;
|
|
1473
1479
|
case "media.resize":
|
|
1474
|
-
|
|
1480
|
+
l.resizeMedia(y);
|
|
1475
1481
|
return;
|
|
1476
1482
|
case "media.align":
|
|
1477
|
-
|
|
1483
|
+
l.alignMedia(y);
|
|
1478
1484
|
return;
|
|
1479
1485
|
case "media.resetSize":
|
|
1480
|
-
|
|
1486
|
+
l.resetMediaSize(y.assetId);
|
|
1481
1487
|
return;
|
|
1482
1488
|
case "fullscreen.toggle":
|
|
1483
1489
|
T();
|
|
1484
1490
|
return;
|
|
1485
1491
|
}
|
|
1486
1492
|
});
|
|
1487
|
-
return
|
|
1493
|
+
return v.uploadMediaFile = s.uploadMediaFile, v.destroy = () => {
|
|
1488
1494
|
s.destroy();
|
|
1489
|
-
},
|
|
1490
|
-
},
|
|
1495
|
+
}, v;
|
|
1496
|
+
}, es = 300, ts = "BridgeRTE", Pt = ({
|
|
1491
1497
|
editor: e,
|
|
1492
1498
|
overflowLength: t
|
|
1493
1499
|
}) => {
|
|
@@ -1498,7 +1504,7 @@ const ia = (e) => {
|
|
|
1498
1504
|
F().selectEnd();
|
|
1499
1505
|
const r = D();
|
|
1500
1506
|
return O(r) ? (vt(e, r.anchor, t), !0) : !1;
|
|
1501
|
-
},
|
|
1507
|
+
}, ns = ({
|
|
1502
1508
|
lexicalEditor: e,
|
|
1503
1509
|
options: t,
|
|
1504
1510
|
isDestroyed: n,
|
|
@@ -1506,13 +1512,13 @@ const ia = (e) => {
|
|
|
1506
1512
|
syncPlaceholder: o
|
|
1507
1513
|
}) => {
|
|
1508
1514
|
let a = 0, s = null;
|
|
1509
|
-
const
|
|
1515
|
+
const i = () => {
|
|
1510
1516
|
s && (clearTimeout(s), s = null);
|
|
1511
1517
|
}, d = (u) => {
|
|
1512
1518
|
if (n()) return;
|
|
1513
1519
|
const p = Nn(e.getEditorState(), e);
|
|
1514
|
-
r(p), u &&
|
|
1515
|
-
},
|
|
1520
|
+
r(p), u && xa(t, p);
|
|
1521
|
+
}, l = (u) => {
|
|
1516
1522
|
const p = t.maxLength !== void 0 && t.maxLength >= 0 ? t.maxLength : void 0;
|
|
1517
1523
|
return {
|
|
1518
1524
|
dirty: !0,
|
|
@@ -1522,9 +1528,9 @@ const ia = (e) => {
|
|
|
1522
1528
|
isOverMaxLength: p === void 0 ? !1 : u > p
|
|
1523
1529
|
};
|
|
1524
1530
|
}, g = (u) => {
|
|
1525
|
-
Ea(t,
|
|
1526
|
-
},
|
|
1527
|
-
t.onChange && (
|
|
1531
|
+
Ea(t, l(u));
|
|
1532
|
+
}, f = () => {
|
|
1533
|
+
t.onChange && (i(), s = setTimeout(() => {
|
|
1528
1534
|
d(!0);
|
|
1529
1535
|
}, dr));
|
|
1530
1536
|
}, b = (u) => {
|
|
@@ -1532,12 +1538,12 @@ const ia = (e) => {
|
|
|
1532
1538
|
a -= 1;
|
|
1533
1539
|
return;
|
|
1534
1540
|
}
|
|
1535
|
-
g(u),
|
|
1536
|
-
}, T = () => e.getEditorState().read(() => F().getTextContent().length),
|
|
1541
|
+
g(u), f();
|
|
1542
|
+
}, T = () => e.getEditorState().read(() => F().getTextContent().length), v = (u) => t.maxLength === void 0 || t.maxLength < 0 ? 0 : u - t.maxLength, y = (u) => u <= 0 ? !1 : (e.update(() => {
|
|
1537
1543
|
Pt({ editor: e, overflowLength: u });
|
|
1538
1544
|
}, { discrete: !0 }), !0);
|
|
1539
1545
|
return {
|
|
1540
|
-
clearContentChangeTimer:
|
|
1546
|
+
clearContentChangeTimer: i,
|
|
1541
1547
|
enforceCurrentMaxLength: () => {
|
|
1542
1548
|
t.maxLength === void 0 || t.maxLength < 0 || e.update(() => {
|
|
1543
1549
|
const u = F().getTextContent().length - (t.maxLength ?? 0);
|
|
@@ -1550,21 +1556,21 @@ const ia = (e) => {
|
|
|
1550
1556
|
},
|
|
1551
1557
|
syncAfterEditorUpdate() {
|
|
1552
1558
|
const u = T();
|
|
1553
|
-
if (y(
|
|
1559
|
+
if (y(v(u))) {
|
|
1554
1560
|
o();
|
|
1555
1561
|
return;
|
|
1556
1562
|
}
|
|
1557
1563
|
o(), b(u);
|
|
1558
1564
|
}
|
|
1559
1565
|
};
|
|
1560
|
-
}, He = "data-language", Dn = "纯文本",
|
|
1566
|
+
}, He = "data-language", Dn = "纯文本", rs = "language", os = /* @__PURE__ */ new Set(["plain", "plaintext", "text", "txt"]), as = new Set(To().map(([e]) => e)), ss = [
|
|
1561
1567
|
He,
|
|
1562
1568
|
"data-lang",
|
|
1563
1569
|
"data-code-language",
|
|
1564
1570
|
"data-highlight-language",
|
|
1565
1571
|
"lang",
|
|
1566
1572
|
"language"
|
|
1567
|
-
],
|
|
1573
|
+
], is = /^[a-z][a-z0-9_+#.-]{0,31}$/i, ls = /^(?:language|lang)-([a-z][a-z0-9_+#.-]{0,31})$/i, cs = /^brush:\s*([a-z][a-z0-9_+#.-]{0,31})$/i, ds = /* @__PURE__ */ new Map([
|
|
1568
1574
|
["dockerfile", "docker"],
|
|
1569
1575
|
["shell", "shellscript"],
|
|
1570
1576
|
["sh", "shellscript"],
|
|
@@ -1577,23 +1583,23 @@ const ia = (e) => {
|
|
|
1577
1583
|
["ts", "typescript"],
|
|
1578
1584
|
["tsx", "tsx"],
|
|
1579
1585
|
["yml", "yaml"]
|
|
1580
|
-
]),
|
|
1586
|
+
]), us = (e) => e.type === "select", It = (e) => e.find((t) => t.name === rs && us(t)), ne = (e) => {
|
|
1581
1587
|
const t = e == null ? void 0 : e.trim().toLowerCase();
|
|
1582
|
-
if (!t || !
|
|
1583
|
-
if (
|
|
1584
|
-
const n =
|
|
1585
|
-
return
|
|
1586
|
-
},
|
|
1587
|
-
for (const t of
|
|
1588
|
+
if (!t || !is.test(t)) return null;
|
|
1589
|
+
if (os.has(t)) return "";
|
|
1590
|
+
const n = ds.get(t) ?? Mo(t);
|
|
1591
|
+
return as.has(n) ? n : null;
|
|
1592
|
+
}, ms = (e) => {
|
|
1593
|
+
for (const t of ss) {
|
|
1588
1594
|
const n = ne(e.getAttribute(t));
|
|
1589
1595
|
if (n) return n;
|
|
1590
1596
|
}
|
|
1591
1597
|
return null;
|
|
1592
|
-
},
|
|
1593
|
-
const [, t] = e.match(
|
|
1598
|
+
}, gs = (e) => {
|
|
1599
|
+
const [, t] = e.match(cs) ?? [], n = ne(t);
|
|
1594
1600
|
if (n) return n;
|
|
1595
1601
|
for (const r of e.split(/\s+/)) {
|
|
1596
|
-
const [, o] = r.match(
|
|
1602
|
+
const [, o] = r.match(ls) ?? [], a = ne(o);
|
|
1597
1603
|
if (a) return a;
|
|
1598
1604
|
}
|
|
1599
1605
|
return null;
|
|
@@ -1605,18 +1611,18 @@ const ia = (e) => {
|
|
|
1605
1611
|
return ((n = e.find((a) => a.value === t)) == null ? void 0 : n.label) ?? ((r = e.find((a) => ne(a.value) === ne(t))) == null ? void 0 : r.label) ?? ((o = e[0]) == null ? void 0 : o.label) ?? Dn;
|
|
1606
1612
|
};
|
|
1607
1613
|
Hn();
|
|
1608
|
-
const
|
|
1614
|
+
const hs = (e) => {
|
|
1609
1615
|
[...e.querySelectorAll("pre,code")].forEach((t) => {
|
|
1610
|
-
const n =
|
|
1616
|
+
const n = ms(t) ?? gs(t.className), r = t.tagName === "PRE" ? t : t.closest("pre");
|
|
1611
1617
|
r && n && r.setAttribute(He, n);
|
|
1612
1618
|
});
|
|
1613
|
-
},
|
|
1619
|
+
}, ps = (e) => {
|
|
1614
1620
|
e.querySelectorAll("pre").forEach((t) => {
|
|
1615
1621
|
[...t.children].forEach((r) => {
|
|
1616
1622
|
r.tagName === "CODE" && r.replaceWith(...r.childNodes);
|
|
1617
1623
|
});
|
|
1618
1624
|
});
|
|
1619
|
-
},
|
|
1625
|
+
}, fs = (e, t) => {
|
|
1620
1626
|
const n = [...t.querySelectorAll("pre[data-language]")];
|
|
1621
1627
|
let r = 0;
|
|
1622
1628
|
e.forEach((o) => {
|
|
@@ -1634,7 +1640,7 @@ const gs = (e) => {
|
|
|
1634
1640
|
property: "#e45649",
|
|
1635
1641
|
string: "#50a14f",
|
|
1636
1642
|
attrName: "#986801"
|
|
1637
|
-
},
|
|
1643
|
+
}, bs = {
|
|
1638
1644
|
[Q.keyword]: "keyword",
|
|
1639
1645
|
[Q.function]: "function",
|
|
1640
1646
|
[Q.operator]: "operator",
|
|
@@ -1642,10 +1648,10 @@ const gs = (e) => {
|
|
|
1642
1648
|
[Q.property]: "property",
|
|
1643
1649
|
[Q.string]: "string",
|
|
1644
1650
|
[Q.attrName]: "attr-name"
|
|
1645
|
-
},
|
|
1651
|
+
}, ys = (e) => {
|
|
1646
1652
|
const [, t] = e.match(/(?:^|;)color:\s*(#[0-9a-f]{3,8})/i) ?? [];
|
|
1647
|
-
return t ?
|
|
1648
|
-
},
|
|
1653
|
+
return t ? bs[t.toLowerCase()] : void 0;
|
|
1654
|
+
}, vs = {
|
|
1649
1655
|
...wt,
|
|
1650
1656
|
defaultLanguage: null,
|
|
1651
1657
|
defaultTheme: $n,
|
|
@@ -1653,14 +1659,14 @@ const gs = (e) => {
|
|
|
1653
1659
|
const n = wt.$tokenize.call(this, e, t);
|
|
1654
1660
|
return e.getStyle() && e.setStyle(""), n.map((r) => zr(r) ? Vr(
|
|
1655
1661
|
r.getTextContent(),
|
|
1656
|
-
|
|
1662
|
+
ys(r.getStyle())
|
|
1657
1663
|
) : r);
|
|
1658
1664
|
}
|
|
1659
|
-
},
|
|
1660
|
-
let Z = 0, ae = null, ke = !1,
|
|
1661
|
-
const
|
|
1665
|
+
}, ws = 1200, fe = /* @__PURE__ */ new Set(), Ne = /* @__PURE__ */ new Set(), Je = /* @__PURE__ */ new Set(), Pe = [];
|
|
1666
|
+
let Z = 0, ae = null, ke = !1, xe = null, Rt = !1;
|
|
1667
|
+
const Cs = (e) => "requestIdleCallback" in window ? {
|
|
1662
1668
|
id: window.requestIdleCallback(e, {
|
|
1663
|
-
timeout:
|
|
1669
|
+
timeout: ws
|
|
1664
1670
|
}),
|
|
1665
1671
|
kind: "idle"
|
|
1666
1672
|
} : {
|
|
@@ -1671,15 +1677,15 @@ const ws = (e) => "requestIdleCallback" in window ? {
|
|
|
1671
1677
|
});
|
|
1672
1678
|
}, 0),
|
|
1673
1679
|
kind: "timeout"
|
|
1674
|
-
},
|
|
1680
|
+
}, _s = (e) => {
|
|
1675
1681
|
if (e.kind === "idle") {
|
|
1676
1682
|
window.cancelIdleCallback(e.id);
|
|
1677
1683
|
return;
|
|
1678
1684
|
}
|
|
1679
1685
|
globalThis.clearTimeout(e.id);
|
|
1680
|
-
},
|
|
1681
|
-
|
|
1682
|
-
if (fe.has(t) || Ne.has(t) || Je.has(t) ||
|
|
1686
|
+
}, ks = (e) => e.map((t) => t.value).filter((t) => t !== ""), xs = (e) => {
|
|
1687
|
+
ks(e).forEach((t) => {
|
|
1688
|
+
if (fe.has(t) || Ne.has(t) || Je.has(t) || xn(t)) {
|
|
1683
1689
|
fe.add(t);
|
|
1684
1690
|
return;
|
|
1685
1691
|
}
|
|
@@ -1689,33 +1695,33 @@ const ws = (e) => "requestIdleCallback" in window ? {
|
|
|
1689
1695
|
for (; Pe.length > 0; ) {
|
|
1690
1696
|
const e = Pe.shift();
|
|
1691
1697
|
if (e && (Je.delete(e), !(fe.has(e) || Ne.has(e)))) {
|
|
1692
|
-
if (
|
|
1698
|
+
if (xn(e)) {
|
|
1693
1699
|
fe.add(e);
|
|
1694
1700
|
continue;
|
|
1695
1701
|
}
|
|
1696
1702
|
return e;
|
|
1697
1703
|
}
|
|
1698
1704
|
}
|
|
1699
|
-
},
|
|
1705
|
+
}, Ms = async () => {
|
|
1700
1706
|
if (!Rt) {
|
|
1701
|
-
if (!
|
|
1707
|
+
if (!xe) {
|
|
1702
1708
|
const e = So($n);
|
|
1703
|
-
|
|
1709
|
+
xe = Promise.resolve(e ?? void 0).then(() => {
|
|
1704
1710
|
Rt = !0;
|
|
1705
1711
|
}).catch(() => {
|
|
1706
1712
|
}).finally(() => {
|
|
1707
|
-
|
|
1713
|
+
xe = null;
|
|
1708
1714
|
});
|
|
1709
1715
|
}
|
|
1710
|
-
await
|
|
1716
|
+
await xe;
|
|
1711
1717
|
}
|
|
1712
|
-
},
|
|
1713
|
-
Z += 1,
|
|
1718
|
+
}, Ts = (e) => {
|
|
1719
|
+
Z += 1, xs(e);
|
|
1714
1720
|
const t = async () => {
|
|
1715
1721
|
if (!(Z <= 0 || ke)) {
|
|
1716
1722
|
ke = !0;
|
|
1717
1723
|
try {
|
|
1718
|
-
if (await
|
|
1724
|
+
if (await Ms(), Z <= 0) return;
|
|
1719
1725
|
const r = Es();
|
|
1720
1726
|
if (!r) return;
|
|
1721
1727
|
Ne.add(r), await Promise.resolve(Lo(r) ?? void 0).then(() => {
|
|
@@ -1729,14 +1735,14 @@ const ws = (e) => "requestIdleCallback" in window ? {
|
|
|
1729
1735
|
}
|
|
1730
1736
|
}
|
|
1731
1737
|
}, n = () => {
|
|
1732
|
-
Z <= 0 || ae !== null || ke || Pe.length === 0 || (ae =
|
|
1738
|
+
Z <= 0 || ae !== null || ke || Pe.length === 0 || (ae = Cs(() => {
|
|
1733
1739
|
ae = null, t();
|
|
1734
1740
|
}));
|
|
1735
1741
|
};
|
|
1736
1742
|
return n(), () => {
|
|
1737
|
-
Z = Math.max(0, Z - 1), Z === 0 && ae !== null && (
|
|
1743
|
+
Z = Math.max(0, Z - 1), Z === 0 && ae !== null && (_s(ae), ae = null);
|
|
1738
1744
|
};
|
|
1739
|
-
}, V = 12,
|
|
1745
|
+
}, V = 12, Ls = 6, Ie = (e, t, n) => Math.min(Math.max(e, t), Math.max(t, n)), Fn = () => {
|
|
1740
1746
|
const e = window.visualViewport;
|
|
1741
1747
|
return {
|
|
1742
1748
|
left: (e == null ? void 0 : e.offsetLeft) ?? 0,
|
|
@@ -1744,7 +1750,7 @@ const ws = (e) => "requestIdleCallback" in window ? {
|
|
|
1744
1750
|
width: (e == null ? void 0 : e.width) ?? window.innerWidth,
|
|
1745
1751
|
height: (e == null ? void 0 : e.height) ?? window.innerHeight
|
|
1746
1752
|
};
|
|
1747
|
-
},
|
|
1753
|
+
}, Ss = (e, t) => ({
|
|
1748
1754
|
/*
|
|
1749
1755
|
* dialog request 里传的是 viewport 坐标。用 virtual reference 交给 floating-ui,
|
|
1750
1756
|
* 让 dialog 和 toolbar group、hoverbar 等轻浮层复用同一套翻转和边界避让逻辑。
|
|
@@ -1760,70 +1766,70 @@ const ws = (e) => "requestIdleCallback" in window ? {
|
|
|
1760
1766
|
width: t.width,
|
|
1761
1767
|
height: t.height
|
|
1762
1768
|
})
|
|
1763
|
-
}),
|
|
1764
|
-
const n = e.getBoundingClientRect(), r = Fn(), o = t.getBoundingClientRect(), a = o.left + V, s = o.top + V,
|
|
1769
|
+
}), Ns = (e, t) => {
|
|
1770
|
+
const n = e.getBoundingClientRect(), r = Fn(), o = t.getBoundingClientRect(), a = o.left + V, s = o.top + V, i = r.left + V, d = r.top + V, l = r.left + r.width - n.width - V, g = r.top + r.height - n.height - V;
|
|
1765
1771
|
return {
|
|
1766
|
-
left: Ie(a,
|
|
1772
|
+
left: Ie(a, i, l),
|
|
1767
1773
|
top: Ie(s, d, g),
|
|
1768
1774
|
viewportHeight: r.height
|
|
1769
1775
|
};
|
|
1770
|
-
},
|
|
1771
|
-
const r = e.getBoundingClientRect(), o = Fn(), a = o.left + V, s = o.top + V,
|
|
1776
|
+
}, Ps = (e, t, n) => {
|
|
1777
|
+
const r = e.getBoundingClientRect(), o = Fn(), a = o.left + V, s = o.top + V, i = o.left + o.width - r.width - V, d = o.top + o.height - r.height - V;
|
|
1772
1778
|
return {
|
|
1773
|
-
left: Ie(t, a,
|
|
1779
|
+
left: Ie(t, a, i),
|
|
1774
1780
|
top: Ie(n, s, d),
|
|
1775
1781
|
viewportHeight: o.height
|
|
1776
1782
|
};
|
|
1777
1783
|
}, zn = (e) => {
|
|
1778
|
-
var
|
|
1784
|
+
var l, g;
|
|
1779
1785
|
const t = document.createElement("div"), n = document.createElement("div"), r = document.createElement("div");
|
|
1780
1786
|
let o;
|
|
1781
1787
|
const a = () => {
|
|
1782
1788
|
t.dataset.visible = "false", n.dataset.visible = "false", o = void 0;
|
|
1783
|
-
}, s = (
|
|
1784
|
-
n.style.left = `${
|
|
1789
|
+
}, s = (f, b, T) => {
|
|
1790
|
+
n.style.left = `${f}px`, n.style.top = `${b}px`, n.style.setProperty(
|
|
1785
1791
|
"--bridgerte-dialog-visible-height",
|
|
1786
1792
|
`${T}px`
|
|
1787
1793
|
);
|
|
1788
|
-
},
|
|
1794
|
+
}, i = async () => {
|
|
1789
1795
|
if (!o) {
|
|
1790
|
-
const T =
|
|
1796
|
+
const T = Ns(n, e.root);
|
|
1791
1797
|
s(T.left, T.top, T.viewportHeight);
|
|
1792
1798
|
return;
|
|
1793
1799
|
}
|
|
1794
|
-
const
|
|
1795
|
-
|
|
1800
|
+
const f = await vn(
|
|
1801
|
+
Ss(e.root, o),
|
|
1796
1802
|
n,
|
|
1797
1803
|
{
|
|
1798
1804
|
placement: "bottom-start",
|
|
1799
1805
|
strategy: "fixed",
|
|
1800
1806
|
platform: wn,
|
|
1801
1807
|
middleware: [
|
|
1802
|
-
Cn(
|
|
1808
|
+
Cn(Ls),
|
|
1803
1809
|
_n(),
|
|
1804
1810
|
kn({ padding: V })
|
|
1805
1811
|
]
|
|
1806
1812
|
}
|
|
1807
|
-
), b =
|
|
1813
|
+
), b = Ps(n, f.x, f.y);
|
|
1808
1814
|
s(
|
|
1809
1815
|
b.left,
|
|
1810
1816
|
b.top,
|
|
1811
1817
|
b.viewportHeight
|
|
1812
1818
|
);
|
|
1813
|
-
}, d = (
|
|
1814
|
-
o =
|
|
1819
|
+
}, d = (f) => {
|
|
1820
|
+
o = f, f ? n.style.setProperty("--bridgerte-dialog-anchor-width", `${f.width}px`) : n.style.removeProperty("--bridgerte-dialog-anchor-width"), i(), t.dataset.visible = "true", n.dataset.visible = "true";
|
|
1815
1821
|
};
|
|
1816
1822
|
return t.className = "bridgerte__dialog-backdrop", t.dataset.visible = "false", n.className = `bridgerte__dialog ${e.className}`, n.dataset.visible = "false", r.className = "bridgerte__dialog-content", n.append(r), e.root.append(t, n), t.addEventListener("click", () => {
|
|
1817
|
-
var
|
|
1818
|
-
(
|
|
1819
|
-
}), (
|
|
1823
|
+
var f;
|
|
1824
|
+
(f = e.onBackdropClick) == null || f.call(e), a();
|
|
1825
|
+
}), (l = window.visualViewport) == null || l.addEventListener("resize", i), (g = window.visualViewport) == null || g.addEventListener("scroll", i), window.addEventListener("resize", i), {
|
|
1820
1826
|
element: n,
|
|
1821
1827
|
content: r,
|
|
1822
1828
|
open: d,
|
|
1823
1829
|
close: a,
|
|
1824
1830
|
destroy() {
|
|
1825
|
-
var
|
|
1826
|
-
a(), (
|
|
1831
|
+
var f, b;
|
|
1832
|
+
a(), (f = window.visualViewport) == null || f.removeEventListener("resize", i), (b = window.visualViewport) == null || b.removeEventListener("scroll", i), window.removeEventListener("resize", i), t.remove(), n.remove();
|
|
1827
1833
|
}
|
|
1828
1834
|
};
|
|
1829
1835
|
}, Re = (e) => typeof requestAnimationFrame == "function" ? requestAnimationFrame(e) : window.setTimeout(e, 0), lt = (e) => {
|
|
@@ -1835,18 +1841,18 @@ const ws = (e) => "requestIdleCallback" in window ? {
|
|
|
1835
1841
|
}, U = (e, t = {}) => {
|
|
1836
1842
|
let n = null;
|
|
1837
1843
|
const r = (s) => {
|
|
1838
|
-
const
|
|
1844
|
+
const i = n ?? e;
|
|
1839
1845
|
if (!(!s && !n)) {
|
|
1840
1846
|
if (s) {
|
|
1841
|
-
|
|
1847
|
+
i.dataset.pressed = "true";
|
|
1842
1848
|
return;
|
|
1843
1849
|
}
|
|
1844
|
-
delete
|
|
1850
|
+
delete i.dataset.pressed, n = null;
|
|
1845
1851
|
}
|
|
1846
1852
|
}, o = (s) => {
|
|
1847
1853
|
if (s.pointerType === "mouse") return;
|
|
1848
|
-
const
|
|
1849
|
-
n =
|
|
1854
|
+
const i = s.target;
|
|
1855
|
+
n = i instanceof HTMLElement && t.targetSelector ? i.closest(t.targetSelector) : e, n && r(!0);
|
|
1850
1856
|
}, a = () => {
|
|
1851
1857
|
r(!1);
|
|
1852
1858
|
};
|
|
@@ -1873,7 +1879,7 @@ const ws = (e) => "requestIdleCallback" in window ? {
|
|
|
1873
1879
|
e.content.removeEventListener("pointerdown", t), e.content.removeEventListener("focusin", n), document.removeEventListener("pointerdown", r);
|
|
1874
1880
|
}
|
|
1875
1881
|
};
|
|
1876
|
-
},
|
|
1882
|
+
}, Is = (e, t, n) => {
|
|
1877
1883
|
e.update(
|
|
1878
1884
|
t,
|
|
1879
1885
|
{
|
|
@@ -1881,41 +1887,41 @@ const ws = (e) => "requestIdleCallback" in window ? {
|
|
|
1881
1887
|
onUpdate: n
|
|
1882
1888
|
}
|
|
1883
1889
|
);
|
|
1884
|
-
}, At = "language",
|
|
1890
|
+
}, At = "language", Rs = "bridgerte-code-block-language", Bt = 8, As = ".bridgerte__code-block-controls", Le = ".bridgerte__code-block-control-button";
|
|
1885
1891
|
let Dt = 0;
|
|
1886
|
-
const
|
|
1892
|
+
const Bs = () => (Dt += 1, `${Rs}-${Dt}`), Ds = (e, t, n) => {
|
|
1887
1893
|
var o;
|
|
1888
1894
|
const r = e.querySelector(".bridgerte__code-block-control-label");
|
|
1889
1895
|
e.dataset.language = n ?? "", (o = e.querySelector(Le)) == null || o.setAttribute(
|
|
1890
1896
|
"data-language",
|
|
1891
1897
|
n ?? ""
|
|
1892
1898
|
), r && (r.textContent = On(t, n));
|
|
1893
|
-
},
|
|
1899
|
+
}, Hs = (e, t) => {
|
|
1894
1900
|
const n = document.createElement("div"), r = document.createElement("button"), o = document.createElement("span"), a = document.createElement("span");
|
|
1895
1901
|
return n.className = "bridgerte__code-block-controls", n.contentEditable = "false", n.dataset.language = t ?? "", n.setAttribute("aria-label", "代码块操作"), r.type = "button", r.className = "bridgerte__code-block-control-button", r.dataset.language = t ?? "", r.setAttribute("aria-label", "选择代码块语言"), o.className = "bridgerte__code-block-control-label", o.textContent = On(e, t), a.className = "bridgerte__code-block-control-arrow", r.append(o, a), n.append(r), n;
|
|
1896
|
-
},
|
|
1902
|
+
}, Os = (e) => {
|
|
1897
1903
|
const t = document.createElement("div"), n = e.root.querySelector(".bridgerte__content") ?? e.root, r = yn(
|
|
1898
1904
|
e.languagePanel ?? Xe,
|
|
1899
1905
|
e.payloadPanelConfig
|
|
1900
1906
|
), o = Hn(r);
|
|
1901
|
-
let a = null, s = null,
|
|
1902
|
-
const
|
|
1903
|
-
|
|
1907
|
+
let a = null, s = null, i = null, d = null, l = null, g = null;
|
|
1908
|
+
const f = () => {
|
|
1909
|
+
i ?? (i = Ts(o));
|
|
1904
1910
|
}, b = () => {
|
|
1905
1911
|
a == null || a.close();
|
|
1906
1912
|
}, T = (M, L) => {
|
|
1907
|
-
e.isReadonly() ||
|
|
1913
|
+
e.isReadonly() || Is(e.editor, () => {
|
|
1908
1914
|
const N = he(M);
|
|
1909
1915
|
X(N) && N.setLanguage(L);
|
|
1910
1916
|
});
|
|
1911
|
-
},
|
|
1917
|
+
}, v = (M, L) => {
|
|
1912
1918
|
Re(() => {
|
|
1913
1919
|
T(M, L);
|
|
1914
1920
|
});
|
|
1915
1921
|
}, y = (M, L, N) => {
|
|
1916
1922
|
var R;
|
|
1917
1923
|
return ((R = e.onRequest) == null ? void 0 : R.call(e, {
|
|
1918
|
-
id:
|
|
1924
|
+
id: Bs(),
|
|
1919
1925
|
readonly: e.isReadonly(),
|
|
1920
1926
|
menuId: "code-block-language",
|
|
1921
1927
|
command: { type: "block.setCodeLanguage", language: N },
|
|
@@ -1930,7 +1936,7 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
1930
1936
|
[At]: N
|
|
1931
1937
|
},
|
|
1932
1938
|
submit: (S) => {
|
|
1933
|
-
b(),
|
|
1939
|
+
b(), v(M, S[At] ?? "");
|
|
1934
1940
|
},
|
|
1935
1941
|
cancel: b
|
|
1936
1942
|
})) === !0;
|
|
@@ -1946,23 +1952,23 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
1946
1952
|
);
|
|
1947
1953
|
M.style.transform = `translate(${A}px, ${$}px)`;
|
|
1948
1954
|
}, u = () => {
|
|
1949
|
-
|
|
1955
|
+
l && (g == null || g(), g = null, l.remove(), l = null);
|
|
1950
1956
|
}, p = (M) => {
|
|
1951
1957
|
const L = e.editor.getElementByKey(M);
|
|
1952
1958
|
if (!L) {
|
|
1953
1959
|
d === M && (d = null, u());
|
|
1954
1960
|
return;
|
|
1955
1961
|
}
|
|
1956
|
-
|
|
1962
|
+
f(), L.dataset.lexicalKey = M;
|
|
1957
1963
|
const N = L.getAttribute("data-language");
|
|
1958
|
-
if (
|
|
1959
|
-
|
|
1964
|
+
if (l) {
|
|
1965
|
+
Ds(l, o, N), x(l, L);
|
|
1960
1966
|
return;
|
|
1961
1967
|
}
|
|
1962
|
-
const R =
|
|
1968
|
+
const R = Hs(o, N);
|
|
1963
1969
|
g = U(R, {
|
|
1964
1970
|
targetSelector: Le
|
|
1965
|
-
}), R.dataset.lexicalKey = M,
|
|
1971
|
+
}), R.dataset.lexicalKey = M, l = R, t.append(R), x(R, L);
|
|
1966
1972
|
}, E = (M) => {
|
|
1967
1973
|
const L = M.dataset.lexicalKey;
|
|
1968
1974
|
!L || d === L || (d !== null && (b(), u()), d = L, p(L));
|
|
@@ -1992,7 +1998,7 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
1992
1998
|
A.type = "button", A.className = "bridgerte__menu-item bridgerte__code-block-menu-item", A.textContent = k.label, U(A), A.addEventListener("pointerdown", ($) => {
|
|
1993
1999
|
$.preventDefault();
|
|
1994
2000
|
}), A.addEventListener("click", () => {
|
|
1995
|
-
b(),
|
|
2001
|
+
b(), v(L, k.value);
|
|
1996
2002
|
}), S.append(A);
|
|
1997
2003
|
}), a.content.append(S), a.open({
|
|
1998
2004
|
x: N.left,
|
|
@@ -2005,14 +2011,14 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2005
2011
|
if (!(L instanceof HTMLElement)) return;
|
|
2006
2012
|
const N = L.closest(Le);
|
|
2007
2013
|
if (!N) return;
|
|
2008
|
-
const R = N.closest(
|
|
2014
|
+
const R = N.closest(As);
|
|
2009
2015
|
if (!R) return;
|
|
2010
2016
|
const S = R.dataset.lexicalKey;
|
|
2011
2017
|
S && (M.preventDefault(), M.stopPropagation(), I(R, S));
|
|
2012
2018
|
}, c = (M) => {
|
|
2013
2019
|
const L = M.target;
|
|
2014
2020
|
L instanceof HTMLElement && L.closest(Le) && M.preventDefault();
|
|
2015
|
-
},
|
|
2021
|
+
}, m = (M) => {
|
|
2016
2022
|
const L = M.target;
|
|
2017
2023
|
if (!(L instanceof HTMLElement)) return;
|
|
2018
2024
|
if (!L.closest(".bridgerte__code-block")) {
|
|
@@ -2026,7 +2032,7 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2026
2032
|
const S = he(R);
|
|
2027
2033
|
X(S) && S.selectEnd();
|
|
2028
2034
|
}), e.editor.focus());
|
|
2029
|
-
},
|
|
2035
|
+
}, h = () => {
|
|
2030
2036
|
s === null && (s = Re(() => {
|
|
2031
2037
|
s = null, d !== null && p(d);
|
|
2032
2038
|
}));
|
|
@@ -2041,13 +2047,13 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2041
2047
|
return;
|
|
2042
2048
|
}
|
|
2043
2049
|
const R = e.editor.getElementByKey(N);
|
|
2044
|
-
R && (R.dataset.lexicalKey = N), d === N &&
|
|
2050
|
+
R && (R.dataset.lexicalKey = N), d === N && l && p(N);
|
|
2045
2051
|
});
|
|
2046
2052
|
}
|
|
2047
|
-
), P = e.editor.registerUpdateListener(
|
|
2048
|
-
return t.addEventListener("pointerdown", c), t.addEventListener("click", w), n.addEventListener("pointerdown",
|
|
2053
|
+
), P = e.editor.registerUpdateListener(h);
|
|
2054
|
+
return t.addEventListener("pointerdown", c), t.addEventListener("click", w), n.addEventListener("pointerdown", m), n.addEventListener("scroll", h, { passive: !0 }), window.addEventListener("resize", h), {
|
|
2049
2055
|
destroy() {
|
|
2050
|
-
H.destroy(), C(), P(),
|
|
2056
|
+
H.destroy(), C(), P(), i == null || i(), i = null, s !== null && (lt(s), s = null), t.removeEventListener("pointerdown", c), t.removeEventListener("click", w), n.removeEventListener("pointerdown", m), n.removeEventListener("scroll", h), window.removeEventListener("resize", h), u(), t.remove(), a == null || a.destroy(), a = null;
|
|
2051
2057
|
}
|
|
2052
2058
|
};
|
|
2053
2059
|
}, dt = (e, t = {}) => e.map((n) => {
|
|
@@ -2058,10 +2064,10 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2058
2064
|
...r === void 0 ? {} : { label: r },
|
|
2059
2065
|
...o === void 0 ? {} : { payloadPanel: o }
|
|
2060
2066
|
};
|
|
2061
|
-
}),
|
|
2067
|
+
}), $s = (e, t) => {
|
|
2062
2068
|
const n = t.find((r) => r.command === e.command.type);
|
|
2063
2069
|
return (n == null ? void 0 : n.value) === void 0 ? void 0 : { value: String(n.value) };
|
|
2064
|
-
},
|
|
2070
|
+
}, Fs = (e, t) => {
|
|
2065
2071
|
const n = t.find((o) => ko(e.command, o)), r = t.find((o) => o.command === e.command.type);
|
|
2066
2072
|
return {
|
|
2067
2073
|
active: (n == null ? void 0 : n.active) === !0,
|
|
@@ -2071,7 +2077,7 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2071
2077
|
"media-resize-20",
|
|
2072
2078
|
"media-resize-50",
|
|
2073
2079
|
"media-resize-100"
|
|
2074
|
-
],
|
|
2080
|
+
], zs = [
|
|
2075
2081
|
"media-align-left",
|
|
2076
2082
|
"media-align-center",
|
|
2077
2083
|
"media-align-right",
|
|
@@ -2079,11 +2085,11 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2079
2085
|
...be,
|
|
2080
2086
|
"|",
|
|
2081
2087
|
"media-remove"
|
|
2082
|
-
],
|
|
2088
|
+
], Vs = [
|
|
2083
2089
|
"media-retry",
|
|
2084
2090
|
"|",
|
|
2085
2091
|
"media-remove"
|
|
2086
|
-
],
|
|
2092
|
+
], Ws = [
|
|
2087
2093
|
{
|
|
2088
2094
|
id: "media-align-left",
|
|
2089
2095
|
command: { type: "media.align", assetId: "", value: "left" },
|
|
@@ -2132,7 +2138,7 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2132
2138
|
label: "删除",
|
|
2133
2139
|
icon: "trash-2"
|
|
2134
2140
|
}
|
|
2135
|
-
], Vn = (e) => be.includes(e),
|
|
2141
|
+
], Vn = (e) => be.includes(e), Us = (e) => typeof e == "object" && Array.isArray(e.menuKeys), js = (e) => new Set(e.flatMap((t) => t === "|" ? [] : typeof t == "string" ? [t] : Us(t) ? [t.key, ...t.menuKeys] : [])), Ve = (e) => typeof e == "string" && Vn(e), Ks = (e) => {
|
|
2136
2142
|
const t = e.findIndex((r) => r === "media-remove"), n = t === -1 ? e.length : t;
|
|
2137
2143
|
return [
|
|
2138
2144
|
...e.slice(0, n),
|
|
@@ -2141,24 +2147,24 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2141
2147
|
"|",
|
|
2142
2148
|
...e.slice(n)
|
|
2143
2149
|
];
|
|
2144
|
-
},
|
|
2145
|
-
const t =
|
|
2150
|
+
}, qs = (e) => {
|
|
2151
|
+
const t = js(e);
|
|
2146
2152
|
if (be.filter((o) => !t.has(o)).length === 0) return e;
|
|
2147
2153
|
const r = e.findIndex(Ve);
|
|
2148
|
-
return r === -1 ?
|
|
2154
|
+
return r === -1 ? Ks(e) : [
|
|
2149
2155
|
...e.slice(0, r).filter((o) => !Ve(o)),
|
|
2150
2156
|
...be,
|
|
2151
2157
|
...e.slice(r + 1).filter((o) => !Ve(o))
|
|
2152
2158
|
];
|
|
2153
|
-
},
|
|
2159
|
+
}, Gs = (e) => {
|
|
2154
2160
|
var r;
|
|
2155
|
-
const t = (e == null ? void 0 : e.toolbarKeys) ??
|
|
2161
|
+
const t = (e == null ? void 0 : e.toolbarKeys) ?? zs;
|
|
2156
2162
|
return {
|
|
2157
2163
|
...e,
|
|
2158
|
-
toolbarKeys:
|
|
2164
|
+
toolbarKeys: qs(t),
|
|
2159
2165
|
excludeKeys: (r = e == null ? void 0 : e.excludeKeys) == null ? void 0 : r.filter((o) => !Vn(o))
|
|
2160
2166
|
};
|
|
2161
|
-
},
|
|
2167
|
+
}, Xs = (e, t) => {
|
|
2162
2168
|
switch (e.command.type) {
|
|
2163
2169
|
case "media.retry":
|
|
2164
2170
|
return { ...e.command, assetId: t };
|
|
@@ -2171,165 +2177,165 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2171
2177
|
default:
|
|
2172
2178
|
return null;
|
|
2173
2179
|
}
|
|
2174
|
-
},
|
|
2175
|
-
const n = dt(
|
|
2180
|
+
}, Ys = (e, t, n) => e.command.type === "media.resize" ? e.command.widthPercent === t : e.command.type === "media.align" && e.command.value === n, Wn = (e, t = {}) => {
|
|
2181
|
+
const n = dt(Ws, {
|
|
2176
2182
|
menuLabels: t.menuLabels
|
|
2177
|
-
}), r = e === "error" ? { toolbarKeys:
|
|
2183
|
+
}), r = e === "error" ? { toolbarKeys: Vs } : Gs(t.config);
|
|
2178
2184
|
return ot(r, n);
|
|
2179
|
-
}, se = 8, de = "bridgerte__media-controls-button",
|
|
2185
|
+
}, se = 8, de = "bridgerte__media-controls-button", Js = (e) => e.querySelector(".bridgerte__content") ?? e, Qs = (e) => e instanceof Element ? e.closest(".bridgerte__media") : null, Zs = (e, t = !1) => {
|
|
2180
2186
|
const n = document.createElement("button");
|
|
2181
2187
|
return n.type = "button", n.className = de, n.textContent = e.label, n.dataset.menuItemId = e.id, n.dataset.action = e.id.replace(/^media-/, ""), t && (n.dataset.active = "true"), n.setAttribute("aria-label", e.label), n;
|
|
2182
|
-
}, Un = (e) => e.flatMap((t) => t.type === "button" ? [t.item] : t.type === "group" ? t.items : []),
|
|
2188
|
+
}, Un = (e) => e.flatMap((t) => t.type === "button" ? [t.item] : t.type === "group" ? t.items : []), ei = (e, t, n, r) => {
|
|
2183
2189
|
if (t.type === "separator") {
|
|
2184
2190
|
const a = document.createElement("span");
|
|
2185
2191
|
a.className = "bridgerte__media-controls-separator", a.dataset.separatorId = t.key, a.setAttribute("aria-hidden", "true"), e.append(a);
|
|
2186
2192
|
return;
|
|
2187
2193
|
}
|
|
2188
2194
|
(t.type === "button" ? [t.item] : t.items).forEach((a) => {
|
|
2189
|
-
e.append(
|
|
2195
|
+
e.append(Zs(
|
|
2190
2196
|
a,
|
|
2191
|
-
|
|
2197
|
+
Ys(a, n, r)
|
|
2192
2198
|
));
|
|
2193
2199
|
});
|
|
2194
|
-
},
|
|
2200
|
+
}, ti = (e, t, n) => {
|
|
2195
2201
|
const r = document.createElement("div"), o = e.dataset.status, a = Number(
|
|
2196
2202
|
e.dataset.displayWidthPercent ?? t
|
|
2197
|
-
), s = e.dataset.align ?? "left",
|
|
2203
|
+
), s = e.dataset.align ?? "left", i = Wn(o, {
|
|
2198
2204
|
config: n.mediaControlsConfig,
|
|
2199
2205
|
menuLabels: n.menuLabels
|
|
2200
2206
|
});
|
|
2201
|
-
return r.className = "bridgerte__media-controls", r.contentEditable = "false", r.setAttribute("aria-label", "媒体操作"), r.dataset.status = o ?? "success", r.dataset.displayWidthPercent = e.dataset.displayWidthPercent ?? "", r.dataset.align = e.dataset.align ?? "", r.dataset.menuItemIds = Un(
|
|
2202
|
-
|
|
2207
|
+
return r.className = "bridgerte__media-controls", r.contentEditable = "false", r.setAttribute("aria-label", "媒体操作"), r.dataset.status = o ?? "success", r.dataset.displayWidthPercent = e.dataset.displayWidthPercent ?? "", r.dataset.align = e.dataset.align ?? "", r.dataset.menuItemIds = Un(i).map((d) => d.id).join("|"), i.forEach((d) => {
|
|
2208
|
+
ei(r, d, a, s);
|
|
2203
2209
|
}), r;
|
|
2204
|
-
},
|
|
2205
|
-
const t = document.createElement("div"), n =
|
|
2206
|
-
let s = null,
|
|
2210
|
+
}, ni = (e) => {
|
|
2211
|
+
const t = document.createElement("div"), n = Js(e.root), r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
2212
|
+
let s = null, i = null, d = !1, l = null;
|
|
2207
2213
|
const g = (c) => {
|
|
2208
|
-
var
|
|
2209
|
-
const
|
|
2210
|
-
|
|
2211
|
-
},
|
|
2212
|
-
const
|
|
2214
|
+
var h;
|
|
2215
|
+
const m = r.get(c);
|
|
2216
|
+
m && ((h = o.get(m)) == null || h(), o.delete(m), m.remove(), r.delete(c), l === c && (l = null));
|
|
2217
|
+
}, f = (c, m) => m.dataset.status === "error" || l === c, b = (c, m) => {
|
|
2218
|
+
const h = e.root.getBoundingClientRect(), C = m.getBoundingClientRect(), P = C.bottom < h.top || C.top > h.bottom, M = Math.max(
|
|
2213
2219
|
se,
|
|
2214
|
-
|
|
2220
|
+
h.width - c.offsetWidth - se
|
|
2215
2221
|
), L = Math.min(
|
|
2216
|
-
Math.max(C.left -
|
|
2222
|
+
Math.max(C.left - h.left + se, se),
|
|
2217
2223
|
M
|
|
2218
2224
|
), N = Math.max(
|
|
2219
2225
|
se,
|
|
2220
|
-
C.top -
|
|
2226
|
+
C.top - h.top - c.offsetHeight - se
|
|
2221
2227
|
);
|
|
2222
2228
|
c.hidden = P, c.style.transform = `translate(${L}px, ${N}px)`;
|
|
2223
2229
|
}, T = (c) => {
|
|
2224
|
-
const
|
|
2225
|
-
if (!
|
|
2230
|
+
const m = e.editor.getElementByKey(c);
|
|
2231
|
+
if (!m) {
|
|
2226
2232
|
g(c);
|
|
2227
2233
|
return;
|
|
2228
2234
|
}
|
|
2229
|
-
|
|
2230
|
-
const
|
|
2231
|
-
if (!
|
|
2235
|
+
m.dataset.lexicalKey = c, a.set(m, c);
|
|
2236
|
+
const h = r.get(c);
|
|
2237
|
+
if (!f(c, m)) {
|
|
2232
2238
|
g(c);
|
|
2233
2239
|
return;
|
|
2234
2240
|
}
|
|
2235
|
-
if (
|
|
2236
|
-
const M =
|
|
2237
|
-
if (M === L &&
|
|
2238
|
-
b(
|
|
2241
|
+
if (h) {
|
|
2242
|
+
const M = m.dataset.status === "error", L = h.querySelector('[data-action="retry"]') !== null, N = m.dataset.displayWidthPercent ?? "", R = m.dataset.align ?? "";
|
|
2243
|
+
if (M === L && h.dataset.displayWidthPercent === N && h.dataset.align === R) {
|
|
2244
|
+
b(h, m);
|
|
2239
2245
|
return;
|
|
2240
2246
|
}
|
|
2241
2247
|
g(c);
|
|
2242
2248
|
}
|
|
2243
|
-
const C =
|
|
2249
|
+
const C = ti(m, e.defaultWidthPercent, e), P = U(C, {
|
|
2244
2250
|
targetSelector: `.${de}`
|
|
2245
2251
|
});
|
|
2246
|
-
C.dataset.lexicalKey = c, C.dataset.assetId =
|
|
2247
|
-
},
|
|
2248
|
-
s = null, a.forEach((c,
|
|
2249
|
-
e.root.contains(
|
|
2252
|
+
C.dataset.lexicalKey = c, C.dataset.assetId = m.dataset.assetId, r.set(c, C), o.set(C, P), t.append(C), b(C, m);
|
|
2253
|
+
}, v = () => {
|
|
2254
|
+
s = null, a.forEach((c, m) => {
|
|
2255
|
+
e.root.contains(m) || (a.delete(m), g(c));
|
|
2250
2256
|
}), e.root.querySelectorAll(".bridgerte__media").forEach((c) => {
|
|
2251
|
-
const
|
|
2252
|
-
|
|
2253
|
-
}), r.forEach((c,
|
|
2254
|
-
T(
|
|
2255
|
-
}),
|
|
2257
|
+
const m = c.dataset.lexicalKey;
|
|
2258
|
+
m && (a.set(c, m), T(m));
|
|
2259
|
+
}), r.forEach((c, m) => {
|
|
2260
|
+
T(m);
|
|
2261
|
+
}), l !== null && T(l);
|
|
2256
2262
|
}, y = () => {
|
|
2257
|
-
s === null && (s = Re(
|
|
2258
|
-
}, x = (c,
|
|
2259
|
-
const
|
|
2263
|
+
s === null && (s = Re(v));
|
|
2264
|
+
}, x = (c, m) => {
|
|
2265
|
+
const h = m.dataset.assetId, C = Un(Wn(m.dataset.status, {
|
|
2260
2266
|
config: e.mediaControlsConfig,
|
|
2261
2267
|
menuLabels: e.menuLabels
|
|
2262
2268
|
})).find((M) => M.id === c.dataset.menuItemId);
|
|
2263
|
-
if (!
|
|
2264
|
-
const P =
|
|
2269
|
+
if (!h || !C) return;
|
|
2270
|
+
const P = Xs(C, h);
|
|
2265
2271
|
P && e.executeCommand(P);
|
|
2266
2272
|
}, u = (c) => {
|
|
2267
2273
|
if (!c) {
|
|
2268
|
-
const C =
|
|
2269
|
-
|
|
2274
|
+
const C = l;
|
|
2275
|
+
l = null, C !== null && T(C);
|
|
2270
2276
|
return;
|
|
2271
2277
|
}
|
|
2272
|
-
const
|
|
2273
|
-
if (!
|
|
2274
|
-
const
|
|
2275
|
-
|
|
2278
|
+
const m = c.dataset.lexicalKey ? c.dataset.lexicalKey : a.get(c) ?? null;
|
|
2279
|
+
if (!m || l === m) return;
|
|
2280
|
+
const h = l;
|
|
2281
|
+
l = m, h !== null && T(h), T(m);
|
|
2276
2282
|
}, p = (c) => {
|
|
2277
|
-
const
|
|
2278
|
-
if (!(
|
|
2279
|
-
const
|
|
2280
|
-
|
|
2283
|
+
const m = c.target;
|
|
2284
|
+
if (!(m instanceof HTMLElement)) return;
|
|
2285
|
+
const h = m.closest(`.${de}`);
|
|
2286
|
+
h && (c.preventDefault(), i = c.pointerType === "mouse" ? null : h);
|
|
2281
2287
|
}, E = (c) => {
|
|
2282
|
-
if (c.pointerType === "mouse" || !
|
|
2283
|
-
const
|
|
2284
|
-
C ===
|
|
2288
|
+
if (c.pointerType === "mouse" || !i) return;
|
|
2289
|
+
const m = c.target, h = m instanceof HTMLElement ? m.closest(".bridgerte__media-controls") : null, C = m instanceof HTMLElement ? m.closest(`.${de}`) : null;
|
|
2290
|
+
C === i && h && (c.preventDefault(), c.stopPropagation(), x(C, h), d = !0), i = null;
|
|
2285
2291
|
}, _ = () => {
|
|
2286
|
-
|
|
2292
|
+
i = null;
|
|
2287
2293
|
}, B = (c) => {
|
|
2288
2294
|
if (d) {
|
|
2289
2295
|
d = !1, c.preventDefault(), c.stopPropagation();
|
|
2290
2296
|
return;
|
|
2291
2297
|
}
|
|
2292
|
-
const
|
|
2293
|
-
if (!(
|
|
2294
|
-
const
|
|
2295
|
-
!
|
|
2298
|
+
const m = c.target;
|
|
2299
|
+
if (!(m instanceof HTMLElement)) return;
|
|
2300
|
+
const h = m.closest(`.${de}`), C = m.closest(".bridgerte__media-controls");
|
|
2301
|
+
!h || !C || (c.preventDefault(), c.stopPropagation(), x(h, C));
|
|
2296
2302
|
}, H = e.editor.registerMutationListener(
|
|
2297
2303
|
le,
|
|
2298
2304
|
(c) => {
|
|
2299
|
-
c.forEach((
|
|
2300
|
-
if (
|
|
2301
|
-
g(
|
|
2305
|
+
c.forEach((m, h) => {
|
|
2306
|
+
if (m === "destroyed") {
|
|
2307
|
+
g(h);
|
|
2302
2308
|
return;
|
|
2303
2309
|
}
|
|
2304
|
-
T(
|
|
2310
|
+
T(h);
|
|
2305
2311
|
});
|
|
2306
2312
|
}
|
|
2307
2313
|
), I = e.editor.registerUpdateListener(y), w = ct({
|
|
2308
2314
|
root: e.root,
|
|
2309
2315
|
content: n,
|
|
2310
|
-
getBlockFromTarget:
|
|
2316
|
+
getBlockFromTarget: Qs,
|
|
2311
2317
|
activateBlock: u,
|
|
2312
2318
|
clearBlock: () => u(null)
|
|
2313
2319
|
});
|
|
2314
2320
|
return t.className = "bridgerte__media-controls-layer", e.root.append(t), t.addEventListener("pointerdown", p), t.addEventListener("pointerup", E), t.addEventListener("pointercancel", _), t.addEventListener("click", B), n.addEventListener("scroll", y, { passive: !0 }), window.addEventListener("resize", y), {
|
|
2315
2321
|
destroy() {
|
|
2316
2322
|
H(), I(), s !== null && (lt(s), s = null), t.removeEventListener("pointerdown", p), t.removeEventListener("pointerup", E), t.removeEventListener("pointercancel", _), t.removeEventListener("click", B), w.destroy(), n.removeEventListener("scroll", y), window.removeEventListener("resize", y), r.forEach((c) => {
|
|
2317
|
-
var
|
|
2318
|
-
(
|
|
2323
|
+
var m;
|
|
2324
|
+
(m = o.get(c)) == null || m(), c.remove();
|
|
2319
2325
|
}), r.clear(), o.clear(), a.clear(), t.remove();
|
|
2320
2326
|
}
|
|
2321
2327
|
};
|
|
2322
|
-
},
|
|
2328
|
+
}, ri = ["width", "height"], q = (e, t) => {
|
|
2323
2329
|
var r;
|
|
2324
2330
|
const n = (r = e[t]) == null ? void 0 : r.trim();
|
|
2325
2331
|
return n || void 0;
|
|
2326
2332
|
}, Qe = (e, t) => {
|
|
2327
2333
|
const n = Number.parseInt(e[t] ?? "", 10);
|
|
2328
2334
|
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
2329
|
-
}, Ht = (e, t) =>
|
|
2335
|
+
}, Ht = (e, t) => ri.reduce((n, r) => {
|
|
2330
2336
|
const o = Qe(t, r);
|
|
2331
2337
|
return o === void 0 ? n : { ...n, [r]: o };
|
|
2332
|
-
}, e),
|
|
2338
|
+
}, e), oi = (e, t) => {
|
|
2333
2339
|
if (e.type === "format.color" || e.type === "format.backgroundColor" || e.type === "format.fontSize" || e.type === "format.fontFamily" || e.type === "format.lineHeight")
|
|
2334
2340
|
return t.value !== void 0 ? { ...e, value: t.value } : e;
|
|
2335
2341
|
if (e.type === "link.set") {
|
|
@@ -2372,7 +2378,7 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2372
2378
|
g: Number.parseInt(r.slice(2, 4), 16),
|
|
2373
2379
|
b: Number.parseInt(r.slice(4, 6), 16)
|
|
2374
2380
|
};
|
|
2375
|
-
},
|
|
2381
|
+
}, ai = (e) => {
|
|
2376
2382
|
const t = e.trim().match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i);
|
|
2377
2383
|
return t ? {
|
|
2378
2384
|
r: ee(Number(t[1])),
|
|
@@ -2380,13 +2386,13 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2380
2386
|
b: ee(Number(t[3]))
|
|
2381
2387
|
} : null;
|
|
2382
2388
|
}, We = (e) => {
|
|
2383
|
-
const t = jn(e) ??
|
|
2389
|
+
const t = jn(e) ?? ai(e);
|
|
2384
2390
|
return t ? Ze(t) : null;
|
|
2385
|
-
}, Kn = (e) => Math.min(Math.max(e, 0), 1),
|
|
2386
|
-
const r = ee(e) / 255, o = ee(t) / 255, a = ee(n) / 255, s = Math.max(r, o, a),
|
|
2387
|
-
let
|
|
2388
|
-
return d !== 0 && (s === r ?
|
|
2389
|
-
h:
|
|
2391
|
+
}, Kn = (e) => Math.min(Math.max(e, 0), 1), si = ({ r: e, g: t, b: n }) => {
|
|
2392
|
+
const r = ee(e) / 255, o = ee(t) / 255, a = ee(n) / 255, s = Math.max(r, o, a), i = Math.min(r, o, a), d = s - i;
|
|
2393
|
+
let l = 0;
|
|
2394
|
+
return d !== 0 && (s === r ? l = 60 * ((o - a) / d % 6) : s === o ? l = 60 * ((a - r) / d + 2) : l = 60 * ((r - o) / d + 4)), {
|
|
2395
|
+
h: l < 0 ? l + 360 : l,
|
|
2390
2396
|
s: s === 0 ? 0 : d / s,
|
|
2391
2397
|
v: s
|
|
2392
2398
|
};
|
|
@@ -2396,40 +2402,40 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2396
2402
|
v: n
|
|
2397
2403
|
}) => {
|
|
2398
2404
|
const r = n * t, o = r * (1 - Math.abs(e / 60 % 2 - 1)), a = n - r;
|
|
2399
|
-
let s = 0,
|
|
2400
|
-
return e < 60 ? (s = r,
|
|
2405
|
+
let s = 0, i = 0, d = 0;
|
|
2406
|
+
return e < 60 ? (s = r, i = o) : e < 120 ? (s = o, i = r) : e < 180 ? (i = r, d = o) : e < 240 ? (i = o, d = r) : e < 300 ? (s = o, d = r) : (s = r, d = o), {
|
|
2401
2407
|
r: (s + a) * 255,
|
|
2402
|
-
g: (
|
|
2408
|
+
g: (i + a) * 255,
|
|
2403
2409
|
b: (d + a) * 255
|
|
2404
2410
|
};
|
|
2405
|
-
},
|
|
2411
|
+
}, ii = ({ h: e, s: t }) => {
|
|
2406
2412
|
const n = e * Math.PI / 180, r = Kn(t) * 50;
|
|
2407
2413
|
return {
|
|
2408
2414
|
x: 50 + Math.cos(n) * r,
|
|
2409
2415
|
y: 50 + Math.sin(n) * r
|
|
2410
2416
|
};
|
|
2411
2417
|
}, $t = (e, t) => {
|
|
2412
|
-
const n = t.getBoundingClientRect(), r = n.left + n.width / 2, o = n.top + n.height / 2, a = e.clientX - r, s = e.clientY - o,
|
|
2418
|
+
const n = t.getBoundingClientRect(), r = n.left + n.width / 2, o = n.top + n.height / 2, a = e.clientX - r, s = e.clientY - o, i = Math.min(Math.sqrt(a * a + s * s), n.width / 2), d = Math.atan2(s, a) * 180 / Math.PI;
|
|
2413
2419
|
return {
|
|
2414
2420
|
h: d < 0 ? d + 360 : d,
|
|
2415
|
-
s: Kn(
|
|
2421
|
+
s: Kn(i / (n.width / 2)),
|
|
2416
2422
|
v: 1
|
|
2417
2423
|
};
|
|
2418
|
-
},
|
|
2424
|
+
}, li = [
|
|
2419
2425
|
"#000000",
|
|
2420
2426
|
"#ffffff"
|
|
2421
|
-
],
|
|
2427
|
+
], ci = (e) => {
|
|
2422
2428
|
var t;
|
|
2423
|
-
return (t = e.options) != null && t.length ? e.options :
|
|
2429
|
+
return (t = e.options) != null && t.length ? e.options : li.map((n) => ({ label: n, value: n }));
|
|
2424
2430
|
}, qn = () => {
|
|
2425
2431
|
const e = document.createElement("section");
|
|
2426
2432
|
return e.className = "bridgerte__payload-panel-field", e;
|
|
2427
|
-
},
|
|
2433
|
+
}, di = (e, t, n) => {
|
|
2428
2434
|
const r = qn(), o = document.createElement("div");
|
|
2429
2435
|
return o.className = "bridgerte__payload-panel-option-list", e.options.forEach((a) => {
|
|
2430
2436
|
const s = document.createElement("button");
|
|
2431
|
-
s.type = "button", s.className = "bridgerte__payload-panel-option", s.textContent = a.label, s.dataset.bridgertePayloadOption = a.value, s.dataset.active = t[e.name] === a.value ? "true" : "false", U(s), s.addEventListener("pointerdown", (
|
|
2432
|
-
|
|
2437
|
+
s.type = "button", s.className = "bridgerte__payload-panel-option", s.textContent = a.label, s.dataset.bridgertePayloadOption = a.value, s.dataset.active = t[e.name] === a.value ? "true" : "false", U(s), s.addEventListener("pointerdown", (i) => {
|
|
2438
|
+
i.preventDefault();
|
|
2433
2439
|
}), s.addEventListener("click", () => {
|
|
2434
2440
|
n({
|
|
2435
2441
|
...t,
|
|
@@ -2437,17 +2443,17 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2437
2443
|
});
|
|
2438
2444
|
}), o.append(s);
|
|
2439
2445
|
}), r.append(o), r;
|
|
2440
|
-
},
|
|
2441
|
-
const r = qn(), o = document.createElement("div"), a = document.createElement("div"), s = document.createElement("span"),
|
|
2442
|
-
let
|
|
2446
|
+
}, ui = (e, t, n) => {
|
|
2447
|
+
const r = qn(), o = document.createElement("div"), a = document.createElement("div"), s = document.createElement("span"), i = document.createElement("div"), d = document.createElement("div"), l = ci(e), g = l.length === 2;
|
|
2448
|
+
let f = { h: 0, s: 0, v: 1 }, b = null;
|
|
2443
2449
|
const T = (u) => {
|
|
2444
2450
|
const p = We(u);
|
|
2445
|
-
return !!(p &&
|
|
2446
|
-
},
|
|
2451
|
+
return !!(p && l.some((E) => We(E.value) === p));
|
|
2452
|
+
}, v = (u, p = !0) => {
|
|
2447
2453
|
const E = We(u);
|
|
2448
2454
|
if (!E) return;
|
|
2449
|
-
t[e.name] = E, d.style.background = E,
|
|
2450
|
-
const _ =
|
|
2455
|
+
t[e.name] = E, d.style.background = E, f = si(jn(E) ?? { r: 255, g: 255, b: 255 });
|
|
2456
|
+
const _ = ii(f);
|
|
2451
2457
|
a.dataset.active = p ? "true" : "false", d.dataset.empty = "false", p && (s.style.left = `${_.x}%`, s.style.top = `${_.y}%`);
|
|
2452
2458
|
}, y = () => {
|
|
2453
2459
|
const u = t[e.name];
|
|
@@ -2456,111 +2462,111 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2456
2462
|
[e.name]: u
|
|
2457
2463
|
});
|
|
2458
2464
|
};
|
|
2459
|
-
r.className = "bridgerte__payload-panel-field", o.className = "bridgerte__payload-panel-color-picker", a.className = "bridgerte__payload-panel-color-wheel", a.setAttribute("aria-label", `${e.label}选择区域`), s.className = "bridgerte__payload-panel-color-wheel-handle",
|
|
2465
|
+
r.className = "bridgerte__payload-panel-field", o.className = "bridgerte__payload-panel-color-picker", a.className = "bridgerte__payload-panel-color-wheel", a.setAttribute("aria-label", `${e.label}选择区域`), s.className = "bridgerte__payload-panel-color-wheel-handle", i.className = "bridgerte__payload-panel-color-actions", i.dataset.layout = g ? "sides" : "grid", d.className = "bridgerte__payload-panel-color-preview", d.dataset.empty = "true", a.append(s), l.forEach((u) => {
|
|
2460
2466
|
const p = document.createElement("button"), E = u.value;
|
|
2461
2467
|
p.type = "button", p.className = "bridgerte__payload-panel-color-swatch", p.dataset.value = E, p.style.background = E, p.setAttribute("aria-label", `选择颜色 ${u.label}`), U(p), p.addEventListener("pointerdown", (_) => {
|
|
2462
2468
|
_.preventDefault();
|
|
2463
2469
|
}), p.addEventListener("click", () => {
|
|
2464
|
-
|
|
2465
|
-
}),
|
|
2470
|
+
v(E, !1), y();
|
|
2471
|
+
}), i.append(p);
|
|
2466
2472
|
}), a.addEventListener("pointerdown", (u) => {
|
|
2467
|
-
b = u.pointerId, a.setPointerCapture(u.pointerId),
|
|
2473
|
+
b = u.pointerId, a.setPointerCapture(u.pointerId), f = $t(u, a), v(Ze(Ot(f))), u.preventDefault();
|
|
2468
2474
|
}), a.addEventListener("pointermove", (u) => {
|
|
2469
|
-
b === u.pointerId && (
|
|
2475
|
+
b === u.pointerId && (f = $t(u, a), v(Ze(Ot(f))));
|
|
2470
2476
|
}), a.addEventListener("pointerup", (u) => {
|
|
2471
2477
|
b === u.pointerId && (b = null, a.releasePointerCapture(u.pointerId), y());
|
|
2472
2478
|
}), a.addEventListener("pointercancel", (u) => {
|
|
2473
2479
|
b === u.pointerId && (b = null, a.releasePointerCapture(u.pointerId));
|
|
2474
2480
|
});
|
|
2475
2481
|
const x = t[e.name];
|
|
2476
|
-
return x &&
|
|
2477
|
-
},
|
|
2482
|
+
return x && v(x, !(g && T(x))), o.append(a, i), r.append(o, d), r;
|
|
2483
|
+
}, mi = (e, t, n) => {
|
|
2478
2484
|
const r = document.createElement("label"), o = document.createElement("input");
|
|
2479
2485
|
return r.className = "bridgerte__payload-panel-text-field", r.textContent = e.label, o.type = e.name === "href" || e.name === "url" ? "url" : "text", o.className = "bridgerte__payload-panel-text-input", o.value = t[e.name] ?? "", o.placeholder = e.placeholder ?? "", o.spellcheck = !1, o.addEventListener("input", () => {
|
|
2480
2486
|
t[e.name] = o.value;
|
|
2481
2487
|
}), o.addEventListener("keydown", (a) => {
|
|
2482
2488
|
a.key === "Enter" && (a.preventDefault(), n(t));
|
|
2483
2489
|
}), r.append(o), r;
|
|
2484
|
-
},
|
|
2490
|
+
}, gi = (e, t, n) => {
|
|
2485
2491
|
const r = document.createElement("label"), o = document.createElement("input");
|
|
2486
2492
|
return r.className = "bridgerte__payload-panel-text-field", r.textContent = e.label, o.type = "number", o.className = "bridgerte__payload-panel-text-input", o.value = t[e.name] ?? "", o.placeholder = e.placeholder ?? "", e.min !== void 0 && (o.min = String(e.min)), e.max !== void 0 && (o.max = String(e.max)), e.step !== void 0 && (o.step = String(e.step)), o.addEventListener("input", () => {
|
|
2487
2493
|
t[e.name] = o.value;
|
|
2488
2494
|
}), o.addEventListener("keydown", (a) => {
|
|
2489
2495
|
a.key === "Enter" && (a.preventDefault(), n(t));
|
|
2490
2496
|
}), r.append(o), r;
|
|
2491
|
-
},
|
|
2497
|
+
}, hi = ({
|
|
2492
2498
|
field: e,
|
|
2493
2499
|
values: t,
|
|
2494
2500
|
onSubmit: n
|
|
2495
|
-
}) => e.type === "color" ?
|
|
2501
|
+
}) => e.type === "color" ? ui(e, t, n) : e.type === "text" ? mi(e, t, n) : e.type === "number" ? gi(e, t, n) : di(e, t, n), pi = (e) => {
|
|
2496
2502
|
var t, n, r;
|
|
2497
2503
|
return e.defaultValue ?? (e.type === "select" ? (t = e.options[0]) == null ? void 0 : t.value : void 0) ?? (e.type === "color" ? (r = (n = e.options) == null ? void 0 : n[0]) == null ? void 0 : r.value : void 0) ?? "";
|
|
2498
|
-
},
|
|
2504
|
+
}, fi = (e, t) => (t == null ? void 0 : t[e.name]) ?? (e.type === "color" ? "" : pi(e)), Ft = (e) => e.some((t) => t.type === "text" || t.type === "number"), bi = (e) => {
|
|
2499
2505
|
const t = e.querySelector(
|
|
2500
2506
|
".bridgerte__payload-panel-text-input"
|
|
2501
2507
|
);
|
|
2502
2508
|
queueMicrotask(() => {
|
|
2503
2509
|
t == null || t.focus(), t == null || t.select();
|
|
2504
2510
|
});
|
|
2505
|
-
},
|
|
2511
|
+
}, yi = (e, t, n) => {
|
|
2506
2512
|
const r = document.createElement("div"), o = document.createElement("span"), a = (n == null ? void 0 : n(e)) ?? null;
|
|
2507
2513
|
if (r.className = "bridgerte__payload-panel-title", o.textContent = e.panel.title, r.append(o), a) {
|
|
2508
2514
|
const s = document.createElement("button");
|
|
2509
|
-
s.type = "button", s.className = "bridgerte__payload-panel-clear", s.textContent = "清除", s.setAttribute("aria-label", `清除${e.panel.title}`), U(s), s.addEventListener("pointerdown", (
|
|
2510
|
-
|
|
2515
|
+
s.type = "button", s.className = "bridgerte__payload-panel-clear", s.textContent = "清除", s.setAttribute("aria-label", `清除${e.panel.title}`), U(s), s.addEventListener("pointerdown", (i) => {
|
|
2516
|
+
i.preventDefault();
|
|
2511
2517
|
}), s.addEventListener("click", () => {
|
|
2512
2518
|
t(a);
|
|
2513
2519
|
}), r.append(s);
|
|
2514
2520
|
}
|
|
2515
2521
|
return r;
|
|
2516
|
-
},
|
|
2522
|
+
}, vi = (e) => (
|
|
2517
2523
|
/*
|
|
2518
2524
|
* 字体类面板只需要紧凑候选列表,颜色面板需要保留一点横向空间给圆盘和黑白按钮。
|
|
2519
2525
|
* 输入型面板保留默认宽度;table-insert 会按 schema 网格列数单独计算。
|
|
2520
2526
|
*/
|
|
2521
2527
|
e === "font-size" || e === "font-family" || e === "line-height" ? "180px" : "220px"
|
|
2522
|
-
),
|
|
2528
|
+
), wi = 3, Ci = 3, _i = 10, Gn = 10, ki = 16, xi = 2, Ei = 24, Mi = () => {
|
|
2523
2529
|
var e;
|
|
2524
2530
|
return typeof window < "u" && ((e = window.matchMedia) == null ? void 0 : e.call(window, "(hover: hover) and (pointer: fine)").matches) === !0;
|
|
2525
2531
|
}, ue = (e, t) => {
|
|
2526
2532
|
const n = Number.parseInt(e ?? "", 10);
|
|
2527
2533
|
return Number.isFinite(n) ? Math.min(Math.max(n, t.min), t.max) : t.defaultValue;
|
|
2528
|
-
},
|
|
2529
|
-
const o = e.find((g) =>
|
|
2534
|
+
}, Ti = (e, t) => e.type === "number" && e.name === t, zt = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 ? Math.floor(e) : t, Vt = (e, t, n, r) => {
|
|
2535
|
+
const o = e.find((g) => Ti(g, t)), a = zt(o == null ? void 0 : o.min, 1), s = zt(o == null ? void 0 : o.max, n), i = Math.max(a, s), d = Math.min(Math.max(r, a), i), l = ue(o == null ? void 0 : o.defaultValue, {
|
|
2530
2536
|
min: a,
|
|
2531
|
-
max:
|
|
2537
|
+
max: i,
|
|
2532
2538
|
defaultValue: d
|
|
2533
2539
|
});
|
|
2534
2540
|
return {
|
|
2535
2541
|
min: a,
|
|
2536
|
-
max:
|
|
2537
|
-
defaultValue:
|
|
2542
|
+
max: i,
|
|
2543
|
+
defaultValue: l
|
|
2538
2544
|
};
|
|
2539
2545
|
}, Xn = (e) => ({
|
|
2540
2546
|
rows: Vt(
|
|
2541
2547
|
e,
|
|
2542
2548
|
"rows",
|
|
2543
2549
|
tn,
|
|
2544
|
-
|
|
2550
|
+
wi
|
|
2545
2551
|
),
|
|
2546
2552
|
cols: Vt(
|
|
2547
2553
|
e,
|
|
2548
2554
|
"cols",
|
|
2549
2555
|
nn,
|
|
2550
|
-
|
|
2556
|
+
Ci
|
|
2551
2557
|
)
|
|
2552
|
-
}),
|
|
2558
|
+
}), Li = (e) => {
|
|
2553
2559
|
const t = Math.min(e.cols.max, Gn);
|
|
2554
|
-
return `${t *
|
|
2555
|
-
},
|
|
2560
|
+
return `${t * ki + Math.max(t - 1, 0) * xi + Ei}px`;
|
|
2561
|
+
}, Si = ({
|
|
2556
2562
|
fields: e,
|
|
2557
2563
|
values: t,
|
|
2558
2564
|
onSubmit: n
|
|
2559
2565
|
}) => {
|
|
2560
|
-
const r = Xn(e), o = document.createElement("section"), a = document.createElement("div"), s = document.createElement("div"),
|
|
2566
|
+
const r = Xn(e), o = document.createElement("section"), a = document.createElement("div"), s = document.createElement("div"), i = [], d = Mi(), l = Math.min(r.rows.max, _i), g = Math.min(r.cols.max, Gn), f = {
|
|
2561
2567
|
...r.rows,
|
|
2562
|
-
max:
|
|
2563
|
-
defaultValue: Math.min(r.rows.defaultValue,
|
|
2568
|
+
max: l,
|
|
2569
|
+
defaultValue: Math.min(r.rows.defaultValue, l)
|
|
2564
2570
|
}, b = {
|
|
2565
2571
|
...r.cols,
|
|
2566
2572
|
max: g,
|
|
@@ -2568,15 +2574,15 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2568
2574
|
};
|
|
2569
2575
|
let T = ue(
|
|
2570
2576
|
t.rows,
|
|
2571
|
-
|
|
2572
|
-
),
|
|
2577
|
+
f
|
|
2578
|
+
), v = ue(
|
|
2573
2579
|
t.cols,
|
|
2574
2580
|
b
|
|
2575
2581
|
), y = null;
|
|
2576
2582
|
const x = (I, w) => {
|
|
2577
|
-
T = I,
|
|
2578
|
-
const
|
|
2579
|
-
c.dataset.active = String(
|
|
2583
|
+
T = I, v = w, t.rows = String(I), t.cols = String(w), s.textContent = `${I} x ${w}`, i.forEach((c) => {
|
|
2584
|
+
const m = Number.parseInt(c.dataset.rows ?? "0", 10), h = Number.parseInt(c.dataset.cols ?? "0", 10);
|
|
2585
|
+
c.dataset.active = String(m <= I && h <= w);
|
|
2580
2586
|
});
|
|
2581
2587
|
}, u = (I) => {
|
|
2582
2588
|
var w;
|
|
@@ -2585,7 +2591,7 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2585
2591
|
if (!I) return;
|
|
2586
2592
|
const w = ue(
|
|
2587
2593
|
I.dataset.rows,
|
|
2588
|
-
|
|
2594
|
+
f
|
|
2589
2595
|
), c = ue(
|
|
2590
2596
|
I.dataset.cols,
|
|
2591
2597
|
b
|
|
@@ -2595,7 +2601,7 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2595
2601
|
n({
|
|
2596
2602
|
...t,
|
|
2597
2603
|
rows: String(T),
|
|
2598
|
-
cols: String(
|
|
2604
|
+
cols: String(v)
|
|
2599
2605
|
});
|
|
2600
2606
|
}, _ = () => {
|
|
2601
2607
|
y = null;
|
|
@@ -2608,33 +2614,33 @@ const As = () => (Dt += 1, `${Is}-${Dt}`), Bs = (e, t, n) => {
|
|
|
2608
2614
|
}
|
|
2609
2615
|
_(), p(w), E();
|
|
2610
2616
|
};
|
|
2611
|
-
for (let I = 1; I <=
|
|
2617
|
+
for (let I = 1; I <= l; I += 1)
|
|
2612
2618
|
for (let w = 1; w <= g; w += 1) {
|
|
2613
2619
|
const c = document.createElement("button");
|
|
2614
|
-
c.type = "button", c.className = "bridgerte__payload-panel-table-cell", c.dataset.rows = String(I), c.dataset.cols = String(w), c.setAttribute("aria-label", `插入 ${I} 行 ${w} 列表格`), U(c), c.addEventListener("pointerdown", (
|
|
2615
|
-
y = c, p(c),
|
|
2616
|
-
}), c.addEventListener("pointerup", B), c.addEventListener("pointercancel", _), c.addEventListener("click", (
|
|
2617
|
-
H(
|
|
2620
|
+
c.type = "button", c.className = "bridgerte__payload-panel-table-cell", c.dataset.rows = String(I), c.dataset.cols = String(w), c.setAttribute("aria-label", `插入 ${I} 行 ${w} 列表格`), U(c), c.addEventListener("pointerdown", (m) => {
|
|
2621
|
+
y = c, p(c), m.preventDefault();
|
|
2622
|
+
}), c.addEventListener("pointerup", B), c.addEventListener("pointercancel", _), c.addEventListener("click", (m) => {
|
|
2623
|
+
H(m, c);
|
|
2618
2624
|
}), d && c.addEventListener("pointerenter", () => {
|
|
2619
2625
|
p(c);
|
|
2620
|
-
}),
|
|
2626
|
+
}), i.push(c), a.append(c);
|
|
2621
2627
|
}
|
|
2622
2628
|
return o.className = "bridgerte__payload-panel-field", a.className = "bridgerte__payload-panel-table-grid", a.setAttribute("aria-label", "选择表格行列"), a.style.setProperty(
|
|
2623
2629
|
"--bridgerte-payload-panel-table-cols",
|
|
2624
2630
|
String(g)
|
|
2625
2631
|
), s.className = "bridgerte__payload-panel-table-status", s.setAttribute("aria-live", "polite"), a.addEventListener("pointermove", (I) => {
|
|
2626
2632
|
d || p(u(I));
|
|
2627
|
-
}), x(T,
|
|
2628
|
-
},
|
|
2633
|
+
}), x(T, v), o.append(a, s), o;
|
|
2634
|
+
}, Ni = "bridgerte-payload-panel";
|
|
2629
2635
|
let Wt = 0;
|
|
2630
|
-
const
|
|
2636
|
+
const Pi = () => (Wt += 1, `${Ni}-${Wt}`), Ee = (e) => e.panel.id === "table-insert", Ii = (e, t) => {
|
|
2631
2637
|
const n = document.createElement("button");
|
|
2632
2638
|
return n.type = "button", n.className = "bridgerte__payload-panel-submit", n.textContent = "应用", U(n), n.addEventListener("pointerdown", (r) => {
|
|
2633
2639
|
r.preventDefault();
|
|
2634
2640
|
}), n.addEventListener("click", () => {
|
|
2635
2641
|
t(e);
|
|
2636
2642
|
}), n;
|
|
2637
|
-
},
|
|
2643
|
+
}, Ri = (e) => {
|
|
2638
2644
|
let t = null, n = {};
|
|
2639
2645
|
const r = zn({
|
|
2640
2646
|
root: e.editorRoot,
|
|
@@ -2646,40 +2652,40 @@ const Ni = () => (Wt += 1, `${Si}-${Wt}`), xe = (e) => e.panel.id === "table-ins
|
|
|
2646
2652
|
function o() {
|
|
2647
2653
|
t = null, n = {}, r.close(), r.content.replaceChildren();
|
|
2648
2654
|
}
|
|
2649
|
-
const a = (
|
|
2650
|
-
var
|
|
2655
|
+
const a = (l) => {
|
|
2656
|
+
var f;
|
|
2651
2657
|
if (!t || t.readonly || e.isReadonly()) return;
|
|
2652
|
-
const g =
|
|
2653
|
-
g && ((
|
|
2658
|
+
const g = oi(t.command, l);
|
|
2659
|
+
g && ((f = e.restoreEditorFocus) == null || f.call(e, () => {
|
|
2654
2660
|
o(), e.isReadonly() || e.executeCommand(g);
|
|
2655
2661
|
}));
|
|
2656
|
-
}, s = (
|
|
2662
|
+
}, s = (l) => {
|
|
2657
2663
|
var g;
|
|
2658
2664
|
!t || t.readonly || e.isReadonly() || (g = e.restoreEditorFocus) == null || g.call(e, () => {
|
|
2659
|
-
o(), e.isReadonly() || e.executeCommand(
|
|
2665
|
+
o(), e.isReadonly() || e.executeCommand(l);
|
|
2660
2666
|
});
|
|
2661
|
-
},
|
|
2662
|
-
n =
|
|
2663
|
-
const g =
|
|
2664
|
-
r.element.style.width = `min(${g}, calc(100vw - 24px))`, r.content.append(
|
|
2665
|
-
fields:
|
|
2667
|
+
}, i = (l) => {
|
|
2668
|
+
n = l.panel.fields.reduce((f, b) => (f[b.name] = fi(b, l.currentValues), f), {});
|
|
2669
|
+
const g = Ee(l) ? Li(Xn(l.panel.fields)) : vi(l.panel.id);
|
|
2670
|
+
r.element.style.width = `min(${g}, calc(100vw - 24px))`, r.content.append(yi(l, s, e.getClearCommand)), Ee(l) ? r.content.append(Si({
|
|
2671
|
+
fields: l.panel.fields,
|
|
2666
2672
|
values: n,
|
|
2667
2673
|
onSubmit: a
|
|
2668
|
-
})) :
|
|
2669
|
-
r.content.append(
|
|
2670
|
-
field:
|
|
2674
|
+
})) : l.panel.fields.forEach((f) => {
|
|
2675
|
+
r.content.append(hi({
|
|
2676
|
+
field: f,
|
|
2671
2677
|
values: n,
|
|
2672
2678
|
onSubmit: a
|
|
2673
2679
|
}));
|
|
2674
|
-
}), !
|
|
2680
|
+
}), !Ee(l) && Ft(l.panel.fields) && r.content.append(Ii(n, a)), r.open(l.anchorRect), !Ee(l) && Ft(l.panel.fields) && bi(r.content);
|
|
2675
2681
|
};
|
|
2676
2682
|
return {
|
|
2677
|
-
open: (
|
|
2683
|
+
open: (l) => {
|
|
2678
2684
|
var b;
|
|
2679
2685
|
o();
|
|
2680
2686
|
const g = {
|
|
2681
|
-
...
|
|
2682
|
-
id:
|
|
2687
|
+
...l,
|
|
2688
|
+
id: Pi(),
|
|
2683
2689
|
readonly: e.isReadonly(),
|
|
2684
2690
|
submit: a,
|
|
2685
2691
|
cancel: o
|
|
@@ -2689,7 +2695,7 @@ const Ni = () => (Wt += 1, `${Si}-${Wt}`), xe = (e) => e.panel.id === "table-ins
|
|
|
2689
2695
|
o();
|
|
2690
2696
|
return;
|
|
2691
2697
|
}
|
|
2692
|
-
l
|
|
2698
|
+
i(l);
|
|
2693
2699
|
}
|
|
2694
2700
|
},
|
|
2695
2701
|
close: o,
|
|
@@ -2697,128 +2703,128 @@ const Ni = () => (Wt += 1, `${Si}-${Wt}`), xe = (e) => e.panel.id === "table-ins
|
|
|
2697
2703
|
o(), r.destroy();
|
|
2698
2704
|
}
|
|
2699
2705
|
};
|
|
2700
|
-
}, me = "bridgerte__table-controls-button",
|
|
2706
|
+
}, me = "bridgerte__table-controls-button", Ai = [
|
|
2701
2707
|
"table-insert-row-after",
|
|
2702
2708
|
"table-delete-row",
|
|
2703
2709
|
"table-insert-column-after",
|
|
2704
2710
|
"table-delete-column",
|
|
2705
2711
|
"table-delete"
|
|
2706
|
-
],
|
|
2712
|
+
], Bi = () => {
|
|
2707
2713
|
const e = new Map(De.map((t) => [t.id, t]));
|
|
2708
|
-
return
|
|
2709
|
-
}, Yn =
|
|
2714
|
+
return Ai.map((t) => xo.find((n) => n.id === t) ?? e.get(t)).filter((t) => t !== void 0);
|
|
2715
|
+
}, Yn = Bi(), Di = new Map(
|
|
2710
2716
|
/*
|
|
2711
2717
|
* Controls 按钮用 MenuItem.id 查完整 command,同类命令的不同 payload 不能用 command.type 合并。
|
|
2712
2718
|
* 后续加入插入前/后、合并/拆分等表格菜单时,只要 id 稳定,就不会互相覆盖。
|
|
2713
2719
|
*/
|
|
2714
2720
|
Yn.map((e) => [e.id, e])
|
|
2715
|
-
),
|
|
2721
|
+
), Hi = (e) => e.matches(".bridgerte__table") ? e : e.querySelector(".bridgerte__table") ?? e, Oi = (e, t) => e.classList.contains("bridgerte__table-wrapper") ? e : t.parentElement instanceof HTMLElement ? t.parentElement : t, $i = (e) => e.querySelector(".bridgerte__content") ?? e, Fi = (e) => e instanceof Element ? e.closest(".bridgerte__table-wrapper") : null, zi = (e) => {
|
|
2716
2722
|
const t = e.getFirstChild();
|
|
2717
2723
|
if (!ao(t)) return null;
|
|
2718
2724
|
const n = t.getFirstChild();
|
|
2719
2725
|
return so(n) ? n : null;
|
|
2720
|
-
},
|
|
2726
|
+
}, Vi = (e) => {
|
|
2721
2727
|
const t = document.createElement("button");
|
|
2722
2728
|
return t.type = "button", t.className = me, t.textContent = e.label, t.dataset.menuItemId = e.id, t.setAttribute("aria-label", e.label), t;
|
|
2723
|
-
},
|
|
2729
|
+
}, Wi = () => {
|
|
2724
2730
|
const e = document.createElement("div");
|
|
2725
2731
|
return e.className = "bridgerte__table-controls", e.contentEditable = "false", e.setAttribute("aria-label", "表格操作"), Yn.forEach((t) => {
|
|
2726
|
-
e.append(
|
|
2732
|
+
e.append(Vi(t));
|
|
2727
2733
|
}), e;
|
|
2728
|
-
},
|
|
2729
|
-
const t = document.createElement("div"), n =
|
|
2730
|
-
let s = null,
|
|
2731
|
-
const g = (
|
|
2734
|
+
}, Ui = (e) => {
|
|
2735
|
+
const t = document.createElement("div"), n = $i(e.root), r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
2736
|
+
let s = null, i = null, d = !1, l = null;
|
|
2737
|
+
const g = (h, C) => {
|
|
2732
2738
|
const P = e.root.getBoundingClientRect(), M = C.getBoundingClientRect(), L = M.bottom < P.top || M.top > P.bottom, N = Math.max(
|
|
2733
2739
|
8,
|
|
2734
|
-
P.width -
|
|
2740
|
+
P.width - h.offsetWidth - 8
|
|
2735
2741
|
), R = Math.min(
|
|
2736
2742
|
Math.max(M.left - P.left + 8, 8),
|
|
2737
2743
|
N
|
|
2738
|
-
), S = Math.max(8, M.top - P.top -
|
|
2739
|
-
|
|
2740
|
-
},
|
|
2741
|
-
const C = e.editor.getElementByKey(
|
|
2744
|
+
), S = Math.max(8, M.top - P.top - h.offsetHeight - 8);
|
|
2745
|
+
h.hidden = L, h.style.transform = `translate(${R}px, ${S}px)`;
|
|
2746
|
+
}, f = (h) => l === h, b = (h) => {
|
|
2747
|
+
const C = e.editor.getElementByKey(h);
|
|
2742
2748
|
if (!C) {
|
|
2743
|
-
T(
|
|
2749
|
+
T(h);
|
|
2744
2750
|
return;
|
|
2745
2751
|
}
|
|
2746
|
-
C.dataset.lexicalKey =
|
|
2747
|
-
const P =
|
|
2748
|
-
a.set(M,
|
|
2749
|
-
const L = r.get(
|
|
2750
|
-
if (!
|
|
2751
|
-
T(
|
|
2752
|
+
C.dataset.lexicalKey = h;
|
|
2753
|
+
const P = Hi(C), M = Oi(C, P);
|
|
2754
|
+
a.set(M, h);
|
|
2755
|
+
const L = r.get(h);
|
|
2756
|
+
if (!f(h)) {
|
|
2757
|
+
T(h);
|
|
2752
2758
|
return;
|
|
2753
2759
|
}
|
|
2754
2760
|
if (L) {
|
|
2755
2761
|
g(L, M);
|
|
2756
2762
|
return;
|
|
2757
2763
|
}
|
|
2758
|
-
const N =
|
|
2764
|
+
const N = Wi(), R = U(N, {
|
|
2759
2765
|
targetSelector: `.${me}`
|
|
2760
2766
|
});
|
|
2761
|
-
N.dataset.lexicalKey =
|
|
2762
|
-
}, T = (
|
|
2767
|
+
N.dataset.lexicalKey = h, r.set(h, N), o.set(N, R), t.append(N), g(N, M);
|
|
2768
|
+
}, T = (h) => {
|
|
2763
2769
|
var P;
|
|
2764
|
-
const C = r.get(
|
|
2765
|
-
C && ((P = o.get(C)) == null || P(), o.delete(C), C.remove(), r.delete(
|
|
2766
|
-
},
|
|
2767
|
-
s = null, a.forEach((
|
|
2768
|
-
e.root.contains(C) || (a.delete(C), T(
|
|
2769
|
-
}), e.root.querySelectorAll(".bridgerte__table-wrapper").forEach((
|
|
2770
|
-
const C =
|
|
2771
|
-
C && (a.set(
|
|
2772
|
-
}), r.forEach((
|
|
2770
|
+
const C = r.get(h);
|
|
2771
|
+
C && ((P = o.get(C)) == null || P(), o.delete(C), C.remove(), r.delete(h), l === h && (l = null));
|
|
2772
|
+
}, v = () => {
|
|
2773
|
+
s = null, a.forEach((h, C) => {
|
|
2774
|
+
e.root.contains(C) || (a.delete(C), T(h));
|
|
2775
|
+
}), e.root.querySelectorAll(".bridgerte__table-wrapper").forEach((h) => {
|
|
2776
|
+
const C = h.dataset.lexicalKey;
|
|
2777
|
+
C && (a.set(h, C), b(C));
|
|
2778
|
+
}), r.forEach((h, C) => {
|
|
2773
2779
|
b(C);
|
|
2774
|
-
}),
|
|
2780
|
+
}), l !== null && b(l);
|
|
2775
2781
|
}, y = () => {
|
|
2776
|
-
s === null && (s = Re(
|
|
2777
|
-
}, x = (
|
|
2782
|
+
s === null && (s = Re(v));
|
|
2783
|
+
}, x = (h) => {
|
|
2778
2784
|
e.editor.update(() => {
|
|
2779
2785
|
var P;
|
|
2780
|
-
const C = he(
|
|
2781
|
-
C instanceof Ge && ((P =
|
|
2786
|
+
const C = he(h);
|
|
2787
|
+
C instanceof Ge && ((P = zi(C)) == null || P.selectStart());
|
|
2782
2788
|
}), e.editor.focus();
|
|
2783
|
-
}, u = (
|
|
2784
|
-
x(
|
|
2785
|
-
}, p = (
|
|
2786
|
-
const P = C.dataset.lexicalKey, M =
|
|
2789
|
+
}, u = (h, C) => {
|
|
2790
|
+
x(h), e.executeCommand(C);
|
|
2791
|
+
}, p = (h, C) => {
|
|
2792
|
+
const P = C.dataset.lexicalKey, M = h.dataset.menuItemId, L = M ? Di.get(M) : void 0;
|
|
2787
2793
|
!P || !L || u(P, L.command);
|
|
2788
|
-
}, E = (
|
|
2789
|
-
if (!
|
|
2790
|
-
const M =
|
|
2791
|
-
|
|
2794
|
+
}, E = (h) => {
|
|
2795
|
+
if (!h) {
|
|
2796
|
+
const M = l;
|
|
2797
|
+
l = null, M !== null && b(M);
|
|
2792
2798
|
return;
|
|
2793
2799
|
}
|
|
2794
|
-
const C =
|
|
2795
|
-
if (!C ||
|
|
2796
|
-
const P =
|
|
2797
|
-
|
|
2798
|
-
}, _ = (
|
|
2799
|
-
const C =
|
|
2800
|
+
const C = h.dataset.lexicalKey ? h.dataset.lexicalKey : a.get(h) ?? null;
|
|
2801
|
+
if (!C || l === C) return;
|
|
2802
|
+
const P = l;
|
|
2803
|
+
l = C, P !== null && b(P), b(C);
|
|
2804
|
+
}, _ = (h) => {
|
|
2805
|
+
const C = h.target;
|
|
2800
2806
|
if (!(C instanceof HTMLElement)) return;
|
|
2801
2807
|
const P = C.closest(`.${me}`);
|
|
2802
|
-
P && (
|
|
2803
|
-
}, B = (
|
|
2804
|
-
if (
|
|
2805
|
-
const C =
|
|
2806
|
-
M ===
|
|
2808
|
+
P && (h.preventDefault(), i = h.pointerType === "mouse" ? null : P);
|
|
2809
|
+
}, B = (h) => {
|
|
2810
|
+
if (h.pointerType === "mouse" || !i) return;
|
|
2811
|
+
const C = h.target, P = C instanceof HTMLElement ? C.closest(".bridgerte__table-controls") : null, M = C instanceof HTMLElement ? C.closest(`.${me}`) : null;
|
|
2812
|
+
M === i && P && (h.preventDefault(), h.stopPropagation(), p(M, P), d = !0), i = null;
|
|
2807
2813
|
}, H = () => {
|
|
2808
|
-
|
|
2809
|
-
}, I = (
|
|
2814
|
+
i = null;
|
|
2815
|
+
}, I = (h) => {
|
|
2810
2816
|
if (d) {
|
|
2811
|
-
d = !1,
|
|
2817
|
+
d = !1, h.preventDefault(), h.stopPropagation();
|
|
2812
2818
|
return;
|
|
2813
2819
|
}
|
|
2814
|
-
const C =
|
|
2820
|
+
const C = h.target;
|
|
2815
2821
|
if (!(C instanceof HTMLElement)) return;
|
|
2816
2822
|
const P = C.closest(`.${me}`), M = C.closest(".bridgerte__table-controls");
|
|
2817
|
-
!P || !M || (
|
|
2823
|
+
!P || !M || (h.preventDefault(), h.stopPropagation(), p(P, M));
|
|
2818
2824
|
}, w = e.editor.registerMutationListener(
|
|
2819
2825
|
Ge,
|
|
2820
|
-
(
|
|
2821
|
-
|
|
2826
|
+
(h) => {
|
|
2827
|
+
h.forEach((C, P) => {
|
|
2822
2828
|
if (C === "destroyed") {
|
|
2823
2829
|
T(P);
|
|
2824
2830
|
return;
|
|
@@ -2826,41 +2832,41 @@ const Ni = () => (Wt += 1, `${Si}-${Wt}`), xe = (e) => e.panel.id === "table-ins
|
|
|
2826
2832
|
b(P);
|
|
2827
2833
|
});
|
|
2828
2834
|
}
|
|
2829
|
-
), c = e.editor.registerUpdateListener(y),
|
|
2835
|
+
), c = e.editor.registerUpdateListener(y), m = ct({
|
|
2830
2836
|
root: e.root,
|
|
2831
2837
|
content: n,
|
|
2832
|
-
getBlockFromTarget:
|
|
2838
|
+
getBlockFromTarget: Fi,
|
|
2833
2839
|
activateBlock: E,
|
|
2834
2840
|
clearBlock: () => E(null)
|
|
2835
2841
|
});
|
|
2836
2842
|
return t.className = "bridgerte__table-controls-layer", e.root.append(t), t.addEventListener("pointerdown", _), t.addEventListener("pointerup", B), t.addEventListener("pointercancel", H), t.addEventListener("click", I), n.addEventListener("scroll", y, { passive: !0 }), window.addEventListener("resize", y), {
|
|
2837
2843
|
destroy() {
|
|
2838
|
-
w(), c(), s !== null && (lt(s), s = null), t.removeEventListener("pointerdown", _), t.removeEventListener("pointerup", B), t.removeEventListener("pointercancel", H), t.removeEventListener("click", I),
|
|
2844
|
+
w(), c(), s !== null && (lt(s), s = null), t.removeEventListener("pointerdown", _), t.removeEventListener("pointerup", B), t.removeEventListener("pointercancel", H), t.removeEventListener("click", I), m.destroy(), n.removeEventListener("scroll", y), window.removeEventListener("resize", y), r.forEach((h) => {
|
|
2839
2845
|
var C;
|
|
2840
|
-
(C = o.get(
|
|
2846
|
+
(C = o.get(h)) == null || C(), h.remove();
|
|
2841
2847
|
}), r.clear(), o.clear(), a.clear(), t.remove();
|
|
2842
2848
|
}
|
|
2843
2849
|
};
|
|
2844
|
-
},
|
|
2845
|
-
const t =
|
|
2850
|
+
}, ji = (e) => {
|
|
2851
|
+
const t = Ri({
|
|
2846
2852
|
editorRoot: e.editorRoot,
|
|
2847
2853
|
isReadonly: e.isReadonly,
|
|
2848
2854
|
restoreEditorFocus: e.restoreEditorFocus,
|
|
2849
2855
|
executeCommand: e.executeCommand,
|
|
2850
2856
|
getClearCommand: e.getClearCommand,
|
|
2851
2857
|
onRequest: e.onRequest
|
|
2852
|
-
}), n =
|
|
2858
|
+
}), n = Os({
|
|
2853
2859
|
editor: e.lexicalEditor,
|
|
2854
2860
|
root: e.editorRoot,
|
|
2855
2861
|
isReadonly: e.isReadonly,
|
|
2856
2862
|
languagePanel: e.codeBlockLanguagePanel,
|
|
2857
2863
|
payloadPanelConfig: e.payloadPanelConfig,
|
|
2858
2864
|
onRequest: e.onRequest
|
|
2859
|
-
}), r =
|
|
2865
|
+
}), r = Ui({
|
|
2860
2866
|
editor: e.lexicalEditor,
|
|
2861
2867
|
root: e.editorRoot,
|
|
2862
2868
|
executeCommand: e.executeCommand
|
|
2863
|
-
}), o =
|
|
2869
|
+
}), o = ni({
|
|
2864
2870
|
editor: e.lexicalEditor,
|
|
2865
2871
|
root: e.editorRoot,
|
|
2866
2872
|
defaultWidthPercent: e.defaultMediaWidthPercent,
|
|
@@ -2877,7 +2883,7 @@ const Ni = () => (Wt += 1, `${Si}-${Wt}`), xe = (e) => e.panel.id === "table-ins
|
|
|
2877
2883
|
t.destroy(), n.destroy(), r.destroy(), o.destroy();
|
|
2878
2884
|
}
|
|
2879
2885
|
};
|
|
2880
|
-
},
|
|
2886
|
+
}, Ki = (e, t) => {
|
|
2881
2887
|
const n = document.createElement("div"), r = document.createElement("div"), o = document.createElement("div"), a = document.createElement("div");
|
|
2882
2888
|
return e.classList.add("bridgerte"), e.textContent = "", n.className = "bridgerte__editor", r.className = "bridgerte__body", o.className = "bridgerte__content", a.className = "bridgerte__placeholder", a.textContent = t.placeholder, a.setAttribute("aria-hidden", "true"), o.dataset.placeholder = t.placeholder, o.setAttribute("role", "textbox"), o.setAttribute("aria-multiline", "true"), r.append(o, a), n.append(r), e.append(n), {
|
|
2883
2889
|
rootElement: n,
|
|
@@ -2885,7 +2891,7 @@ const Ni = () => (Wt += 1, `${Si}-${Wt}`), xe = (e) => e.panel.id === "table-ins
|
|
|
2885
2891
|
contentElement: o,
|
|
2886
2892
|
placeholderElement: a
|
|
2887
2893
|
};
|
|
2888
|
-
},
|
|
2894
|
+
}, qi = ({
|
|
2889
2895
|
editor: e
|
|
2890
2896
|
}) => {
|
|
2891
2897
|
let t = null;
|
|
@@ -2905,16 +2911,16 @@ const Ni = () => (Wt += 1, `${Si}-${Wt}`), xe = (e) => e.panel.id === "table-ins
|
|
|
2905
2911
|
t = null;
|
|
2906
2912
|
}
|
|
2907
2913
|
};
|
|
2908
|
-
},
|
|
2914
|
+
}, Gi = /((https?:\/\/|www\.)[^\s<>()]+[^\s<>().,;:!?])/i, Xi = /([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,})/i, Yi = {
|
|
2909
2915
|
changeHandlers: [],
|
|
2910
2916
|
excludeParents: [],
|
|
2911
2917
|
matchers: [
|
|
2912
|
-
bt(
|
|
2913
|
-
bt(
|
|
2918
|
+
bt(Gi, (e) => e.startsWith("http://") || e.startsWith("https://") ? e : `https://${e}`),
|
|
2919
|
+
bt(Xi, (e) => `mailto:${e}`)
|
|
2914
2920
|
]
|
|
2915
|
-
},
|
|
2921
|
+
}, Ji = ({
|
|
2916
2922
|
editor: e
|
|
2917
|
-
}) => ho(e,
|
|
2923
|
+
}) => ho(e, Yi), Qi = [
|
|
2918
2924
|
".bridgerte__code-header",
|
|
2919
2925
|
".bridgerte__code-block-controls",
|
|
2920
2926
|
".bridgerte__code-block-control-button",
|
|
@@ -2928,32 +2934,32 @@ const Ni = () => (Wt += 1, `${Si}-${Wt}`), xe = (e) => e.panel.id === "table-ins
|
|
|
2928
2934
|
".bridgerte__dialog-backdrop",
|
|
2929
2935
|
".bridgerte__dialog",
|
|
2930
2936
|
".bridgerte__payload-panel"
|
|
2931
|
-
].join(","),
|
|
2937
|
+
].join(","), Zi = (e, t) => {
|
|
2932
2938
|
const n = e.anchorNode, r = e.focusNode;
|
|
2933
2939
|
return n !== null && r !== null && t.contains(n) && t.contains(r);
|
|
2934
|
-
},
|
|
2935
|
-
e.querySelectorAll(
|
|
2940
|
+
}, el = (e) => {
|
|
2941
|
+
e.querySelectorAll(Qi).forEach((t) => {
|
|
2936
2942
|
t.remove();
|
|
2937
2943
|
}), e.querySelectorAll('[contenteditable="false"]').forEach((t) => {
|
|
2938
2944
|
t.classList.contains("bridgerte__media") || t.remove();
|
|
2939
2945
|
});
|
|
2940
|
-
},
|
|
2946
|
+
}, tl = (e) => {
|
|
2941
2947
|
const t = e.ownerDocument.getSelection();
|
|
2942
|
-
if (!t || t.rangeCount === 0 || !
|
|
2948
|
+
if (!t || t.rangeCount === 0 || !Zi(t, e))
|
|
2943
2949
|
return null;
|
|
2944
2950
|
const n = t.getRangeAt(0).cloneContents();
|
|
2945
|
-
|
|
2951
|
+
el(n);
|
|
2946
2952
|
const r = e.ownerDocument.createElement("div");
|
|
2947
2953
|
return r.append(n), {
|
|
2948
2954
|
html: r.innerHTML,
|
|
2949
2955
|
text: r.textContent ?? ""
|
|
2950
2956
|
};
|
|
2951
|
-
},
|
|
2957
|
+
}, nl = ({
|
|
2952
2958
|
target: e,
|
|
2953
2959
|
isReadonly: t
|
|
2954
2960
|
}) => {
|
|
2955
2961
|
const n = (o) => {
|
|
2956
|
-
const a =
|
|
2962
|
+
const a = tl(e);
|
|
2957
2963
|
!a || !o.clipboardData || (o.clipboardData.setData("text/html", a.html), o.clipboardData.setData("text/plain", a.text), o.preventDefault(), o.stopImmediatePropagation());
|
|
2958
2964
|
}, r = (o) => {
|
|
2959
2965
|
if (t()) {
|
|
@@ -2965,7 +2971,7 @@ const Ni = () => (Wt += 1, `${Si}-${Wt}`), xe = (e) => e.panel.id === "table-ins
|
|
|
2965
2971
|
return e.addEventListener("copy", n, { capture: !0 }), e.addEventListener("cut", r, { capture: !0 }), () => {
|
|
2966
2972
|
e.removeEventListener("copy", n, { capture: !0 }), e.removeEventListener("cut", r, { capture: !0 });
|
|
2967
2973
|
};
|
|
2968
|
-
}, Me = 8,
|
|
2974
|
+
}, Me = 8, rl = () => {
|
|
2969
2975
|
const e = window.visualViewport;
|
|
2970
2976
|
return {
|
|
2971
2977
|
left: (e == null ? void 0 : e.offsetLeft) ?? 0,
|
|
@@ -2976,14 +2982,14 @@ const Ni = () => (Wt += 1, `${Si}-${Wt}`), xe = (e) => e.panel.id === "table-ins
|
|
|
2976
2982
|
}, Ut = (e, t, n) => Math.min(Math.max(e, t), Math.max(t, n));
|
|
2977
2983
|
function Jn(e, t, n = {}) {
|
|
2978
2984
|
const r = n.placement ?? "bottom-start", o = n.offset ?? 8, a = n.shiftPadding ?? 8, s = n.strategy ?? "absolute";
|
|
2979
|
-
let
|
|
2980
|
-
const
|
|
2985
|
+
let i = null, d = !1;
|
|
2986
|
+
const l = () => {
|
|
2981
2987
|
t.style.position = s, t.style.left = "0px", t.style.top = "0px", t.style.opacity = "0", t.style.pointerEvents = "none";
|
|
2982
|
-
}, g = (
|
|
2983
|
-
const x =
|
|
2984
|
-
t.style.left = `${Ut(
|
|
2985
|
-
},
|
|
2986
|
-
const
|
|
2988
|
+
}, g = (v, y) => {
|
|
2989
|
+
const x = rl(), u = t.getBoundingClientRect(), p = x.left + Me, E = x.top + Me, _ = x.left + x.width - u.width - Me, B = x.top + x.height - u.height - Me;
|
|
2990
|
+
t.style.left = `${Ut(v, p, _)}px`, t.style.top = `${Ut(y, E, B)}px`, t.style.opacity = "", t.style.pointerEvents = "";
|
|
2991
|
+
}, f = async () => {
|
|
2992
|
+
const v = await vn(e, t, {
|
|
2987
2993
|
placement: r,
|
|
2988
2994
|
strategy: s,
|
|
2989
2995
|
platform: wn,
|
|
@@ -2993,20 +2999,20 @@ function Jn(e, t, n = {}) {
|
|
|
2993
2999
|
kn({ padding: a })
|
|
2994
3000
|
]
|
|
2995
3001
|
});
|
|
2996
|
-
g(
|
|
3002
|
+
g(v.x, v.y);
|
|
2997
3003
|
}, b = () => {
|
|
2998
|
-
|
|
2999
|
-
}, T = (
|
|
3000
|
-
if (d !==
|
|
3001
|
-
if (d =
|
|
3002
|
-
|
|
3004
|
+
i == null || i(), i = null;
|
|
3005
|
+
}, T = (v) => {
|
|
3006
|
+
if (d !== v) {
|
|
3007
|
+
if (d = v, b(), d) {
|
|
3008
|
+
l(), t.hidden = !1, i = Eo(e, t, f), f();
|
|
3003
3009
|
return;
|
|
3004
3010
|
}
|
|
3005
3011
|
t.hidden = !0, t.style.opacity = "", t.style.pointerEvents = "";
|
|
3006
3012
|
}
|
|
3007
3013
|
};
|
|
3008
|
-
return
|
|
3009
|
-
update:
|
|
3014
|
+
return l(), t.hidden = !0, {
|
|
3015
|
+
update: f,
|
|
3010
3016
|
setOpen: T,
|
|
3011
3017
|
destroy() {
|
|
3012
3018
|
b(), t.hidden = !0;
|
|
@@ -3106,7 +3112,7 @@ const Qn = {
|
|
|
3106
3112
|
"upload-video": '<svg aria-hidden="true" class="lucide lucide-film" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <rect width="18" height="18" x="3" y="3" rx="2" /> <path d="M7 3v18" /> <path d="M3 7.5h4" /> <path d="M3 12h18" /> <path d="M3 16.5h4" /> <path d="M17 3v18" /> <path d="M17 7.5h4" /> <path d="M17 16.5h4" /> </svg>',
|
|
3107
3113
|
// 行高菜单使用,表示 format.lineHeight。
|
|
3108
3114
|
"wrap-text": '<svg aria-hidden="true" class="lucide lucide-wrap-text" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="m16 16-3 3 3 3" /> <path d="M3 12h14.5a1 1 0 0 1 0 7H13" /> <path d="M3 19h6" /> <path d="M3 5h18" /> </svg>'
|
|
3109
|
-
},
|
|
3115
|
+
}, ol = (e) => {
|
|
3110
3116
|
const t = document.createElement("span");
|
|
3111
3117
|
return t.className = "bridgerte__menu-icon-text", t.textContent = e, t;
|
|
3112
3118
|
}, Zn = (e, t, n) => {
|
|
@@ -3114,11 +3120,11 @@ const Qn = {
|
|
|
3114
3120
|
e.innerHTML = t;
|
|
3115
3121
|
return;
|
|
3116
3122
|
}
|
|
3117
|
-
e.append(
|
|
3123
|
+
e.append(ol(n));
|
|
3118
3124
|
}, et = () => {
|
|
3119
3125
|
const e = window.getSelection(), t = e != null && e.rangeCount ? e.getRangeAt(0) : null, n = t == null ? void 0 : t.getBoundingClientRect();
|
|
3120
3126
|
return !n || n.width === 0 && n.height === 0 ? null : n;
|
|
3121
|
-
},
|
|
3127
|
+
}, al = 160, sl = {
|
|
3122
3128
|
toolbarKeys: [
|
|
3123
3129
|
"bold",
|
|
3124
3130
|
"italic",
|
|
@@ -3133,16 +3139,16 @@ const Qn = {
|
|
|
3133
3139
|
"font-family",
|
|
3134
3140
|
"line-height"
|
|
3135
3141
|
]
|
|
3136
|
-
},
|
|
3142
|
+
}, il = () => {
|
|
3137
3143
|
const e = D();
|
|
3138
3144
|
return O(e) && !e.isCollapsed();
|
|
3139
|
-
}, jt = (e, t) => e.target instanceof Node && t.contains(e.target), Kt = (e) => e instanceof Element ? e.closest(".bridgerte__hoverbar-button") : null,
|
|
3145
|
+
}, jt = (e, t) => e.target instanceof Node && t.contains(e.target), Kt = (e) => e instanceof Element ? e.closest(".bridgerte__hoverbar-button") : null, ll = (e) => e.flatMap((t) => t.type === "button" ? [t.item] : t.type === "group" ? t.items : []), cl = (e) => {
|
|
3140
3146
|
const t = document.createElement("span");
|
|
3141
3147
|
return t.className = "bridgerte__hoverbar-separator", t.dataset.separatorId = e.key, t.setAttribute("aria-hidden", "true"), t;
|
|
3142
|
-
},
|
|
3143
|
-
const r =
|
|
3148
|
+
}, dl = (e, t, n) => {
|
|
3149
|
+
const r = Fs(e, t), o = document.createElement("button");
|
|
3144
3150
|
return o.type = "button", o.className = "bridgerte__hoverbar-button", o.dataset.hoverbarItemId = e.id, o.dataset.active = String(r.active), o.disabled = r.disabled, o.setAttribute("aria-label", e.label), o.setAttribute("aria-pressed", String(r.active)), Zn(o, n[e.icon] ?? Qn[e.icon], e.label), o;
|
|
3145
|
-
},
|
|
3151
|
+
}, ul = ({
|
|
3146
3152
|
editorRoot: e,
|
|
3147
3153
|
contentElement: t,
|
|
3148
3154
|
editor: n,
|
|
@@ -3150,16 +3156,16 @@ const Qn = {
|
|
|
3150
3156
|
executeCommand: o,
|
|
3151
3157
|
requestPayloadPanel: a,
|
|
3152
3158
|
getCommandStates: s,
|
|
3153
|
-
menuSchema:
|
|
3159
|
+
menuSchema: i,
|
|
3154
3160
|
hoverbarConfig: d,
|
|
3155
|
-
menuLabels:
|
|
3161
|
+
menuLabels: l,
|
|
3156
3162
|
payloadPanelConfig: g,
|
|
3157
|
-
icons:
|
|
3163
|
+
icons: f = {}
|
|
3158
3164
|
}) => {
|
|
3159
|
-
const b = dt(
|
|
3160
|
-
menuLabels:
|
|
3165
|
+
const b = dt(i ?? De, {
|
|
3166
|
+
menuLabels: l,
|
|
3161
3167
|
payloadPanelConfig: g
|
|
3162
|
-
}), T = ot(d ??
|
|
3168
|
+
}), T = ot(d ?? sl, b), v = ll(T), y = document.createElement("span"), x = document.createElement("div");
|
|
3163
3169
|
let u = null, p = !1, E = null;
|
|
3164
3170
|
const _ = U(x, {
|
|
3165
3171
|
targetSelector: ".bridgerte__hoverbar-button"
|
|
@@ -3178,8 +3184,8 @@ const Qn = {
|
|
|
3178
3184
|
y.style.left = `${(S == null ? void 0 : S.left) ?? k.left}px`, y.style.top = `${(S == null ? void 0 : S.top) ?? k.top}px`, y.style.width = `${(S == null ? void 0 : S.width) || 1}px`, y.style.height = `${(S == null ? void 0 : S.height) || 1}px`;
|
|
3179
3185
|
}, w = () => {
|
|
3180
3186
|
const S = s();
|
|
3181
|
-
x.replaceChildren(...T.flatMap((k) => k.type === "separator" ? [
|
|
3182
|
-
}, c = () => r() ? !1 : n.getEditorState().read(
|
|
3187
|
+
x.replaceChildren(...T.flatMap((k) => k.type === "separator" ? [cl(k)] : (k.type === "button" ? [k.item] : k.items).map(($) => dl($, S, f)))), I(), p = !0, x.dataset.visible = "true", u == null || u.setOpen(!0), u == null || u.update();
|
|
3188
|
+
}, c = () => r() ? !1 : n.getEditorState().read(il), m = (S = !1) => {
|
|
3183
3189
|
if (B(), !c()) {
|
|
3184
3190
|
H();
|
|
3185
3191
|
return;
|
|
@@ -3190,9 +3196,9 @@ const Qn = {
|
|
|
3190
3196
|
}
|
|
3191
3197
|
p && H(), E = window.setTimeout(() => {
|
|
3192
3198
|
E = null, c() && w();
|
|
3193
|
-
},
|
|
3194
|
-
},
|
|
3195
|
-
const k =
|
|
3199
|
+
}, al);
|
|
3200
|
+
}, h = (S) => {
|
|
3201
|
+
const k = v.find((A) => A.id === S.dataset.hoverbarItemId);
|
|
3196
3202
|
if (!(!k || S.disabled)) {
|
|
3197
3203
|
if (k.payloadPanel) {
|
|
3198
3204
|
const A = S.getBoundingClientRect();
|
|
@@ -3200,31 +3206,31 @@ const Qn = {
|
|
|
3200
3206
|
menuId: k.id,
|
|
3201
3207
|
command: k.command,
|
|
3202
3208
|
panel: k.payloadPanel,
|
|
3203
|
-
currentValues:
|
|
3209
|
+
currentValues: $s(k, s()),
|
|
3204
3210
|
anchorRect: {
|
|
3205
3211
|
x: A.left,
|
|
3206
3212
|
y: A.top,
|
|
3207
3213
|
width: A.width,
|
|
3208
3214
|
height: A.height
|
|
3209
3215
|
}
|
|
3210
|
-
}),
|
|
3216
|
+
}), m(!0);
|
|
3211
3217
|
return;
|
|
3212
3218
|
}
|
|
3213
|
-
o(k.command),
|
|
3219
|
+
o(k.command), m(!0);
|
|
3214
3220
|
}
|
|
3215
3221
|
}, C = (S) => {
|
|
3216
3222
|
Kt(S.target) && S.preventDefault();
|
|
3217
3223
|
}, P = (S) => {
|
|
3218
3224
|
const k = Kt(S.target);
|
|
3219
|
-
k && (S.preventDefault(),
|
|
3225
|
+
k && (S.preventDefault(), h(k));
|
|
3220
3226
|
}, M = (S) => {
|
|
3221
3227
|
!p || jt(S, x) || jt(S, t) || H();
|
|
3222
3228
|
}, L = n.registerCommand(
|
|
3223
3229
|
ln,
|
|
3224
|
-
() => (
|
|
3230
|
+
() => (m(), !1),
|
|
3225
3231
|
j
|
|
3226
3232
|
), N = n.registerUpdateListener(() => {
|
|
3227
|
-
|
|
3233
|
+
m();
|
|
3228
3234
|
}), R = n.registerCommand(
|
|
3229
3235
|
cn,
|
|
3230
3236
|
(S) => p ? (S == null || S.preventDefault(), H(), !0) : !1,
|
|
@@ -3233,18 +3239,18 @@ const Qn = {
|
|
|
3233
3239
|
return x.addEventListener("pointerdown", C), x.addEventListener("click", P), document.addEventListener("pointerdown", M, !0), () => {
|
|
3234
3240
|
B(), L(), N(), R(), x.removeEventListener("pointerdown", C), x.removeEventListener("click", P), document.removeEventListener("pointerdown", M, !0), _(), u == null || u.destroy(), y.remove(), x.remove();
|
|
3235
3241
|
};
|
|
3236
|
-
},
|
|
3242
|
+
}, ml = (e) => e.metaKey || e.ctrlKey, gl = {
|
|
3237
3243
|
b: { type: "format.bold" },
|
|
3238
3244
|
i: { type: "format.italic" },
|
|
3239
3245
|
u: { type: "format.underline" },
|
|
3240
3246
|
"\\": { type: "format.clear" }
|
|
3241
|
-
},
|
|
3247
|
+
}, hl = {
|
|
3242
3248
|
x: { type: "format.strike" },
|
|
3243
3249
|
l: { type: "align", value: "left" },
|
|
3244
3250
|
e: { type: "align", value: "center" },
|
|
3245
3251
|
r: { type: "align", value: "right" },
|
|
3246
3252
|
j: { type: "align", value: "justify" }
|
|
3247
|
-
},
|
|
3253
|
+
}, pl = {
|
|
3248
3254
|
0: { type: "block.paragraph" },
|
|
3249
3255
|
1: { type: "block.heading", level: 1 },
|
|
3250
3256
|
2: { type: "block.heading", level: 2 },
|
|
@@ -3252,30 +3258,30 @@ const Qn = {
|
|
|
3252
3258
|
4: { type: "block.heading", level: 4 },
|
|
3253
3259
|
5: { type: "block.heading", level: 5 },
|
|
3254
3260
|
6: { type: "block.heading", level: 6 }
|
|
3255
|
-
},
|
|
3261
|
+
}, fl = (e) => {
|
|
3256
3262
|
const t = e.key.toLowerCase(), n = e.code;
|
|
3257
|
-
if (!e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey || !
|
|
3263
|
+
if (!e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey || !ml(e)) return null;
|
|
3258
3264
|
if (e.altKey) {
|
|
3259
3265
|
if (e.shiftKey) return null;
|
|
3260
3266
|
if (t === "c" || n === "KeyC") return { type: "block.code" };
|
|
3261
3267
|
const r = n.startsWith("Digit") ? n.slice(5) : t;
|
|
3262
|
-
return
|
|
3268
|
+
return pl[r] ?? null;
|
|
3263
3269
|
}
|
|
3264
|
-
return e.shiftKey ? t === "z" ? { type: "history.redo" } : t === "." || t === ">" || n === "Period" ? { type: "block.quote" } : t === "7" || t === "&" || n === "Digit7" ? { type: "list.ordered" } : t === "8" || t === "*" || n === "Digit8" ? { type: "list.unordered" } : t === "9" || t === "(" || n === "Digit9" ? { type: "list.todo" } : t === "-" || t === "_" || n === "Minus" ? { type: "block.divider" } :
|
|
3265
|
-
},
|
|
3270
|
+
return e.shiftKey ? t === "z" ? { type: "history.redo" } : t === "." || t === ">" || n === "Period" ? { type: "block.quote" } : t === "7" || t === "&" || n === "Digit7" ? { type: "list.ordered" } : t === "8" || t === "*" || n === "Digit8" ? { type: "list.unordered" } : t === "9" || t === "(" || n === "Digit9" ? { type: "list.todo" } : t === "-" || t === "_" || n === "Minus" ? { type: "block.divider" } : hl[t] ?? null : t === "z" ? { type: "history.undo" } : t === "y" && e.ctrlKey && !e.metaKey ? { type: "history.redo" } : t === "`" || t === "~" || n === "Backquote" ? { type: "format.inlineCode" } : gl[t] ?? null;
|
|
3271
|
+
}, bl = ({
|
|
3266
3272
|
target: e,
|
|
3267
3273
|
isReadonly: t,
|
|
3268
3274
|
executeCommand: n
|
|
3269
3275
|
}) => {
|
|
3270
3276
|
const r = (o) => {
|
|
3271
3277
|
if (t()) return;
|
|
3272
|
-
const a =
|
|
3278
|
+
const a = fl(o);
|
|
3273
3279
|
a && (o.preventDefault(), n(a));
|
|
3274
3280
|
};
|
|
3275
3281
|
return e.addEventListener("keydown", r), () => {
|
|
3276
3282
|
e.removeEventListener("keydown", r);
|
|
3277
3283
|
};
|
|
3278
|
-
},
|
|
3284
|
+
}, yl = (e, t) => {
|
|
3279
3285
|
const n = t.offsetTop, r = n + t.offsetHeight, o = e.scrollTop, a = o + e.clientHeight;
|
|
3280
3286
|
if (n < o) {
|
|
3281
3287
|
e.scrollTop = n;
|
|
@@ -3298,15 +3304,15 @@ const Qn = {
|
|
|
3298
3304
|
menu: o,
|
|
3299
3305
|
anchor: a,
|
|
3300
3306
|
itemSelector: s,
|
|
3301
|
-
getCurrentTrigger:
|
|
3307
|
+
getCurrentTrigger: i,
|
|
3302
3308
|
getTriggerRect: d,
|
|
3303
|
-
resolveItems:
|
|
3309
|
+
resolveItems: l,
|
|
3304
3310
|
renderItem: g,
|
|
3305
|
-
renderStatus:
|
|
3311
|
+
renderStatus: f,
|
|
3306
3312
|
onStateChange: b,
|
|
3307
3313
|
onSelect: T
|
|
3308
3314
|
}) => {
|
|
3309
|
-
let
|
|
3315
|
+
let v = null, y = 0;
|
|
3310
3316
|
const x = U(o, {
|
|
3311
3317
|
targetSelector: s
|
|
3312
3318
|
}), u = Jn(a, o, {
|
|
@@ -3316,24 +3322,24 @@ const Qn = {
|
|
|
3316
3322
|
});
|
|
3317
3323
|
e.append(a, o);
|
|
3318
3324
|
const p = () => {
|
|
3319
|
-
const k =
|
|
3325
|
+
const k = v ? d(v.trigger) ?? et() : et(), A = t.getBoundingClientRect();
|
|
3320
3326
|
return k ?? A;
|
|
3321
3327
|
}, E = () => {
|
|
3322
3328
|
const k = p();
|
|
3323
3329
|
a.style.left = `${k.left}px`, a.style.top = `${k.top}px`, a.style.height = `${k.height || 1}px`;
|
|
3324
3330
|
}, _ = (k = !0) => {
|
|
3325
|
-
|
|
3331
|
+
v = null, o.dataset.visible = "false", k && o.replaceChildren(), u.setOpen(!1);
|
|
3326
3332
|
}, B = () => {
|
|
3327
3333
|
const k = o.querySelector(`${s}[data-active="true"]`);
|
|
3328
|
-
k &&
|
|
3334
|
+
k && yl(o, k);
|
|
3329
3335
|
}, H = (k, A) => {
|
|
3330
|
-
!
|
|
3336
|
+
!v || v.requestId !== A.requestId || (_(), T(k, A.trigger));
|
|
3331
3337
|
}, I = () => {
|
|
3332
|
-
if (!
|
|
3338
|
+
if (!v) {
|
|
3333
3339
|
_();
|
|
3334
3340
|
return;
|
|
3335
3341
|
}
|
|
3336
|
-
const k =
|
|
3342
|
+
const k = v, A = p();
|
|
3337
3343
|
if ((b == null ? void 0 : b(k, {
|
|
3338
3344
|
anchorRect: A,
|
|
3339
3345
|
close: _,
|
|
@@ -3347,7 +3353,7 @@ const Qn = {
|
|
|
3347
3353
|
...k.items.map((re, pt) => g(re, pt, pt === k.activeIndex))
|
|
3348
3354
|
);
|
|
3349
3355
|
else {
|
|
3350
|
-
const re =
|
|
3356
|
+
const re = f == null ? void 0 : f(
|
|
3351
3357
|
k.status,
|
|
3352
3358
|
k.trigger.query,
|
|
3353
3359
|
k.error
|
|
@@ -3359,10 +3365,10 @@ const Qn = {
|
|
|
3359
3365
|
}, w = async (k, A) => {
|
|
3360
3366
|
let $;
|
|
3361
3367
|
try {
|
|
3362
|
-
$ = await Promise.resolve(
|
|
3368
|
+
$ = await Promise.resolve(l(k));
|
|
3363
3369
|
} catch (J) {
|
|
3364
|
-
(
|
|
3365
|
-
...
|
|
3370
|
+
(v == null ? void 0 : v.requestId) === A && (v = {
|
|
3371
|
+
...v,
|
|
3366
3372
|
items: [],
|
|
3367
3373
|
activeIndex: 0,
|
|
3368
3374
|
status: "error",
|
|
@@ -3370,10 +3376,10 @@ const Qn = {
|
|
|
3370
3376
|
}, I());
|
|
3371
3377
|
return;
|
|
3372
3378
|
}
|
|
3373
|
-
!
|
|
3374
|
-
...
|
|
3379
|
+
!v || A !== v.requestId || (v = {
|
|
3380
|
+
...v,
|
|
3375
3381
|
items: $,
|
|
3376
|
-
activeIndex: Math.min(
|
|
3382
|
+
activeIndex: Math.min(v.activeIndex, Math.max($.length - 1, 0)),
|
|
3377
3383
|
status: $.length > 0 ? "success" : "empty",
|
|
3378
3384
|
error: void 0
|
|
3379
3385
|
}, I());
|
|
@@ -3382,12 +3388,12 @@ const Qn = {
|
|
|
3382
3388
|
_();
|
|
3383
3389
|
return;
|
|
3384
3390
|
}
|
|
3385
|
-
const k = n.getEditorState().read(
|
|
3391
|
+
const k = n.getEditorState().read(i);
|
|
3386
3392
|
if (!k) {
|
|
3387
3393
|
_(!1);
|
|
3388
3394
|
return;
|
|
3389
3395
|
}
|
|
3390
|
-
y += 1,
|
|
3396
|
+
y += 1, v = {
|
|
3391
3397
|
trigger: k,
|
|
3392
3398
|
items: [],
|
|
3393
3399
|
activeIndex: 0,
|
|
@@ -3395,36 +3401,36 @@ const Qn = {
|
|
|
3395
3401
|
status: "loading",
|
|
3396
3402
|
error: void 0
|
|
3397
3403
|
}, I(), w(k.query, y);
|
|
3398
|
-
},
|
|
3399
|
-
if (!
|
|
3400
|
-
const k =
|
|
3404
|
+
}, m = () => {
|
|
3405
|
+
if (!v || v.status !== "success") return !1;
|
|
3406
|
+
const k = v.items[v.activeIndex], A = v.trigger;
|
|
3401
3407
|
return k ? (_(), T(k, A), !0) : !1;
|
|
3402
|
-
},
|
|
3403
|
-
...
|
|
3404
|
-
activeIndex: (
|
|
3408
|
+
}, h = (k) => !v || v.status !== "success" || v.items.length === 0 ? !1 : (v = {
|
|
3409
|
+
...v,
|
|
3410
|
+
activeIndex: (v.activeIndex + k + v.items.length) % v.items.length
|
|
3405
3411
|
}, I(), !0), C = (k) => {
|
|
3406
3412
|
const A = k.target, $ = A instanceof HTMLElement ? A.closest(s) : null, J = $ != null && $.dataset.index ? Number.parseInt($.dataset.index, 10) : Number.NaN;
|
|
3407
|
-
!
|
|
3413
|
+
!v || v.status !== "success" || Number.isNaN(J) || (v = { ...v, activeIndex: J }, k.preventDefault(), m());
|
|
3408
3414
|
}, P = (k) => {
|
|
3409
3415
|
const A = k.target;
|
|
3410
3416
|
A instanceof HTMLElement && A.closest(s) && k.preventDefault();
|
|
3411
3417
|
}, M = n.registerUpdateListener(() => {
|
|
3412
3418
|
c();
|
|
3413
3419
|
}), L = n.registerCommand(
|
|
3414
|
-
|
|
3415
|
-
(k) =>
|
|
3420
|
+
xr,
|
|
3421
|
+
(k) => h(1) ? (k == null || k.preventDefault(), !0) : !1,
|
|
3416
3422
|
j
|
|
3417
3423
|
), N = n.registerCommand(
|
|
3418
|
-
|
|
3419
|
-
(k) =>
|
|
3424
|
+
Er,
|
|
3425
|
+
(k) => h(-1) ? (k == null || k.preventDefault(), !0) : !1,
|
|
3420
3426
|
j
|
|
3421
3427
|
), R = n.registerCommand(
|
|
3422
3428
|
Mr,
|
|
3423
|
-
(k) =>
|
|
3429
|
+
(k) => m() ? (k == null || k.preventDefault(), !0) : !1,
|
|
3424
3430
|
j
|
|
3425
3431
|
), S = n.registerCommand(
|
|
3426
3432
|
cn,
|
|
3427
|
-
(k) =>
|
|
3433
|
+
(k) => v ? (k == null || k.preventDefault(), _(), !0) : !1,
|
|
3428
3434
|
j
|
|
3429
3435
|
);
|
|
3430
3436
|
return o.addEventListener("click", C), o.addEventListener("pointerdown", P), {
|
|
@@ -3433,7 +3439,7 @@ const Qn = {
|
|
|
3433
3439
|
M(), L(), N(), R(), S(), o.removeEventListener("click", C), o.removeEventListener("pointerdown", P), x(), u.destroy(), a.remove(), o.remove();
|
|
3434
3440
|
}
|
|
3435
3441
|
};
|
|
3436
|
-
},
|
|
3442
|
+
}, vl = {
|
|
3437
3443
|
labelField: "label",
|
|
3438
3444
|
descriptionField: "description",
|
|
3439
3445
|
avatarField: "avatar",
|
|
@@ -3444,27 +3450,27 @@ const Qn = {
|
|
|
3444
3450
|
loadingText: "加载中",
|
|
3445
3451
|
emptyText: "没有匹配的提及",
|
|
3446
3452
|
errorText: "提及加载失败"
|
|
3447
|
-
},
|
|
3448
|
-
...
|
|
3453
|
+
}, wl = (e) => ({
|
|
3454
|
+
...vl,
|
|
3449
3455
|
...e
|
|
3450
|
-
}),
|
|
3456
|
+
}), Cl = (e, t) => {
|
|
3451
3457
|
var o;
|
|
3452
3458
|
const n = t.slice(5), r = (o = e.data) == null ? void 0 : o[n];
|
|
3453
3459
|
return typeof r == "string" && r ? r : void 0;
|
|
3454
3460
|
}, Te = (e, t) => {
|
|
3455
|
-
if (t.startsWith("data.")) return
|
|
3461
|
+
if (t.startsWith("data.")) return Cl(e, t);
|
|
3456
3462
|
const n = t === "id" ? e.id : t === "label" ? e.label : t === "value" ? e.value : t === "avatar" ? e.avatar : e.description;
|
|
3457
3463
|
return typeof n == "string" && n ? n : void 0;
|
|
3458
|
-
},
|
|
3464
|
+
}, _l = (e) => e.startsWith("@") ? e : `@${e}`, tr = (e, t) => {
|
|
3459
3465
|
const n = Te(e, t.labelField) ?? e.label ?? e.value ?? e.id, r = t.showDescription ? Te(e, t.descriptionField) ?? e.description : void 0, o = t.showAvatar ? Te(e, t.avatarField) ?? e.avatar : void 0, a = t.showIcon && !o ? Te(e, t.iconField) : void 0;
|
|
3460
3466
|
return {
|
|
3461
3467
|
item: e,
|
|
3462
|
-
label:
|
|
3468
|
+
label: _l(n),
|
|
3463
3469
|
...r ? { description: r } : {},
|
|
3464
3470
|
...o ? { avatar: o } : {},
|
|
3465
3471
|
...a ? { icon: a } : {}
|
|
3466
3472
|
};
|
|
3467
|
-
},
|
|
3473
|
+
}, kl = (e, t) => e.map((n) => tr(n, t)), tt = (e) => e instanceof Y && e.getTextContent().startsWith(" "), xl = (e) => {
|
|
3468
3474
|
const n = e.getTextContent().slice(1);
|
|
3469
3475
|
if (!n) {
|
|
3470
3476
|
e.remove();
|
|
@@ -3473,27 +3479,27 @@ const Qn = {
|
|
|
3473
3479
|
e.setTextContent(n);
|
|
3474
3480
|
}, El = (e, t) => {
|
|
3475
3481
|
const n = e.getPreviousSibling(), r = e.getNextSibling(), o = tt(r) ? r.getNextSibling() : r;
|
|
3476
|
-
if (tt(r) &&
|
|
3482
|
+
if (tt(r) && xl(r), e.remove(), t) {
|
|
3477
3483
|
n == null || n.selectEnd();
|
|
3478
3484
|
return;
|
|
3479
3485
|
}
|
|
3480
3486
|
o == null || o.selectStart();
|
|
3481
|
-
},
|
|
3487
|
+
}, Ml = (e) => {
|
|
3482
3488
|
const t = D();
|
|
3483
3489
|
if (!O(t) || !t.isCollapsed()) return null;
|
|
3484
3490
|
const n = t.anchor, r = n.getNode();
|
|
3485
3491
|
if (Lt(r)) return r;
|
|
3486
3492
|
if (!(r instanceof Y)) return null;
|
|
3487
|
-
const o = r.getTextContentSize(), a = r.getPreviousSibling(), s = r.getNextSibling(),
|
|
3493
|
+
const o = r.getTextContentSize(), a = r.getPreviousSibling(), s = r.getNextSibling(), i = tt(r) && n.offset === 1, d = e ? n.offset === 0 || i ? a : null : n.offset === o ? s : null;
|
|
3488
3494
|
return Lt(d) ? d : null;
|
|
3489
|
-
},
|
|
3495
|
+
}, Tl = (e, t, n) => {
|
|
3490
3496
|
const r = (a) => {
|
|
3491
3497
|
if (t()) return !1;
|
|
3492
|
-
const s =
|
|
3498
|
+
const s = Ml(a);
|
|
3493
3499
|
return s ? (El(s, a), n(), !0) : !1;
|
|
3494
3500
|
}, o = (a, s) => {
|
|
3495
|
-
const
|
|
3496
|
-
return
|
|
3501
|
+
const i = r(s);
|
|
3502
|
+
return i && a.preventDefault(), i;
|
|
3497
3503
|
};
|
|
3498
3504
|
return [
|
|
3499
3505
|
e.registerCommand(
|
|
@@ -3512,40 +3518,40 @@ const Qn = {
|
|
|
3512
3518
|
G
|
|
3513
3519
|
)
|
|
3514
3520
|
];
|
|
3515
|
-
},
|
|
3521
|
+
}, Ll = /(?:^|\s)@([\p{L}\p{N}_-]*)$/u, qt = [
|
|
3516
3522
|
{ id: "bridgerte-team", label: "BridgeRTE Team", value: "bridgerte-team" },
|
|
3517
3523
|
{ id: "frontend", label: "Frontend", value: "frontend" },
|
|
3518
3524
|
{ id: "designer", label: "Designer", value: "designer" }
|
|
3519
|
-
],
|
|
3520
|
-
const t =
|
|
3521
|
-
return t ? qt.filter((n) =>
|
|
3522
|
-
},
|
|
3525
|
+
], Sl = (e) => e.trim().toLowerCase(), Nl = (e) => [e.label, e.value, e.description].filter(Boolean).join(" ").toLowerCase(), Pl = (e) => {
|
|
3526
|
+
const t = Sl(e);
|
|
3527
|
+
return t ? qt.filter((n) => Nl(n).includes(t)) : qt;
|
|
3528
|
+
}, Il = () => {
|
|
3523
3529
|
const e = D();
|
|
3524
3530
|
if (!O(e) || !e.isCollapsed()) return null;
|
|
3525
3531
|
const t = e.anchor, n = t.getNode();
|
|
3526
3532
|
if (!(n instanceof Y)) return null;
|
|
3527
|
-
const o = n.getTextContent().slice(0, t.offset).match(
|
|
3533
|
+
const o = n.getTextContent().slice(0, t.offset).match(Ll);
|
|
3528
3534
|
if (!o) return null;
|
|
3529
|
-
const a = o[1] ?? "", s = o[0] ?? "",
|
|
3535
|
+
const a = o[1] ?? "", s = o[0] ?? "", i = s.startsWith("@") ? 0 : 1, d = t.offset - s.length + i;
|
|
3530
3536
|
return {
|
|
3531
3537
|
query: a,
|
|
3532
3538
|
nodeKey: n.getKey(),
|
|
3533
3539
|
startOffset: d,
|
|
3534
3540
|
endOffset: t.offset
|
|
3535
3541
|
};
|
|
3536
|
-
},
|
|
3542
|
+
}, Rl = () => {
|
|
3537
3543
|
const e = document.createElement("div");
|
|
3538
3544
|
return e.className = "bridgerte__floating-menu bridgerte__mention-menu", e.dataset.visible = "false", e;
|
|
3539
|
-
},
|
|
3545
|
+
}, Al = () => {
|
|
3540
3546
|
const e = document.createElement("span");
|
|
3541
3547
|
return e.className = "bridgerte__mention-anchor", e.setAttribute("aria-hidden", "true"), e;
|
|
3542
|
-
},
|
|
3548
|
+
}, Bl = (e, t) => {
|
|
3543
3549
|
var s;
|
|
3544
3550
|
const n = e.getElementByKey(t.nodeKey), r = ut(n, t.startOffset + 1);
|
|
3545
3551
|
if (!(r instanceof Text)) return null;
|
|
3546
3552
|
const o = document.createRange(), a = Math.min(t.startOffset + 1, ((s = r.textContent) == null ? void 0 : s.length) ?? 0);
|
|
3547
3553
|
return a <= t.startOffset ? null : (o.setStart(r, t.startOffset), o.setEnd(r, a), o.getBoundingClientRect());
|
|
3548
|
-
},
|
|
3554
|
+
}, Dl = (e, t, n) => {
|
|
3549
3555
|
const r = document.createElement("button"), o = document.createElement("span");
|
|
3550
3556
|
if (r.type = "button", r.className = "bridgerte__menu-item bridgerte__mention-item", r.dataset.mentionId = e.item.id, r.dataset.index = String(t), r.dataset.active = String(n), e.avatar) {
|
|
3551
3557
|
const a = document.createElement("img");
|
|
@@ -3559,10 +3565,10 @@ const Qn = {
|
|
|
3559
3565
|
a.className = "bridgerte__mention-item-description", a.textContent = e.description, r.append(a);
|
|
3560
3566
|
}
|
|
3561
3567
|
return r;
|
|
3562
|
-
},
|
|
3568
|
+
}, Hl = (e, t) => {
|
|
3563
3569
|
const n = document.createElement("div");
|
|
3564
3570
|
return n.className = "bridgerte__mention-status", n.dataset.status = e, n.textContent = t, n;
|
|
3565
|
-
},
|
|
3571
|
+
}, Ol = (e, t) => {
|
|
3566
3572
|
switch (e) {
|
|
3567
3573
|
case "loading":
|
|
3568
3574
|
return t.loadingText;
|
|
@@ -3571,12 +3577,12 @@ const Qn = {
|
|
|
3571
3577
|
case "error":
|
|
3572
3578
|
return t.errorText;
|
|
3573
3579
|
}
|
|
3574
|
-
},
|
|
3580
|
+
}, $l = (e) => e ? {
|
|
3575
3581
|
x: e.x,
|
|
3576
3582
|
y: e.y,
|
|
3577
3583
|
width: e.width,
|
|
3578
3584
|
height: e.height
|
|
3579
|
-
} : void 0,
|
|
3585
|
+
} : void 0, Fl = ({
|
|
3580
3586
|
editorRoot: e,
|
|
3581
3587
|
contentElement: t,
|
|
3582
3588
|
editor: n,
|
|
@@ -3584,56 +3590,56 @@ const Qn = {
|
|
|
3584
3590
|
executeCommand: o,
|
|
3585
3591
|
mentionProvider: a,
|
|
3586
3592
|
mentionMenuConfig: s,
|
|
3587
|
-
onMentionMenuRequest:
|
|
3593
|
+
onMentionMenuRequest: i
|
|
3588
3594
|
}) => {
|
|
3589
|
-
const d =
|
|
3595
|
+
const d = Rl(), l = Al(), g = wl(s), f = (v, y) => {
|
|
3590
3596
|
n.update(() => {
|
|
3591
3597
|
const x = he(y.nodeKey);
|
|
3592
3598
|
x instanceof Y && (x.spliceText(y.startOffset, y.endOffset - y.startOffset, ""), x.select(y.startOffset, y.startOffset));
|
|
3593
|
-
}), o({ type: "mention.insert", item:
|
|
3599
|
+
}), o({ type: "mention.insert", item: v });
|
|
3594
3600
|
}, b = er({
|
|
3595
3601
|
editorRoot: e,
|
|
3596
3602
|
contentElement: t,
|
|
3597
3603
|
editor: n,
|
|
3598
3604
|
isReadonly: r,
|
|
3599
3605
|
menu: d,
|
|
3600
|
-
anchor:
|
|
3606
|
+
anchor: l,
|
|
3601
3607
|
itemSelector: ".bridgerte__mention-item",
|
|
3602
|
-
getCurrentTrigger:
|
|
3603
|
-
getTriggerRect: (
|
|
3604
|
-
resolveItems: async (
|
|
3608
|
+
getCurrentTrigger: Il,
|
|
3609
|
+
getTriggerRect: (v) => Bl(n, v),
|
|
3610
|
+
resolveItems: async (v) => {
|
|
3605
3611
|
const y = await Promise.resolve(
|
|
3606
|
-
a ? a(
|
|
3612
|
+
a ? a(v) : Pl(v)
|
|
3607
3613
|
);
|
|
3608
|
-
return
|
|
3614
|
+
return kl(y, g);
|
|
3609
3615
|
},
|
|
3610
|
-
renderItem:
|
|
3611
|
-
renderStatus: (
|
|
3612
|
-
|
|
3613
|
-
|
|
3616
|
+
renderItem: Dl,
|
|
3617
|
+
renderStatus: (v) => Hl(
|
|
3618
|
+
v,
|
|
3619
|
+
Ol(v, g)
|
|
3614
3620
|
),
|
|
3615
|
-
onStateChange:
|
|
3616
|
-
id: `bridgerte-mention-menu-${
|
|
3617
|
-
query:
|
|
3618
|
-
status:
|
|
3619
|
-
items:
|
|
3621
|
+
onStateChange: i ? (v, y) => i({
|
|
3622
|
+
id: `bridgerte-mention-menu-${v.requestId}`,
|
|
3623
|
+
query: v.trigger.query,
|
|
3624
|
+
status: v.status,
|
|
3625
|
+
items: v.items,
|
|
3620
3626
|
config: g,
|
|
3621
3627
|
readonly: r(),
|
|
3622
|
-
anchorRect:
|
|
3623
|
-
...
|
|
3628
|
+
anchorRect: $l(y.anchorRect),
|
|
3629
|
+
...v.error ? { error: v.error } : {},
|
|
3624
3630
|
submit: (x) => y.selectItem(
|
|
3625
3631
|
tr(x, g)
|
|
3626
3632
|
),
|
|
3627
3633
|
cancel: y.close
|
|
3628
3634
|
}) : void 0,
|
|
3629
|
-
onSelect: (
|
|
3635
|
+
onSelect: (v, y) => f(v.item, y)
|
|
3630
3636
|
}), T = dn(
|
|
3631
|
-
...
|
|
3637
|
+
...Tl(n, r, () => b.close(!1))
|
|
3632
3638
|
);
|
|
3633
3639
|
return () => {
|
|
3634
3640
|
T(), b.destroy();
|
|
3635
3641
|
};
|
|
3636
|
-
},
|
|
3642
|
+
}, zl = [
|
|
3637
3643
|
"script",
|
|
3638
3644
|
"style",
|
|
3639
3645
|
"iframe",
|
|
@@ -3650,7 +3656,7 @@ const Qn = {
|
|
|
3650
3656
|
"button",
|
|
3651
3657
|
"select",
|
|
3652
3658
|
"textarea"
|
|
3653
|
-
].join(","),
|
|
3659
|
+
].join(","), Vl = [
|
|
3654
3660
|
".bridgerte__code-header",
|
|
3655
3661
|
".bridgerte__code-block-controls",
|
|
3656
3662
|
".bridgerte__code-block-control-button",
|
|
@@ -3665,7 +3671,7 @@ const Qn = {
|
|
|
3665
3671
|
".bridgerte__dialog",
|
|
3666
3672
|
".bridgerte__payload-panel",
|
|
3667
3673
|
'[data-bridgerte-clipboard-ui="true"]'
|
|
3668
|
-
].join(","),
|
|
3674
|
+
].join(","), Wl = /* @__PURE__ */ new Set([
|
|
3669
3675
|
"A",
|
|
3670
3676
|
"B",
|
|
3671
3677
|
"BLOCKQUOTE",
|
|
@@ -3702,16 +3708,16 @@ const Qn = {
|
|
|
3702
3708
|
"TT",
|
|
3703
3709
|
"U",
|
|
3704
3710
|
"UL"
|
|
3705
|
-
]),
|
|
3711
|
+
]), Ul = /* @__PURE__ */ new Set(["http:", "https:", "mailto:"]), jl = "p,div,blockquote,pre,h1,h2,h3,h4,h5,h6,ul,ol,table", Kl = "p,blockquote,pre,h1,h2,h3,h4,h5,h6,ul,ol,table", ql = /* @__PURE__ */ new Set(["colspan", "rowspan"]), Gl = /* @__PURE__ */ new Set(["TD", "TH"]), Xl = /* @__PURE__ */ new Set(["M", "O", "V", "W"]), Yl = /* @__PURE__ */ new Set(["SPAN"]), Jl = /* @__PURE__ */ new Set(["color", "background-color"]), Ql = /^#([\da-f]{3}|[\da-f]{6}|[\da-f]{8})$/i, Gt = /* @__PURE__ */ new Map([
|
|
3706
3712
|
["B", "strong"],
|
|
3707
3713
|
["DEL", "s"],
|
|
3708
3714
|
["I", "em"],
|
|
3709
3715
|
["STRIKE", "s"],
|
|
3710
3716
|
["TT", "code"]
|
|
3711
|
-
]),
|
|
3717
|
+
]), Zl = (e) => {
|
|
3712
3718
|
try {
|
|
3713
3719
|
const t = new URL(e, window.location.href);
|
|
3714
|
-
return
|
|
3720
|
+
return Ul.has(t.protocol);
|
|
3715
3721
|
} catch {
|
|
3716
3722
|
return !1;
|
|
3717
3723
|
}
|
|
@@ -3720,9 +3726,9 @@ const Qn = {
|
|
|
3720
3726
|
}, gt = (e, t) => {
|
|
3721
3727
|
const n = e.ownerDocument.createElement(t);
|
|
3722
3728
|
return n.append(...e.childNodes), e.replaceWith(n), n;
|
|
3723
|
-
},
|
|
3729
|
+
}, ec = (e) => {
|
|
3724
3730
|
const t = e.tagName.split(":")[0] ?? "";
|
|
3725
|
-
return e.tagName.includes(":") &&
|
|
3731
|
+
return e.tagName.includes(":") && Xl.has(t);
|
|
3726
3732
|
}, nr = (e) => {
|
|
3727
3733
|
[...e.childNodes].forEach((t) => {
|
|
3728
3734
|
if (t.nodeType === Node.COMMENT_NODE) {
|
|
@@ -3745,22 +3751,22 @@ const Qn = {
|
|
|
3745
3751
|
}
|
|
3746
3752
|
rr(t);
|
|
3747
3753
|
});
|
|
3748
|
-
},
|
|
3749
|
-
const t = e.trim().toLowerCase(), [, n] = t.match(
|
|
3754
|
+
}, tc = (e) => /^[1-9]\d*$/.test(e.trim()), ht = (e) => {
|
|
3755
|
+
const t = e.trim().toLowerCase(), [, n] = t.match(Ql) ?? [];
|
|
3750
3756
|
return n ? n.length === 8 ? `#${n.slice(2)}` : t : null;
|
|
3751
|
-
},
|
|
3752
|
-
if (!
|
|
3757
|
+
}, nc = (e, t) => {
|
|
3758
|
+
if (!Yl.has(e)) return null;
|
|
3753
3759
|
const n = t.split(";").flatMap((r) => {
|
|
3754
|
-
const [o, ...a] = r.split(":"), s = o == null ? void 0 : o.trim().toLowerCase(),
|
|
3755
|
-
return !s || !
|
|
3760
|
+
const [o, ...a] = r.split(":"), s = o == null ? void 0 : o.trim().toLowerCase(), i = ht(a.join(":"));
|
|
3761
|
+
return !s || !i || !Jl.has(s) ? [] : [`${s}: ${i}`];
|
|
3756
3762
|
});
|
|
3757
3763
|
return n.length > 0 ? `${n.join("; ")};` : null;
|
|
3758
|
-
},
|
|
3759
|
-
if (
|
|
3764
|
+
}, rc = (e) => {
|
|
3765
|
+
if (ec(e)) {
|
|
3760
3766
|
e.remove();
|
|
3761
3767
|
return;
|
|
3762
3768
|
}
|
|
3763
|
-
if (!
|
|
3769
|
+
if (!Wl.has(e.tagName)) {
|
|
3764
3770
|
mt(e);
|
|
3765
3771
|
return;
|
|
3766
3772
|
}
|
|
@@ -3771,7 +3777,7 @@ const Qn = {
|
|
|
3771
3777
|
return;
|
|
3772
3778
|
}
|
|
3773
3779
|
if (n === "style") {
|
|
3774
|
-
const r =
|
|
3780
|
+
const r = nc(e.tagName, t.value);
|
|
3775
3781
|
if (r) {
|
|
3776
3782
|
e.setAttribute(t.name, r);
|
|
3777
3783
|
return;
|
|
@@ -3780,7 +3786,7 @@ const Qn = {
|
|
|
3780
3786
|
return;
|
|
3781
3787
|
}
|
|
3782
3788
|
if (e.tagName === "A" && n === "href") {
|
|
3783
|
-
if (
|
|
3789
|
+
if (Zl(t.value)) return;
|
|
3784
3790
|
e.removeAttribute(t.name);
|
|
3785
3791
|
return;
|
|
3786
3792
|
}
|
|
@@ -3799,39 +3805,39 @@ const Qn = {
|
|
|
3799
3805
|
e.removeAttribute(t.name);
|
|
3800
3806
|
return;
|
|
3801
3807
|
}
|
|
3802
|
-
|
|
3808
|
+
Gl.has(e.tagName) && ql.has(n) && tc(t.value) || e.removeAttribute(t.name);
|
|
3803
3809
|
}
|
|
3804
3810
|
});
|
|
3805
|
-
},
|
|
3811
|
+
}, oc = (e) => {
|
|
3806
3812
|
[...e.querySelectorAll("font")].forEach((t) => {
|
|
3807
3813
|
const n = t.getAttribute("color"), r = n ? ht(n) : null, o = gt(t, "span");
|
|
3808
3814
|
r && o.setAttribute("style", `color: ${r};`);
|
|
3809
3815
|
});
|
|
3810
|
-
},
|
|
3816
|
+
}, ac = (e) => {
|
|
3811
3817
|
[...e.querySelectorAll([...Gt.keys()].join(","))].forEach((t) => {
|
|
3812
3818
|
const n = Gt.get(t.tagName);
|
|
3813
3819
|
n && gt(t, n);
|
|
3814
3820
|
});
|
|
3815
|
-
},
|
|
3821
|
+
}, sc = (e) => {
|
|
3816
3822
|
[...e.querySelectorAll("div")].reverse().forEach((t) => {
|
|
3817
|
-
if (t.querySelector(
|
|
3823
|
+
if (t.querySelector(Kl)) {
|
|
3818
3824
|
mt(t);
|
|
3819
3825
|
return;
|
|
3820
3826
|
}
|
|
3821
3827
|
gt(t, "p");
|
|
3822
3828
|
});
|
|
3823
|
-
},
|
|
3829
|
+
}, ic = (e) => {
|
|
3824
3830
|
[...e.querySelectorAll("span")].forEach((t) => {
|
|
3825
3831
|
t.attributes.length === 0 && mt(t);
|
|
3826
3832
|
});
|
|
3827
|
-
},
|
|
3833
|
+
}, lc = (e) => !["P", "DIV", "SPAN"].includes(e.tagName) || e.querySelector("br,table,ul,ol") ? !1 : !(e.textContent ?? "").trim(), Xt = (e) => {
|
|
3828
3834
|
[...e.querySelectorAll("p,div,span")].reverse().forEach((t) => {
|
|
3829
|
-
|
|
3835
|
+
lc(t) && t.remove();
|
|
3830
3836
|
});
|
|
3831
|
-
}, lc = (e) => {
|
|
3832
|
-
var t;
|
|
3833
|
-
return e.nodeType === Node.TEXT_NODE ? !!((t = e.textContent) != null && t.trim()) : e.nodeType !== Node.ELEMENT_NODE ? !1 : !e.matches(Ul);
|
|
3834
3837
|
}, cc = (e) => {
|
|
3838
|
+
var t;
|
|
3839
|
+
return e.nodeType === Node.TEXT_NODE ? !!((t = e.textContent) != null && t.trim()) : e.nodeType !== Node.ELEMENT_NODE ? !1 : !e.matches(jl);
|
|
3840
|
+
}, dc = (e) => {
|
|
3835
3841
|
let t = [];
|
|
3836
3842
|
const n = () => {
|
|
3837
3843
|
if (t.length === 0) return;
|
|
@@ -3846,47 +3852,47 @@ const Qn = {
|
|
|
3846
3852
|
r.remove();
|
|
3847
3853
|
return;
|
|
3848
3854
|
}
|
|
3849
|
-
if (
|
|
3855
|
+
if (cc(r)) {
|
|
3850
3856
|
t.push(r);
|
|
3851
3857
|
return;
|
|
3852
3858
|
}
|
|
3853
3859
|
n();
|
|
3854
3860
|
}), n();
|
|
3855
|
-
},
|
|
3861
|
+
}, uc = (e) => {
|
|
3856
3862
|
const t = document.createElement("template");
|
|
3857
|
-
t.innerHTML = e, t.content.querySelectorAll(
|
|
3863
|
+
t.innerHTML = e, t.content.querySelectorAll(zl).forEach((r) => {
|
|
3858
3864
|
r.remove();
|
|
3859
|
-
}), t.content.querySelectorAll(
|
|
3865
|
+
}), t.content.querySelectorAll(Vl).forEach((r) => {
|
|
3860
3866
|
r.remove();
|
|
3861
|
-
}), nr(t.content),
|
|
3867
|
+
}), nr(t.content), hs(t.content), [...t.content.querySelectorAll("*")].forEach(rc), rr(t.content), oc(t.content), ac(t.content), sc(t.content), ic(t.content), Xt(t.content);
|
|
3862
3868
|
const n = document.createElement("div");
|
|
3863
|
-
return n.append(t.content.cloneNode(!0)),
|
|
3864
|
-
},
|
|
3869
|
+
return n.append(t.content.cloneNode(!0)), dc(n), Xt(n), n.innerHTML;
|
|
3870
|
+
}, mc = /^https?:\/\/[^\s<>"']+\.[^\s<>"']+$/i, gc = /^www\.[^\s<>"']+\.[^\s<>"']+$/i, hc = new RegExp(
|
|
3865
3871
|
`^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+(?:/[^\\s<>"']*)?$`,
|
|
3866
3872
|
"i"
|
|
3867
|
-
),
|
|
3868
|
-
const n =
|
|
3873
|
+
), pc = /^[^\s@]+@[^\s@]+\.[^\s@]+$/i, fc = /^\s*```([a-z0-9_+#.-]+)\s*\n([\s\S]*?)\n?```\s*$/i, bc = (e) => e.type.startsWith("image/") ? "image" : e.type.startsWith("video/") ? "video" : null, or = (e) => e ? [...e].flatMap((t) => {
|
|
3874
|
+
const n = bc(t);
|
|
3869
3875
|
return n ? [{ type: n, file: t }] : [];
|
|
3870
3876
|
}) : [], Oe = (e) => ({
|
|
3871
3877
|
text: (e == null ? void 0 : e.getData("text/plain")) ?? "",
|
|
3872
3878
|
html: (e == null ? void 0 : e.getData("text/html")) ?? "",
|
|
3873
3879
|
files: e != null && e.files ? [...e.files] : []
|
|
3874
|
-
}),
|
|
3880
|
+
}), yc = (e) => ({
|
|
3875
3881
|
name: e.name,
|
|
3876
3882
|
mimeType: e.type || void 0,
|
|
3877
3883
|
size: e.size,
|
|
3878
3884
|
data: e
|
|
3879
|
-
}),
|
|
3885
|
+
}), vc = (e) => {
|
|
3880
3886
|
const [, t, n] = e.replace(/\r\n/g, `
|
|
3881
|
-
`).match(
|
|
3887
|
+
`).match(fc) ?? [], r = ne(t);
|
|
3882
3888
|
return n !== void 0 && r !== null ? { code: n, language: r } : null;
|
|
3883
|
-
},
|
|
3889
|
+
}, wc = (e) => {
|
|
3884
3890
|
const t = e.trim();
|
|
3885
|
-
return !t || /\s/.test(t) || t.includes("<") || t.includes(">") || /^[a-z][a-z0-9+.-]*:/i.test(t) && !/^https?:\/\//i.test(t) ||
|
|
3891
|
+
return !t || /\s/.test(t) || t.includes("<") || t.includes(">") || /^[a-z][a-z0-9+.-]*:/i.test(t) && !/^https?:\/\//i.test(t) || pc.test(t) ? !1 : mc.test(t) || gc.test(t) || hc.test(t);
|
|
3886
3892
|
}, ar = (e, {
|
|
3887
3893
|
isReadonly: t,
|
|
3888
3894
|
executeCommand: n
|
|
3889
|
-
}) => t() || !
|
|
3895
|
+
}) => t() || !wc(e.text) ? !1 : (n({
|
|
3890
3896
|
type: "link.set",
|
|
3891
3897
|
href: e.text.trim()
|
|
3892
3898
|
}), !0), nt = (e, {
|
|
@@ -3899,13 +3905,13 @@ const Qn = {
|
|
|
3899
3905
|
return o.length === 0 ? !1 : (o.forEach(({ type: a, file: s }) => {
|
|
3900
3906
|
r(a, s);
|
|
3901
3907
|
}), !0);
|
|
3902
|
-
},
|
|
3908
|
+
}, Cc = (e, t) => {
|
|
3903
3909
|
const r = new DOMParser().parseFromString(t, "text/html");
|
|
3904
|
-
|
|
3910
|
+
ps(r.body);
|
|
3905
3911
|
const o = fn(e, r);
|
|
3906
|
-
return
|
|
3907
|
-
},
|
|
3908
|
-
const n =
|
|
3912
|
+
return fs(o, r.body), o;
|
|
3913
|
+
}, _c = (e, t) => {
|
|
3914
|
+
const n = Cc(e, t);
|
|
3909
3915
|
if (n.length === 0) return !1;
|
|
3910
3916
|
if (D() || F().selectEnd(), n.some(X)) {
|
|
3911
3917
|
n.forEach((o) => {
|
|
@@ -3915,22 +3921,22 @@ const Qn = {
|
|
|
3915
3921
|
return r && X(r) && W([z()]), !0;
|
|
3916
3922
|
}
|
|
3917
3923
|
return W(n), !0;
|
|
3918
|
-
},
|
|
3924
|
+
}, kc = (e, {
|
|
3919
3925
|
editor: t,
|
|
3920
3926
|
isReadonly: n
|
|
3921
3927
|
}) => {
|
|
3922
3928
|
if (n()) return !1;
|
|
3923
3929
|
if (!e.html.trim()) return Ec(e, { editor: t, isReadonly: n });
|
|
3924
|
-
const r =
|
|
3930
|
+
const r = uc(e.html);
|
|
3925
3931
|
return r.trim() ? (t.update(() => {
|
|
3926
|
-
|
|
3932
|
+
_c(t, r);
|
|
3927
3933
|
}), !0) : !1;
|
|
3928
|
-
},
|
|
3934
|
+
}, xc = (e, {
|
|
3929
3935
|
editor: t,
|
|
3930
3936
|
isReadonly: n
|
|
3931
3937
|
}) => {
|
|
3932
3938
|
if (n() || e.html.trim() || !e.text.trim()) return !1;
|
|
3933
|
-
const r =
|
|
3939
|
+
const r = vc(e.text);
|
|
3934
3940
|
return r ? (t.update(() => {
|
|
3935
3941
|
const o = Bn(r.language || void 0), a = z();
|
|
3936
3942
|
D() || F().selectEnd(), o.append(Be(r.code)), bn(o), W([a]), a.selectStart();
|
|
@@ -3940,16 +3946,16 @@ const Qn = {
|
|
|
3940
3946
|
isReadonly: n
|
|
3941
3947
|
}) => n() || e.html.trim() || !e.text ? !1 : (t.update(() => {
|
|
3942
3948
|
D() || F().selectEnd(), W([Be(e.text)]);
|
|
3943
|
-
}), !0), sr = (e, t) =>
|
|
3949
|
+
}), !0), sr = (e, t) => xc(e, t) || kc(e, t), te = (e) => {
|
|
3944
3950
|
e.preventDefault(), e.stopImmediatePropagation();
|
|
3945
|
-
},
|
|
3951
|
+
}, Mc = (e, t) => nt(e, t) || ar(e, t) || sr(e, t), Tc = (e) => {
|
|
3946
3952
|
const t = (n) => {
|
|
3947
3953
|
n.defaultPrevented || ar(Oe(n.clipboardData), e) && te(n);
|
|
3948
3954
|
};
|
|
3949
3955
|
return e.target.addEventListener("paste", t, { capture: !0 }), () => {
|
|
3950
3956
|
e.target.removeEventListener("paste", t, { capture: !0 });
|
|
3951
3957
|
};
|
|
3952
|
-
},
|
|
3958
|
+
}, Lc = (e) => {
|
|
3953
3959
|
const t = (o) => {
|
|
3954
3960
|
o.defaultPrevented || nt(Oe(o.clipboardData), e) && te(o);
|
|
3955
3961
|
}, n = (o) => {
|
|
@@ -3967,14 +3973,14 @@ const Qn = {
|
|
|
3967
3973
|
return e.target.addEventListener("paste", t, { capture: !0 }), e.target.addEventListener("dragover", n), e.target.addEventListener("drop", r), () => {
|
|
3968
3974
|
e.target.removeEventListener("paste", t, { capture: !0 }), e.target.removeEventListener("dragover", n), e.target.removeEventListener("drop", r);
|
|
3969
3975
|
};
|
|
3970
|
-
},
|
|
3976
|
+
}, Sc = (e) => {
|
|
3971
3977
|
const t = (n) => {
|
|
3972
3978
|
n.defaultPrevented || !sr(Oe(n.clipboardData), e) || te(n);
|
|
3973
3979
|
};
|
|
3974
3980
|
return e.target.addEventListener("paste", t, { capture: !0 }), () => {
|
|
3975
3981
|
e.target.removeEventListener("paste", t, { capture: !0 });
|
|
3976
3982
|
};
|
|
3977
|
-
},
|
|
3983
|
+
}, Nc = ({
|
|
3978
3984
|
target: e,
|
|
3979
3985
|
isReadonly: t,
|
|
3980
3986
|
onPaste: n,
|
|
@@ -3983,54 +3989,54 @@ const Qn = {
|
|
|
3983
3989
|
executeCommand: a,
|
|
3984
3990
|
editor: s
|
|
3985
3991
|
}) => {
|
|
3986
|
-
const
|
|
3987
|
-
text: g.text ??
|
|
3988
|
-
html: g.html ??
|
|
3989
|
-
files:
|
|
3992
|
+
const i = (l, g) => Mc({
|
|
3993
|
+
text: g.text ?? l.text,
|
|
3994
|
+
html: g.html ?? l.html,
|
|
3995
|
+
files: l.files
|
|
3990
3996
|
}, {
|
|
3991
3997
|
isReadonly: t,
|
|
3992
3998
|
canUploadMedia: r,
|
|
3993
3999
|
uploadMediaFile: o,
|
|
3994
4000
|
executeCommand: a,
|
|
3995
4001
|
editor: s
|
|
3996
|
-
}), d = (
|
|
4002
|
+
}), d = (l) => {
|
|
3997
4003
|
if (t() || !n) return;
|
|
3998
|
-
const g = Oe(
|
|
4004
|
+
const g = Oe(l.clipboardData), f = n({
|
|
3999
4005
|
text: g.text,
|
|
4000
4006
|
html: g.html,
|
|
4001
|
-
files: g.files.map(
|
|
4007
|
+
files: g.files.map(yc)
|
|
4002
4008
|
});
|
|
4003
|
-
if (
|
|
4004
|
-
te(
|
|
4005
|
-
b !== !0 && b &&
|
|
4009
|
+
if (f instanceof Promise) {
|
|
4010
|
+
te(l), f.then((b) => {
|
|
4011
|
+
b !== !0 && b && i(g, b);
|
|
4006
4012
|
});
|
|
4007
4013
|
return;
|
|
4008
4014
|
}
|
|
4009
|
-
if (
|
|
4010
|
-
te(
|
|
4015
|
+
if (f === !0) {
|
|
4016
|
+
te(l);
|
|
4011
4017
|
return;
|
|
4012
4018
|
}
|
|
4013
|
-
|
|
4019
|
+
f && (te(l), i(g, f));
|
|
4014
4020
|
};
|
|
4015
4021
|
return e.addEventListener("paste", d, { capture: !0 }), () => {
|
|
4016
4022
|
e.removeEventListener("paste", d, { capture: !0 });
|
|
4017
4023
|
};
|
|
4018
|
-
},
|
|
4024
|
+
}, Pc = (e) => e.getKey() === "root" ? null : e.getTopLevelElement(), Ic = (e, t, n) => {
|
|
4019
4025
|
const r = e.getLastDescendant();
|
|
4020
4026
|
return ie(t) ? t === e && n === e.getChildrenSize() : r ? t === r && n === t.getTextContentSize() : !0;
|
|
4021
|
-
},
|
|
4027
|
+
}, Rc = (e) => {
|
|
4022
4028
|
const t = e.getLastChild();
|
|
4023
4029
|
return un(t);
|
|
4024
|
-
},
|
|
4030
|
+
}, Ac = (e) => {
|
|
4025
4031
|
const t = z(), n = e.getLastChild();
|
|
4026
4032
|
un(n) && n.remove(), e.insertAfter(t), t.selectStart();
|
|
4027
|
-
},
|
|
4033
|
+
}, Bc = (e, t) => {
|
|
4028
4034
|
const n = () => {
|
|
4029
4035
|
if (t()) return !1;
|
|
4030
4036
|
const r = D();
|
|
4031
4037
|
if (!O(r) || !r.isCollapsed()) return !1;
|
|
4032
|
-
const o = r.anchor, a = o.getNode(), s =
|
|
4033
|
-
return !mn(s) || !
|
|
4038
|
+
const o = r.anchor, a = o.getNode(), s = Pc(a);
|
|
4039
|
+
return !mn(s) || !Ic(s, a, o.offset) ? !1 : Rc(s) ? (Ac(s), !0) : (r.insertLineBreak(), !0);
|
|
4034
4040
|
};
|
|
4035
4041
|
return [
|
|
4036
4042
|
e.registerCommand(
|
|
@@ -4044,7 +4050,7 @@ const Qn = {
|
|
|
4044
4050
|
G
|
|
4045
4051
|
)
|
|
4046
4052
|
];
|
|
4047
|
-
},
|
|
4053
|
+
}, Dc = [
|
|
4048
4054
|
"paragraph",
|
|
4049
4055
|
"heading-1",
|
|
4050
4056
|
"heading-2",
|
|
@@ -4058,18 +4064,18 @@ const Qn = {
|
|
|
4058
4064
|
"upload-image",
|
|
4059
4065
|
"upload-video",
|
|
4060
4066
|
"table"
|
|
4061
|
-
],
|
|
4067
|
+
], Hc = {
|
|
4062
4068
|
showIcon: !0,
|
|
4063
4069
|
loadingText: "加载中",
|
|
4064
4070
|
emptyText: "没有匹配的命令",
|
|
4065
4071
|
errorText: "命令加载失败"
|
|
4066
|
-
},
|
|
4067
|
-
...
|
|
4072
|
+
}, Oc = (e) => ({
|
|
4073
|
+
...Hc,
|
|
4068
4074
|
...e
|
|
4069
|
-
}),
|
|
4075
|
+
}), $c = (e) => e.flatMap((t) => t.type === "button" ? [t.item] : t.type === "group" ? t.items : []), Fc = (e) => ({
|
|
4070
4076
|
...e,
|
|
4071
|
-
toolbarKeys: (e == null ? void 0 : e.toolbarKeys) ??
|
|
4072
|
-
}),
|
|
4077
|
+
toolbarKeys: (e == null ? void 0 : e.toolbarKeys) ?? Dc
|
|
4078
|
+
}), zc = (e) => ({
|
|
4073
4079
|
id: e.id,
|
|
4074
4080
|
label: e.label,
|
|
4075
4081
|
command: e.command,
|
|
@@ -4077,36 +4083,36 @@ const Qn = {
|
|
|
4077
4083
|
requiresPayload: e.requiresPayload,
|
|
4078
4084
|
payloadPanel: e.payloadPanel,
|
|
4079
4085
|
source: "schema"
|
|
4080
|
-
}),
|
|
4081
|
-
|
|
4086
|
+
}), Vc = (e, t) => $c(ot(
|
|
4087
|
+
Fc(t),
|
|
4082
4088
|
e
|
|
4083
|
-
)).map(
|
|
4089
|
+
)).map(zc), ir = (e) => ({
|
|
4084
4090
|
...e,
|
|
4085
4091
|
source: "provider"
|
|
4086
|
-
}),
|
|
4087
|
-
const n =
|
|
4088
|
-
return n ? e.filter((r) =>
|
|
4089
|
-
},
|
|
4092
|
+
}), Wc = /(?:^|\s)\/([\p{L}\p{N}_-]*)$/u, Uc = (e) => e.trim().toLowerCase(), jc = (e) => [e.label, e.id, e.description, ...e.keywords ?? []].filter(Boolean).join(" ").toLowerCase(), Kc = (e, t) => {
|
|
4093
|
+
const n = Uc(t);
|
|
4094
|
+
return n ? e.filter((r) => jc(r).includes(n)) : e;
|
|
4095
|
+
}, qc = async (e, t) => (await Promise.resolve((t == null ? void 0 : t(e)) ?? [])).map(ir), Gc = (e) => "source" in e ? e : ir(e), Xc = ({
|
|
4090
4096
|
menuSchema: e,
|
|
4091
4097
|
slashCommandConfig: t
|
|
4092
|
-
}) => e !== void 0 || t !== void 0,
|
|
4098
|
+
}) => e !== void 0 || t !== void 0, Yc = () => {
|
|
4093
4099
|
const e = D();
|
|
4094
4100
|
if (!O(e) || !e.isCollapsed()) return null;
|
|
4095
4101
|
const t = e.anchor, n = t.getNode();
|
|
4096
4102
|
if (!(n instanceof Y)) return null;
|
|
4097
|
-
const o = n.getTextContent().slice(0, t.offset).match(
|
|
4103
|
+
const o = n.getTextContent().slice(0, t.offset).match(Wc);
|
|
4098
4104
|
if (!o) return null;
|
|
4099
|
-
const a = o[1] ?? "", s = o[0] ?? "",
|
|
4105
|
+
const a = o[1] ?? "", s = o[0] ?? "", i = s.startsWith("/") ? 0 : 1, d = t.offset - s.length + i;
|
|
4100
4106
|
return {
|
|
4101
4107
|
query: a,
|
|
4102
4108
|
nodeKey: n.getKey(),
|
|
4103
4109
|
startOffset: d,
|
|
4104
4110
|
endOffset: t.offset
|
|
4105
4111
|
};
|
|
4106
|
-
},
|
|
4112
|
+
}, Jc = () => {
|
|
4107
4113
|
const e = document.createElement("div");
|
|
4108
4114
|
return e.className = "bridgerte__floating-menu bridgerte__slash-command-menu", e.dataset.visible = "false", e;
|
|
4109
|
-
},
|
|
4115
|
+
}, Qc = () => {
|
|
4110
4116
|
const e = document.createElement("span");
|
|
4111
4117
|
return e.className = "bridgerte__slash-command-anchor", e.setAttribute("aria-hidden", "true"), e;
|
|
4112
4118
|
}, Yt = (e, t) => {
|
|
@@ -4115,21 +4121,21 @@ const Qn = {
|
|
|
4115
4121
|
if (!(r instanceof Text)) return null;
|
|
4116
4122
|
const o = document.createRange(), a = Math.min(t.startOffset + 1, ((s = r.textContent) == null ? void 0 : s.length) ?? 0);
|
|
4117
4123
|
return a <= t.startOffset ? null : (o.setStart(r, t.startOffset), o.setEnd(r, a), o.getBoundingClientRect());
|
|
4118
|
-
},
|
|
4124
|
+
}, Zc = (e, t, n, r, o) => {
|
|
4119
4125
|
const a = document.createElement("button"), s = document.createElement("span");
|
|
4120
4126
|
if (a.type = "button", a.className = "bridgerte__menu-item bridgerte__slash-command-item", a.dataset.commandId = e.id, a.dataset.index = String(t), a.dataset.active = String(n), r.showIcon && e.icon) {
|
|
4121
|
-
const
|
|
4122
|
-
|
|
4127
|
+
const i = document.createElement("span");
|
|
4128
|
+
i.className = "bridgerte__slash-command-item-icon", i.setAttribute("aria-hidden", "true"), Zn(i, o[e.icon] ?? Qn[e.icon], e.label), a.append(i);
|
|
4123
4129
|
}
|
|
4124
4130
|
if (s.className = "bridgerte__slash-command-item-title", s.textContent = e.label, a.append(s), e.description) {
|
|
4125
|
-
const
|
|
4126
|
-
|
|
4131
|
+
const i = document.createElement("span");
|
|
4132
|
+
i.className = "bridgerte__slash-command-item-description", i.textContent = e.description, a.append(i);
|
|
4127
4133
|
}
|
|
4128
4134
|
return a;
|
|
4129
|
-
},
|
|
4135
|
+
}, ed = (e, t) => {
|
|
4130
4136
|
const n = document.createElement("div");
|
|
4131
4137
|
return n.className = "bridgerte__slash-command-status", n.dataset.status = e, n.textContent = t, n;
|
|
4132
|
-
},
|
|
4138
|
+
}, td = (e, t) => {
|
|
4133
4139
|
switch (e) {
|
|
4134
4140
|
case "loading":
|
|
4135
4141
|
return t.loadingText;
|
|
@@ -4143,7 +4149,7 @@ const Qn = {
|
|
|
4143
4149
|
y: e.y,
|
|
4144
4150
|
width: e.width,
|
|
4145
4151
|
height: e.height
|
|
4146
|
-
} : void 0,
|
|
4152
|
+
} : void 0, nd = ({
|
|
4147
4153
|
editorRoot: e,
|
|
4148
4154
|
contentElement: t,
|
|
4149
4155
|
editor: n,
|
|
@@ -4151,24 +4157,24 @@ const Qn = {
|
|
|
4151
4157
|
executeCommand: o,
|
|
4152
4158
|
requestPayloadPanel: a,
|
|
4153
4159
|
menuSchema: s,
|
|
4154
|
-
slashCommandConfig:
|
|
4160
|
+
slashCommandConfig: i,
|
|
4155
4161
|
icons: d = {},
|
|
4156
|
-
menuLabels:
|
|
4162
|
+
menuLabels: l,
|
|
4157
4163
|
payloadPanelConfig: g,
|
|
4158
|
-
slashCommandMenuConfig:
|
|
4164
|
+
slashCommandMenuConfig: f,
|
|
4159
4165
|
onSlashCommandMenuRequest: b,
|
|
4160
4166
|
slashCommandProvider: T
|
|
4161
4167
|
}) => {
|
|
4162
|
-
const
|
|
4163
|
-
menuLabels:
|
|
4168
|
+
const v = Jc(), y = Qc(), x = Oc(f), u = dt(s ?? De, {
|
|
4169
|
+
menuLabels: l,
|
|
4164
4170
|
payloadPanelConfig: g
|
|
4165
|
-
}), p =
|
|
4171
|
+
}), p = Vc(u, i), E = new Map(u.map((c) => [c.id, c])), _ = Xc({
|
|
4166
4172
|
menuSchema: s,
|
|
4167
|
-
slashCommandConfig:
|
|
4173
|
+
slashCommandConfig: i
|
|
4168
4174
|
}), B = (c) => {
|
|
4169
4175
|
n.update(() => {
|
|
4170
|
-
const
|
|
4171
|
-
|
|
4176
|
+
const m = he(c.nodeKey);
|
|
4177
|
+
m instanceof Y && (m.spliceText(c.startOffset, c.endOffset - c.startOffset, ""), m.select(c.startOffset, c.startOffset));
|
|
4172
4178
|
});
|
|
4173
4179
|
};
|
|
4174
4180
|
return er({
|
|
@@ -4176,53 +4182,53 @@ const Qn = {
|
|
|
4176
4182
|
contentElement: t,
|
|
4177
4183
|
editor: n,
|
|
4178
4184
|
isReadonly: r,
|
|
4179
|
-
menu:
|
|
4185
|
+
menu: v,
|
|
4180
4186
|
anchor: y,
|
|
4181
4187
|
itemSelector: ".bridgerte__slash-command-item",
|
|
4182
|
-
getCurrentTrigger:
|
|
4188
|
+
getCurrentTrigger: Yc,
|
|
4183
4189
|
getTriggerRect: (c) => Yt(n, c),
|
|
4184
4190
|
resolveItems: async (c) => {
|
|
4185
|
-
const
|
|
4191
|
+
const m = _ || !T ? Kc(p, c) : [];
|
|
4186
4192
|
try {
|
|
4187
|
-
const
|
|
4188
|
-
return [...
|
|
4189
|
-
} catch (
|
|
4190
|
-
if (
|
|
4191
|
-
throw
|
|
4193
|
+
const h = await qc(c, T);
|
|
4194
|
+
return [...m, ...h];
|
|
4195
|
+
} catch (h) {
|
|
4196
|
+
if (m.length > 0) return m;
|
|
4197
|
+
throw h;
|
|
4192
4198
|
}
|
|
4193
4199
|
},
|
|
4194
|
-
renderItem: (c,
|
|
4200
|
+
renderItem: (c, m, h) => Zc(
|
|
4195
4201
|
c,
|
|
4196
|
-
h,
|
|
4197
4202
|
m,
|
|
4203
|
+
h,
|
|
4198
4204
|
x,
|
|
4199
4205
|
d
|
|
4200
4206
|
),
|
|
4201
|
-
renderStatus: (c) =>
|
|
4207
|
+
renderStatus: (c) => ed(
|
|
4202
4208
|
c,
|
|
4203
|
-
|
|
4209
|
+
td(c, x)
|
|
4204
4210
|
),
|
|
4205
|
-
onStateChange: b ? (c,
|
|
4211
|
+
onStateChange: b ? (c, m) => b({
|
|
4206
4212
|
id: `bridgerte-slash-command-menu-${c.requestId}`,
|
|
4207
4213
|
query: c.trigger.query,
|
|
4208
4214
|
status: c.status,
|
|
4209
4215
|
items: c.items,
|
|
4210
4216
|
config: x,
|
|
4211
4217
|
readonly: r(),
|
|
4212
|
-
anchorRect: Jt(
|
|
4218
|
+
anchorRect: Jt(m.anchorRect),
|
|
4213
4219
|
...c.error ? { error: c.error } : {},
|
|
4214
|
-
submit: (
|
|
4215
|
-
cancel:
|
|
4220
|
+
submit: (h) => m.selectItem(Gc(h)),
|
|
4221
|
+
cancel: m.close
|
|
4216
4222
|
}) : void 0,
|
|
4217
|
-
onSelect: (c,
|
|
4218
|
-
B(
|
|
4219
|
-
const
|
|
4220
|
-
if (
|
|
4221
|
-
const C = Yt(n,
|
|
4223
|
+
onSelect: (c, m) => {
|
|
4224
|
+
B(m);
|
|
4225
|
+
const h = c.source === "schema" ? E.get(c.id) : void 0;
|
|
4226
|
+
if (h != null && h.payloadPanel) {
|
|
4227
|
+
const C = Yt(n, m);
|
|
4222
4228
|
a({
|
|
4223
|
-
menuId:
|
|
4224
|
-
command:
|
|
4225
|
-
panel:
|
|
4229
|
+
menuId: h.id,
|
|
4230
|
+
command: h.command,
|
|
4231
|
+
panel: h.payloadPanel,
|
|
4226
4232
|
anchorRect: Jt(C ?? void 0)
|
|
4227
4233
|
});
|
|
4228
4234
|
return;
|
|
@@ -4233,12 +4239,12 @@ const Qn = {
|
|
|
4233
4239
|
}, Qt = 32, Ue = (e) => {
|
|
4234
4240
|
var t;
|
|
4235
4241
|
return e instanceof HTMLElement && e.getAttribute("role") === "checkbox" && ((t = e.parentElement) == null ? void 0 : t.classList.contains("bridgerte__list--todo")) === !0;
|
|
4236
|
-
}, je = (e) => e instanceof HTMLElement ? e.closest('[role="checkbox"]') : null,
|
|
4242
|
+
}, je = (e) => e instanceof HTMLElement ? e.closest('[role="checkbox"]') : null, rd = (e) => Sr(e), Zt = (e) => e.button === 0, Ke = (e, t) => {
|
|
4237
4243
|
const n = t.getBoundingClientRect();
|
|
4238
4244
|
return t.dir === "rtl" ? e.clientX >= n.right - Qt && e.clientX <= n.right : e.clientX >= n.left && e.clientX <= n.left + Qt;
|
|
4239
4245
|
}, en = (e) => {
|
|
4240
4246
|
e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
|
|
4241
|
-
},
|
|
4247
|
+
}, od = ({
|
|
4242
4248
|
contentElement: e,
|
|
4243
4249
|
editor: t,
|
|
4244
4250
|
isReadonly: n
|
|
@@ -4246,29 +4252,29 @@ const Qn = {
|
|
|
4246
4252
|
let r = 0;
|
|
4247
4253
|
const o = (d) => {
|
|
4248
4254
|
if (n() || !Zt(d)) return;
|
|
4249
|
-
const
|
|
4250
|
-
!
|
|
4251
|
-
}, a = (d,
|
|
4255
|
+
const l = je(d.target);
|
|
4256
|
+
!l || !Ue(l) || Ke(d, l) && en(d);
|
|
4257
|
+
}, a = (d, l) => {
|
|
4252
4258
|
en(d), t.update(() => {
|
|
4253
|
-
const g =
|
|
4259
|
+
const g = rd(l);
|
|
4254
4260
|
Gr(g) && g.toggleChecked();
|
|
4255
4261
|
});
|
|
4256
4262
|
}, s = (d) => {
|
|
4257
4263
|
if (n() || !Zt(d) || Date.now() - r < 700) return;
|
|
4258
|
-
const
|
|
4259
|
-
!
|
|
4260
|
-
},
|
|
4264
|
+
const l = je(d.target);
|
|
4265
|
+
!l || !Ue(l) || Ke(d, l) && a(d, l);
|
|
4266
|
+
}, i = (d) => {
|
|
4261
4267
|
if (n() || d.pointerType !== "touch") return;
|
|
4262
|
-
const
|
|
4263
|
-
!
|
|
4268
|
+
const l = je(d.target);
|
|
4269
|
+
!l || !Ue(l) || Ke(d, l) && (r = Date.now(), a(d, l));
|
|
4264
4270
|
};
|
|
4265
|
-
return e.addEventListener("pointerdown", o, !0), e.addEventListener("pointerup",
|
|
4266
|
-
e.removeEventListener("pointerdown", o, !0), e.removeEventListener("pointerup",
|
|
4271
|
+
return e.addEventListener("pointerdown", o, !0), e.addEventListener("pointerup", i, !0), e.addEventListener("click", s, !0), () => {
|
|
4272
|
+
e.removeEventListener("pointerdown", o, !0), e.removeEventListener("pointerup", i, !0), e.removeEventListener("click", s, !0);
|
|
4267
4273
|
};
|
|
4268
4274
|
}, qe = (e, t) => {
|
|
4269
4275
|
var n;
|
|
4270
4276
|
return ((n = e.floatingMenus) == null ? void 0 : n[t]) !== !1;
|
|
4271
|
-
},
|
|
4277
|
+
}, ad = ({
|
|
4272
4278
|
options: e,
|
|
4273
4279
|
lexicalEditor: t,
|
|
4274
4280
|
editorRoot: n,
|
|
@@ -4276,14 +4282,14 @@ const Qn = {
|
|
|
4276
4282
|
historyState: o,
|
|
4277
4283
|
isReadonly: a,
|
|
4278
4284
|
executeCommand: s,
|
|
4279
|
-
requestPayloadPanel:
|
|
4285
|
+
requestPayloadPanel: i,
|
|
4280
4286
|
uploadMediaFile: d,
|
|
4281
|
-
canUploadMedia:
|
|
4287
|
+
canUploadMedia: l,
|
|
4282
4288
|
syncAfterEditorUpdate: g,
|
|
4283
|
-
refreshCommandStates:
|
|
4289
|
+
refreshCommandStates: f,
|
|
4284
4290
|
getCommandStates: b,
|
|
4285
4291
|
setCanUndo: T,
|
|
4286
|
-
setCanRedo:
|
|
4292
|
+
setCanRedo: v,
|
|
4287
4293
|
enableKeyboardShortcuts: y
|
|
4288
4294
|
}) => {
|
|
4289
4295
|
const x = qe(e, "mention"), u = qe(e, "slash"), p = qe(e, "hoverbar"), E = dn(
|
|
@@ -4291,11 +4297,11 @@ const Qn = {
|
|
|
4291
4297
|
* 业务自定义 paste hook 最先看到原始剪贴板摘要;返回 undefined 时完全不拦截,
|
|
4292
4298
|
* 继续走 BridgeRTE 内置媒体、URL 和 HTML 清洗链路。
|
|
4293
4299
|
*/
|
|
4294
|
-
|
|
4300
|
+
Nc({
|
|
4295
4301
|
target: r,
|
|
4296
4302
|
isReadonly: a,
|
|
4297
4303
|
onPaste: e.onPaste,
|
|
4298
|
-
canUploadMedia:
|
|
4304
|
+
canUploadMedia: l,
|
|
4299
4305
|
uploadMediaFile: d,
|
|
4300
4306
|
executeCommand: s,
|
|
4301
4307
|
editor: t
|
|
@@ -4304,17 +4310,17 @@ const Qn = {
|
|
|
4304
4310
|
* 媒体文件粘贴/拖拽优先于 URL 粘贴快速路径;剪贴板里有文件时直接进入上传管线,
|
|
4305
4311
|
* 没有文件再交给纯文本 URL 链接处理或 Lexical 默认粘贴。
|
|
4306
4312
|
*/
|
|
4307
|
-
|
|
4313
|
+
Lc({
|
|
4308
4314
|
target: r,
|
|
4309
4315
|
isReadonly: a,
|
|
4310
|
-
canUploadMedia:
|
|
4316
|
+
canUploadMedia: l,
|
|
4311
4317
|
uploadMediaFile: d
|
|
4312
4318
|
}),
|
|
4313
4319
|
/*
|
|
4314
4320
|
* URL 粘贴是 BridgeRTE 的高意图快捷路径,必须先于 Lexical 默认 paste 监听注册。
|
|
4315
4321
|
* 否则 Lexical 会先把 URL 当普通文本插入,后续就失去“选区变链接”的语义。
|
|
4316
4322
|
*/
|
|
4317
|
-
|
|
4323
|
+
Tc({
|
|
4318
4324
|
target: r,
|
|
4319
4325
|
isReadonly: a,
|
|
4320
4326
|
executeCommand: s
|
|
@@ -4323,12 +4329,12 @@ const Qn = {
|
|
|
4323
4329
|
* HTML 清洗放在媒体和纯文本 URL 之后、Lexical 默认 rich text paste 之前。
|
|
4324
4330
|
* 这样外部网页/办公软件片段会先进入 BridgeRTE 白名单清洗,再转成 Lexical 节点。
|
|
4325
4331
|
*/
|
|
4326
|
-
|
|
4332
|
+
Sc({
|
|
4327
4333
|
target: r,
|
|
4328
4334
|
editor: t,
|
|
4329
4335
|
isReadonly: a
|
|
4330
4336
|
}),
|
|
4331
|
-
|
|
4337
|
+
nl({
|
|
4332
4338
|
target: r,
|
|
4333
4339
|
isReadonly: a
|
|
4334
4340
|
}),
|
|
@@ -4337,18 +4343,18 @@ const Qn = {
|
|
|
4337
4343
|
* 代码块高亮一刀切使用 Lexical 官方 Shiki 管线。BridgeRTE tokenizer 只保留稳定 class,
|
|
4338
4344
|
* 不把 Shiki theme 的 inline style 写进内容 HTML。
|
|
4339
4345
|
*/
|
|
4340
|
-
No(t,
|
|
4341
|
-
bo(t, o,
|
|
4346
|
+
No(t, vs),
|
|
4347
|
+
bo(t, o, es),
|
|
4342
4348
|
Xr(t),
|
|
4343
4349
|
Yr(t),
|
|
4344
|
-
...
|
|
4350
|
+
...Bc(t, a),
|
|
4345
4351
|
...oa(t, a),
|
|
4346
|
-
|
|
4352
|
+
od({
|
|
4347
4353
|
contentElement: r,
|
|
4348
4354
|
editor: t,
|
|
4349
4355
|
isReadonly: a
|
|
4350
4356
|
}),
|
|
4351
|
-
x ?
|
|
4357
|
+
x ? Fl({
|
|
4352
4358
|
editorRoot: n,
|
|
4353
4359
|
contentElement: r,
|
|
4354
4360
|
editor: t,
|
|
@@ -4359,13 +4365,13 @@ const Qn = {
|
|
|
4359
4365
|
onMentionMenuRequest: e.onMentionMenuRequest
|
|
4360
4366
|
}) : () => {
|
|
4361
4367
|
},
|
|
4362
|
-
p ?
|
|
4368
|
+
p ? ul({
|
|
4363
4369
|
editorRoot: n,
|
|
4364
4370
|
contentElement: r,
|
|
4365
4371
|
editor: t,
|
|
4366
4372
|
isReadonly: a,
|
|
4367
4373
|
executeCommand: s,
|
|
4368
|
-
requestPayloadPanel:
|
|
4374
|
+
requestPayloadPanel: i,
|
|
4369
4375
|
getCommandStates: b,
|
|
4370
4376
|
menuSchema: e.menuSchema,
|
|
4371
4377
|
hoverbarConfig: e.hoverbarConfig,
|
|
@@ -4375,14 +4381,14 @@ const Qn = {
|
|
|
4375
4381
|
}) : () => {
|
|
4376
4382
|
},
|
|
4377
4383
|
io(t),
|
|
4378
|
-
|
|
4379
|
-
u ?
|
|
4384
|
+
Ji({ editor: t }),
|
|
4385
|
+
u ? nd({
|
|
4380
4386
|
editorRoot: n,
|
|
4381
4387
|
contentElement: r,
|
|
4382
4388
|
editor: t,
|
|
4383
4389
|
isReadonly: a,
|
|
4384
4390
|
executeCommand: s,
|
|
4385
|
-
requestPayloadPanel:
|
|
4391
|
+
requestPayloadPanel: i,
|
|
4386
4392
|
menuSchema: e.menuSchema,
|
|
4387
4393
|
slashCommandConfig: e.slashCommandConfig,
|
|
4388
4394
|
icons: e.icons,
|
|
@@ -4393,23 +4399,23 @@ const Qn = {
|
|
|
4393
4399
|
slashCommandProvider: e.slashCommandProvider
|
|
4394
4400
|
}) : () => {
|
|
4395
4401
|
},
|
|
4396
|
-
|
|
4402
|
+
ma({
|
|
4397
4403
|
editor: t,
|
|
4398
4404
|
contentElement: r,
|
|
4399
4405
|
isReadonly: a
|
|
4400
4406
|
}),
|
|
4401
|
-
y ?
|
|
4407
|
+
y ? bl({
|
|
4402
4408
|
target: r,
|
|
4403
4409
|
isReadonly: a,
|
|
4404
4410
|
executeCommand: s
|
|
4405
4411
|
}) : () => {
|
|
4406
4412
|
},
|
|
4407
4413
|
t.registerUpdateListener(() => {
|
|
4408
|
-
g(),
|
|
4414
|
+
g(), f();
|
|
4409
4415
|
}),
|
|
4410
4416
|
t.registerCommand(
|
|
4411
4417
|
ln,
|
|
4412
|
-
() => (
|
|
4418
|
+
() => (f(), !1),
|
|
4413
4419
|
j
|
|
4414
4420
|
),
|
|
4415
4421
|
t.registerCommand(
|
|
@@ -4419,7 +4425,7 @@ const Qn = {
|
|
|
4419
4425
|
),
|
|
4420
4426
|
t.registerCommand(
|
|
4421
4427
|
Pr,
|
|
4422
|
-
(_) => (
|
|
4428
|
+
(_) => (v(_), !1),
|
|
4423
4429
|
j
|
|
4424
4430
|
)
|
|
4425
4431
|
);
|
|
@@ -4429,14 +4435,14 @@ const Qn = {
|
|
|
4429
4435
|
}
|
|
4430
4436
|
};
|
|
4431
4437
|
};
|
|
4432
|
-
function
|
|
4433
|
-
const n = yo(), r = t.mediaDefaultWidthPercent ?? 50, { contentElement: o } =
|
|
4438
|
+
function sd(e, t = {}) {
|
|
4439
|
+
const n = yo(), r = t.mediaDefaultWidthPercent ?? 50, { contentElement: o, placeholderElement: a } = Ki(e, {
|
|
4434
4440
|
placeholder: t.placeholder ?? la
|
|
4435
|
-
}),
|
|
4436
|
-
let
|
|
4437
|
-
const
|
|
4438
|
-
namespace:
|
|
4439
|
-
editable: !
|
|
4441
|
+
}), s = t.keyboardShortcuts === !0;
|
|
4442
|
+
let i = t.readonly ?? !1, d = !1, l = Ye(t.value);
|
|
4443
|
+
const g = Ir({
|
|
4444
|
+
namespace: ts,
|
|
4445
|
+
editable: !i,
|
|
4440
4446
|
nodes: [
|
|
4441
4447
|
Or,
|
|
4442
4448
|
$r,
|
|
@@ -4453,53 +4459,53 @@ function ad(e, t = {}) {
|
|
|
4453
4459
|
le,
|
|
4454
4460
|
ye
|
|
4455
4461
|
],
|
|
4456
|
-
theme:
|
|
4457
|
-
onError: (
|
|
4458
|
-
K(t, "lexical.runtime", "Lexical runtime error.",
|
|
4462
|
+
theme: Fa,
|
|
4463
|
+
onError: (m) => {
|
|
4464
|
+
K(t, "lexical.runtime", "Lexical runtime error.", m);
|
|
4459
4465
|
}
|
|
4460
4466
|
});
|
|
4461
|
-
uo(
|
|
4462
|
-
const
|
|
4463
|
-
|
|
4464
|
-
},
|
|
4465
|
-
lexicalEditor:
|
|
4467
|
+
uo(g, !0);
|
|
4468
|
+
const f = () => d, b = () => i, T = () => {
|
|
4469
|
+
f() || (da({ editor: g, contentElement: o }), ua({ contentElement: o, placeholderElement: a }));
|
|
4470
|
+
}, v = qi({ editor: g }), y = ns({
|
|
4471
|
+
lexicalEditor: g,
|
|
4466
4472
|
options: t,
|
|
4467
|
-
isDestroyed:
|
|
4468
|
-
setContent: (
|
|
4469
|
-
|
|
4473
|
+
isDestroyed: f,
|
|
4474
|
+
setContent: (m) => {
|
|
4475
|
+
l = m;
|
|
4470
4476
|
},
|
|
4471
|
-
syncPlaceholder:
|
|
4472
|
-
}),
|
|
4473
|
-
lexicalEditor:
|
|
4477
|
+
syncPlaceholder: T
|
|
4478
|
+
}), x = Na({
|
|
4479
|
+
lexicalEditor: g,
|
|
4474
4480
|
options: t,
|
|
4475
|
-
isDestroyed:
|
|
4481
|
+
isDestroyed: f,
|
|
4476
4482
|
canUploadMedia: () => t.uploadAdapter !== void 0,
|
|
4477
|
-
isReadonly:
|
|
4478
|
-
}),
|
|
4483
|
+
isReadonly: b
|
|
4484
|
+
}), u = Za({
|
|
4479
4485
|
container: e,
|
|
4480
|
-
lexicalEditor:
|
|
4486
|
+
lexicalEditor: g,
|
|
4481
4487
|
options: t,
|
|
4482
|
-
isDestroyed:
|
|
4483
|
-
isReadonly:
|
|
4488
|
+
isDestroyed: f,
|
|
4489
|
+
isReadonly: b,
|
|
4484
4490
|
reportError: K
|
|
4485
|
-
}),
|
|
4486
|
-
o.contentEditable = String(!
|
|
4487
|
-
},
|
|
4491
|
+
}), p = () => {
|
|
4492
|
+
o.contentEditable = String(!i), g.setEditable(!i);
|
|
4493
|
+
}, _ = ji({
|
|
4488
4494
|
editorRoot: e,
|
|
4489
|
-
lexicalEditor:
|
|
4490
|
-
isReadonly:
|
|
4491
|
-
restoreEditorFocus: (
|
|
4492
|
-
|
|
4495
|
+
lexicalEditor: g,
|
|
4496
|
+
isReadonly: b,
|
|
4497
|
+
restoreEditorFocus: (m) => {
|
|
4498
|
+
v.restore(), g.focus(m);
|
|
4493
4499
|
},
|
|
4494
|
-
executeCommand:
|
|
4495
|
-
getClearCommand: (
|
|
4496
|
-
switch (
|
|
4500
|
+
executeCommand: u,
|
|
4501
|
+
getClearCommand: (m) => {
|
|
4502
|
+
switch (m.command.type) {
|
|
4497
4503
|
case "format.color":
|
|
4498
4504
|
case "format.backgroundColor":
|
|
4499
4505
|
case "format.fontSize":
|
|
4500
4506
|
case "format.fontFamily":
|
|
4501
4507
|
case "format.lineHeight":
|
|
4502
|
-
return { ...
|
|
4508
|
+
return { ...m.command, value: "" };
|
|
4503
4509
|
default:
|
|
4504
4510
|
return null;
|
|
4505
4511
|
}
|
|
@@ -4510,61 +4516,61 @@ function ad(e, t = {}) {
|
|
|
4510
4516
|
menuLabels: t.menuLabels,
|
|
4511
4517
|
onRequest: t.onPayloadPanelRequest,
|
|
4512
4518
|
defaultMediaWidthPercent: r
|
|
4513
|
-
}),
|
|
4514
|
-
|
|
4519
|
+
}), B = () => Ta(t), H = () => La(t), I = (m) => {
|
|
4520
|
+
f() || (v.capture(), _.payloadPanelController.open(m));
|
|
4515
4521
|
};
|
|
4516
|
-
e.dataset.readonly = String(
|
|
4522
|
+
e.dataset.readonly = String(i), e.addEventListener("focusin", B), e.addEventListener("focusout", H), e.style.setProperty(
|
|
4517
4523
|
"--bridgerte-media-display-width",
|
|
4518
4524
|
`${r}%`
|
|
4519
4525
|
);
|
|
4520
|
-
const
|
|
4526
|
+
const w = ad({
|
|
4521
4527
|
options: t,
|
|
4522
|
-
lexicalEditor:
|
|
4528
|
+
lexicalEditor: g,
|
|
4523
4529
|
editorRoot: e,
|
|
4524
4530
|
contentElement: o,
|
|
4525
4531
|
historyState: n,
|
|
4526
|
-
isReadonly:
|
|
4527
|
-
executeCommand:
|
|
4528
|
-
requestPayloadPanel:
|
|
4529
|
-
uploadMediaFile:
|
|
4532
|
+
isReadonly: b,
|
|
4533
|
+
executeCommand: u,
|
|
4534
|
+
requestPayloadPanel: I,
|
|
4535
|
+
uploadMediaFile: u.uploadMediaFile,
|
|
4530
4536
|
canUploadMedia: () => t.uploadAdapter !== void 0,
|
|
4531
|
-
syncAfterEditorUpdate:
|
|
4532
|
-
refreshCommandStates:
|
|
4533
|
-
getCommandStates:
|
|
4534
|
-
setCanUndo:
|
|
4535
|
-
setCanRedo:
|
|
4536
|
-
enableKeyboardShortcuts:
|
|
4537
|
+
syncAfterEditorUpdate: y.syncAfterEditorUpdate,
|
|
4538
|
+
refreshCommandStates: x.refreshCommandStates,
|
|
4539
|
+
getCommandStates: x.getCommandStates,
|
|
4540
|
+
setCanUndo: x.setCanUndo,
|
|
4541
|
+
setCanRedo: x.setCanRedo,
|
|
4542
|
+
enableKeyboardShortcuts: s
|
|
4537
4543
|
});
|
|
4538
|
-
|
|
4539
|
-
const
|
|
4544
|
+
g.setRootElement(o), y.suppressNextChange(), l = Yo(g, t.value), p();
|
|
4545
|
+
const c = {
|
|
4540
4546
|
getContent() {
|
|
4541
|
-
return
|
|
4547
|
+
return f() || (y.clearContentChangeTimer(), y.syncContent(!1)), l;
|
|
4542
4548
|
},
|
|
4543
|
-
setContent(
|
|
4544
|
-
|
|
4549
|
+
setContent(m) {
|
|
4550
|
+
f() || (y.clearContentChangeTimer(), l = Ye(m), y.suppressNextChange(), Pn(g, l), y.enforceCurrentMaxLength(), T(), g.dispatchCommand(Rr, void 0), x.setHistoryAvailability(!1, !1), y.syncContent(!0));
|
|
4545
4551
|
},
|
|
4546
|
-
executeCommand(
|
|
4547
|
-
|
|
4552
|
+
executeCommand(m) {
|
|
4553
|
+
u(m);
|
|
4548
4554
|
},
|
|
4549
|
-
requestPayloadPanel:
|
|
4550
|
-
getCommandStates:
|
|
4551
|
-
subscribeCommandStateChange:
|
|
4552
|
-
setReadonly(
|
|
4553
|
-
|
|
4555
|
+
requestPayloadPanel: I,
|
|
4556
|
+
getCommandStates: x.getCommandStates,
|
|
4557
|
+
subscribeCommandStateChange: x.subscribeCommandStateChange,
|
|
4558
|
+
setReadonly(m) {
|
|
4559
|
+
f() || (i = m, e.dataset.readonly = String(i), p(), x.refreshCommandStates());
|
|
4554
4560
|
},
|
|
4555
4561
|
focus() {
|
|
4556
|
-
|
|
4562
|
+
f() || g.focus();
|
|
4557
4563
|
},
|
|
4558
4564
|
blur() {
|
|
4559
|
-
|
|
4565
|
+
f() || o.blur();
|
|
4560
4566
|
},
|
|
4561
4567
|
destroy() {
|
|
4562
|
-
|
|
4568
|
+
f() || (d = !0, y.clearContentChangeTimer(), _.destroy(), u.destroy(), x.destroy(), v.clear(), w.destroy(), g.setRootElement(null), e.removeEventListener("focusin", B), e.removeEventListener("focusout", H), e.classList.remove("bridgerte"), e.textContent = "", delete e.dataset.readonly);
|
|
4563
4569
|
}
|
|
4564
4570
|
};
|
|
4565
|
-
return
|
|
4571
|
+
return y.syncContent(!1), T(), x.refreshCommandStates(), Sa(t, c), c;
|
|
4566
4572
|
}
|
|
4567
|
-
const
|
|
4573
|
+
const id = (e) => !ur(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.type === "editor.executeCommand" || e.type === "editor.setContent" || e.type === "editor.setReadonly" || e.type === "editor.requestContent" || e.type === "editor.payloadPanelResolved" || e.type === "editor.payloadPanelCanceled" || e.type === "editor.uploadResolved" || e.type === "editor.uploadRejected", ld = (e) => ({
|
|
4568
4574
|
id: e,
|
|
4569
4575
|
type: "editor.ready",
|
|
4570
4576
|
payload: {
|
|
@@ -4572,21 +4578,21 @@ const sd = (e) => !ur(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4572
4578
|
eventTiming: gr,
|
|
4573
4579
|
version: Ae
|
|
4574
4580
|
}
|
|
4575
|
-
}),
|
|
4581
|
+
}), cd = (e) => `native-upload:${e}:${Date.now()}:${Math.random().toString(36).slice(2)}`, Td = ({
|
|
4576
4582
|
container: e,
|
|
4577
4583
|
transport: t
|
|
4578
4584
|
}) => {
|
|
4579
4585
|
var I;
|
|
4580
|
-
let n = null, r = !1, o = null, a = null, s = null,
|
|
4581
|
-
const d = /* @__PURE__ */ new Map(),
|
|
4586
|
+
let n = null, r = !1, o = null, a = null, s = null, i = 0;
|
|
4587
|
+
const d = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), g = (w) => {
|
|
4582
4588
|
r || t.postMessage(w);
|
|
4583
|
-
},
|
|
4589
|
+
}, f = () => {
|
|
4584
4590
|
s && (clearTimeout(s), s = null);
|
|
4585
4591
|
}, b = () => {
|
|
4586
|
-
|
|
4592
|
+
f(), s = setTimeout(() => {
|
|
4587
4593
|
if (r) return;
|
|
4588
4594
|
const w = Math.ceil(e.getBoundingClientRect().height);
|
|
4589
|
-
w !==
|
|
4595
|
+
w !== i && (i = w, g({
|
|
4590
4596
|
type: "editor.heightChange",
|
|
4591
4597
|
payload: { height: w }
|
|
4592
4598
|
}));
|
|
@@ -4603,15 +4609,15 @@ const sd = (e) => !ur(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4603
4609
|
type: "editor.contentChange",
|
|
4604
4610
|
payload: c
|
|
4605
4611
|
});
|
|
4606
|
-
},
|
|
4607
|
-
const c = w.payload,
|
|
4608
|
-
if (
|
|
4609
|
-
if (d.delete(c.assetId),
|
|
4610
|
-
|
|
4612
|
+
}, v = (w) => {
|
|
4613
|
+
const c = w.payload, m = d.get(c.assetId);
|
|
4614
|
+
if (m) {
|
|
4615
|
+
if (d.delete(c.assetId), m.source === "uploadAdapter") {
|
|
4616
|
+
m.resolve(c.result);
|
|
4611
4617
|
return;
|
|
4612
4618
|
}
|
|
4613
4619
|
n == null || n.executeCommand({
|
|
4614
|
-
type:
|
|
4620
|
+
type: m.type === "image" ? "media.insertImage" : "media.insertVideo",
|
|
4615
4621
|
url: c.result.url,
|
|
4616
4622
|
poster: c.result.poster,
|
|
4617
4623
|
width: c.result.width,
|
|
@@ -4621,10 +4627,10 @@ const sd = (e) => !ur(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4621
4627
|
});
|
|
4622
4628
|
}
|
|
4623
4629
|
}, y = (w) => {
|
|
4624
|
-
const c = w.payload,
|
|
4625
|
-
if (
|
|
4626
|
-
if (d.delete(c.assetId),
|
|
4627
|
-
|
|
4630
|
+
const c = w.payload, m = d.get(c.assetId);
|
|
4631
|
+
if (m) {
|
|
4632
|
+
if (d.delete(c.assetId), m.source === "uploadAdapter") {
|
|
4633
|
+
m.reject(new Error(c.message));
|
|
4628
4634
|
return;
|
|
4629
4635
|
}
|
|
4630
4636
|
g({
|
|
@@ -4636,13 +4642,13 @@ const sd = (e) => !ur(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4636
4642
|
}
|
|
4637
4643
|
});
|
|
4638
4644
|
}
|
|
4639
|
-
}, x = (w, c) => new Promise((
|
|
4645
|
+
}, x = (w, c) => new Promise((m, h) => {
|
|
4640
4646
|
d.set(c, {
|
|
4641
4647
|
type: w,
|
|
4642
4648
|
assetId: c,
|
|
4643
4649
|
source: "uploadAdapter",
|
|
4644
|
-
resolve:
|
|
4645
|
-
reject:
|
|
4650
|
+
resolve: m,
|
|
4651
|
+
reject: h
|
|
4646
4652
|
}), g({
|
|
4647
4653
|
type: "editor.uploadRequest",
|
|
4648
4654
|
payload: {
|
|
@@ -4652,7 +4658,7 @@ const sd = (e) => !ur(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4652
4658
|
}
|
|
4653
4659
|
});
|
|
4654
4660
|
}), u = (w) => {
|
|
4655
|
-
const c =
|
|
4661
|
+
const c = cd(w);
|
|
4656
4662
|
d.set(c, {
|
|
4657
4663
|
type: w,
|
|
4658
4664
|
assetId: c,
|
|
@@ -4666,58 +4672,58 @@ const sd = (e) => !ur(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4666
4672
|
}
|
|
4667
4673
|
});
|
|
4668
4674
|
}, p = (w) => {
|
|
4669
|
-
const c =
|
|
4670
|
-
c && (
|
|
4675
|
+
const c = l.get(w.payload.requestId);
|
|
4676
|
+
c && (l.delete(w.payload.requestId), c.request.submit(w.payload.values));
|
|
4671
4677
|
}, E = (w) => {
|
|
4672
|
-
const c =
|
|
4673
|
-
c && (
|
|
4678
|
+
const c = l.get(w.payload.requestId);
|
|
4679
|
+
c && (l.delete(w.payload.requestId), c.request.cancel());
|
|
4674
4680
|
}, _ = (w, c) => {
|
|
4675
|
-
n == null || n.destroy(), o == null || o(), d.clear(),
|
|
4681
|
+
n == null || n.destroy(), o == null || o(), d.clear(), l.clear(), n = sd(e, {
|
|
4676
4682
|
...c,
|
|
4677
4683
|
uploadAdapter: {
|
|
4678
|
-
uploadImage(
|
|
4679
|
-
return x("image",
|
|
4684
|
+
uploadImage(m, h) {
|
|
4685
|
+
return x("image", h.assetId);
|
|
4680
4686
|
},
|
|
4681
|
-
uploadVideo(
|
|
4682
|
-
return x("video",
|
|
4687
|
+
uploadVideo(m, h) {
|
|
4688
|
+
return x("video", h.assetId);
|
|
4683
4689
|
}
|
|
4684
4690
|
},
|
|
4685
|
-
onContentChange: (
|
|
4691
|
+
onContentChange: (m) => {
|
|
4686
4692
|
g({
|
|
4687
4693
|
type: "editor.contentChange",
|
|
4688
|
-
payload:
|
|
4694
|
+
payload: m
|
|
4689
4695
|
}), b();
|
|
4690
4696
|
},
|
|
4691
|
-
onCommandStateChange: (
|
|
4697
|
+
onCommandStateChange: (m) => {
|
|
4692
4698
|
g({
|
|
4693
4699
|
type: "editor.commandStateChange",
|
|
4694
|
-
payload:
|
|
4700
|
+
payload: m
|
|
4695
4701
|
});
|
|
4696
4702
|
},
|
|
4697
|
-
onPayloadPanelRequest: (
|
|
4703
|
+
onPayloadPanelRequest: (m) => (l.set(m.id, { request: m }), g({
|
|
4698
4704
|
type: "editor.payloadPanelRequest",
|
|
4699
4705
|
payload: {
|
|
4700
|
-
menuId:
|
|
4701
|
-
command:
|
|
4702
|
-
panel:
|
|
4703
|
-
anchorRect:
|
|
4704
|
-
currentValues:
|
|
4705
|
-
id:
|
|
4706
|
-
readonly:
|
|
4706
|
+
menuId: m.menuId,
|
|
4707
|
+
command: m.command,
|
|
4708
|
+
panel: m.panel,
|
|
4709
|
+
anchorRect: m.anchorRect,
|
|
4710
|
+
currentValues: m.currentValues,
|
|
4711
|
+
id: m.id,
|
|
4712
|
+
readonly: m.readonly
|
|
4707
4713
|
}
|
|
4708
4714
|
}), !0),
|
|
4709
|
-
onError: (
|
|
4715
|
+
onError: (m) => {
|
|
4710
4716
|
g({
|
|
4711
4717
|
type: "editor.error",
|
|
4712
|
-
payload:
|
|
4718
|
+
payload: m
|
|
4713
4719
|
});
|
|
4714
4720
|
}
|
|
4715
|
-
}), o = n.subscribeCommandStateChange((
|
|
4721
|
+
}), o = n.subscribeCommandStateChange((m) => {
|
|
4716
4722
|
g({
|
|
4717
4723
|
type: "editor.commandStateChange",
|
|
4718
|
-
payload:
|
|
4724
|
+
payload: m
|
|
4719
4725
|
});
|
|
4720
|
-
}), g(
|
|
4726
|
+
}), g(ld(w)), b();
|
|
4721
4727
|
}, B = (w) => {
|
|
4722
4728
|
if (w.type === "media.pickImage") {
|
|
4723
4729
|
u("image");
|
|
@@ -4729,7 +4735,7 @@ const sd = (e) => !ur(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4729
4735
|
}
|
|
4730
4736
|
n == null || n.executeCommand(w);
|
|
4731
4737
|
}, H = (w) => {
|
|
4732
|
-
if (!(r || !
|
|
4738
|
+
if (!(r || !id(w)))
|
|
4733
4739
|
switch (w.type) {
|
|
4734
4740
|
case "editor.init":
|
|
4735
4741
|
_(w.id, w.payload);
|
|
@@ -4753,7 +4759,7 @@ const sd = (e) => !ur(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4753
4759
|
E(w);
|
|
4754
4760
|
return;
|
|
4755
4761
|
case "editor.uploadResolved":
|
|
4756
|
-
|
|
4762
|
+
v(w);
|
|
4757
4763
|
return;
|
|
4758
4764
|
case "editor.uploadRejected":
|
|
4759
4765
|
y(w);
|
|
@@ -4763,19 +4769,19 @@ const sd = (e) => !ur(e) || !("id" in e) ? !1 : e.type === "editor.init" || e.ty
|
|
|
4763
4769
|
return a = ((I = t.addMessageListener) == null ? void 0 : I.call(t, H)) ?? null, {
|
|
4764
4770
|
receive: H,
|
|
4765
4771
|
destroy() {
|
|
4766
|
-
r || (r = !0,
|
|
4772
|
+
r || (r = !0, f(), a == null || a(), o == null || o(), d.clear(), l.clear(), n == null || n.destroy(), n = null);
|
|
4767
4773
|
}
|
|
4768
4774
|
};
|
|
4769
4775
|
};
|
|
4770
4776
|
export {
|
|
4771
|
-
|
|
4772
|
-
|
|
4777
|
+
sd as a,
|
|
4778
|
+
Td as b,
|
|
4773
4779
|
Jn as c,
|
|
4774
4780
|
Qn as d,
|
|
4775
4781
|
Zn as e,
|
|
4776
4782
|
U as f,
|
|
4777
|
-
|
|
4778
|
-
|
|
4783
|
+
Fs as g,
|
|
4784
|
+
$s as h,
|
|
4779
4785
|
dt as r
|
|
4780
4786
|
};
|
|
4781
|
-
//# sourceMappingURL=index-
|
|
4787
|
+
//# sourceMappingURL=index-BiehJaHJ.js.map
|