zt-react-milkdown 0.1.39 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -6
- package/dist/index.mjs +978 -908
- package/dist/src/core/createEditor.d.ts.map +1 -1
- package/dist/src/core/ime-composition-isolation.d.ts +1 -1
- package/dist/src/core/ime-composition-isolation.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts.map +1 -1
- package/dist/src/plugins/custom/table/index.d.ts +2 -0
- package/dist/src/plugins/custom/table/index.d.ts.map +1 -1
- package/dist/src/plugins/custom/table/table-scroll-node-view.d.ts +6 -0
- package/dist/src/plugins/custom/table/table-scroll-node-view.d.ts.map +1 -0
- package/dist/src/plugins/preset-common.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -634,96 +634,156 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
634
634
|
});
|
|
635
635
|
}), wn = (e, t) => typeof e == "function" ? (n) => {
|
|
636
636
|
t.action(e(n));
|
|
637
|
-
} : () => void 0, Tn = "zt-md-ime-isolating", En = new R("ZT_MD_IME_COMPOSITION_ISOLATION"), Dn = 30, On = 4e3, kn = 150, An = (e) => e.isComposing || e.key === "Process" || e.keyCode === 229,
|
|
637
|
+
} : () => void 0, Tn = "zt-md-ime-isolating", En = new R("ZT_MD_IME_COMPOSITION_ISOLATION"), Dn = 30, On = 4e3, kn = 150, An = "button, input, textarea, select, [contenteditable=\"false\"]", jn = (e) => e.isComposing || e.key === "Process" || e.keyCode === 229, Mn = (e) => e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey, Nn = (e) => e instanceof Element && e.closest(An) !== null, Pn = (e, t) => {
|
|
638
638
|
let n = t;
|
|
639
639
|
for (; n && n.parentNode !== e;) n = n.parentNode;
|
|
640
640
|
return n instanceof HTMLElement ? n : null;
|
|
641
|
-
},
|
|
641
|
+
}, Fn = (e) => {
|
|
642
642
|
let t = e.ownerDocument.defaultView?.getSelection();
|
|
643
643
|
if (!t || t.rangeCount === 0 || !t.isCollapsed) return null;
|
|
644
|
-
let n =
|
|
644
|
+
let n = Pn(e, t.anchorNode);
|
|
645
645
|
return !n || n.getAttribute("contenteditable") === "false" ? null : n;
|
|
646
|
-
},
|
|
646
|
+
}, In = (e) => {
|
|
647
647
|
let t = e.ownerDocument.defaultView?.getSelection();
|
|
648
|
-
return !t || t.rangeCount === 0 || !t.
|
|
649
|
-
|
|
650
|
-
|
|
648
|
+
return !t || t.rangeCount === 0 || !t.anchorNode || !t.focusNode || !e.contains(t.anchorNode) || !e.contains(t.focusNode) ? null : {
|
|
649
|
+
anchorNode: t.anchorNode,
|
|
650
|
+
anchorOffset: t.anchorOffset,
|
|
651
|
+
focusNode: t.focusNode,
|
|
652
|
+
focusOffset: t.focusOffset
|
|
651
653
|
};
|
|
652
|
-
},
|
|
653
|
-
if (!t || !t.
|
|
654
|
+
}, Ln = (e, t) => {
|
|
655
|
+
if (!t || !t.anchorNode.isConnected || !t.focusNode.isConnected || !e.contains(t.anchorNode) || !e.contains(t.focusNode)) return;
|
|
654
656
|
let n = e.ownerDocument.defaultView?.getSelection();
|
|
655
|
-
if (!n || n.rangeCount > 0 && n.
|
|
657
|
+
if (!n || n.rangeCount > 0 && n.anchorNode === t.anchorNode && n.anchorOffset === t.anchorOffset && n.focusNode === t.focusNode && n.focusOffset === t.focusOffset) return;
|
|
658
|
+
if (typeof n.setBaseAndExtent == "function") {
|
|
659
|
+
n.setBaseAndExtent(t.anchorNode, t.anchorOffset, t.focusNode, t.focusOffset);
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
656
662
|
let r = e.ownerDocument.createRange();
|
|
657
|
-
r.setStart(t.
|
|
658
|
-
},
|
|
663
|
+
r.setStart(t.anchorNode, t.anchorOffset), t.anchorNode === t.focusNode && t.anchorOffset === t.focusOffset ? r.collapse(!0) : r.setEnd(t.focusNode, t.focusOffset), n.removeAllRanges(), n.addRange(r);
|
|
664
|
+
}, Rn = V(() => new L({
|
|
659
665
|
key: En,
|
|
660
666
|
view(e) {
|
|
661
|
-
let t = e.dom, n =
|
|
662
|
-
|
|
663
|
-
},
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
667
|
+
let t = e.dom, n = t.ownerDocument, r = e, i = !1, a = null, o = null, s = !1, c = !1, l = null, u = !1, d = () => {
|
|
668
|
+
l !== null && (clearTimeout(l), l = null);
|
|
669
|
+
}, f = () => t.getAttribute("contenteditable") === "true" && (r.state.doc.content.size >= On || t.childElementCount >= Dn), p = (e) => {
|
|
670
|
+
let r = n.activeElement;
|
|
671
|
+
if (!(r instanceof Node) || !t.contains(r) || r === t) return;
|
|
672
|
+
let i = e ? In(t) : null;
|
|
673
|
+
c = !0;
|
|
674
|
+
try {
|
|
675
|
+
t.focus({ preventScroll: !0 });
|
|
676
|
+
} finally {
|
|
677
|
+
c = !1;
|
|
678
|
+
}
|
|
679
|
+
e && Ln(t, i);
|
|
680
|
+
}, m = () => {
|
|
681
|
+
if (i || s || r.composing || !r.state.selection.empty || !f()) return;
|
|
682
|
+
let e = n.activeElement;
|
|
683
|
+
if (!(e instanceof Node) || !t.contains(e) || e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement) return;
|
|
684
|
+
let o = Fn(t);
|
|
685
|
+
if (!o) return;
|
|
686
|
+
let c = In(t);
|
|
687
|
+
t.classList.add(Tn), i = !0, a = o, n.activeElement !== o && (o.focus({ preventScroll: !0 }), Ln(t, c));
|
|
688
|
+
}, h = (e = {}) => {
|
|
689
|
+
d(), i ? (t.classList.remove(Tn), i = !1, a = null) : a = null, e.restoreFocus && p(e.preserveSelection ?? !0);
|
|
690
|
+
}, g = (e) => {
|
|
691
|
+
if (o = null, h({ restoreFocus: !1 }), t.getAttribute("contenteditable") === "true") {
|
|
692
|
+
c = !0;
|
|
693
|
+
try {
|
|
694
|
+
e.focus();
|
|
695
|
+
} finally {
|
|
696
|
+
c = !1;
|
|
697
|
+
}
|
|
698
|
+
!e.composing && e.state.selection.empty && f() && _(0);
|
|
699
|
+
}
|
|
700
|
+
}, _ = (e = 0) => {
|
|
701
|
+
d(), !(i || s || r.composing || !f()) && (l = setTimeout(() => {
|
|
702
|
+
l = null, m();
|
|
678
703
|
}, e));
|
|
679
|
-
},
|
|
680
|
-
if (
|
|
681
|
-
|
|
704
|
+
}, v = (e) => {
|
|
705
|
+
if (jn(e)) {
|
|
706
|
+
d();
|
|
682
707
|
return;
|
|
683
708
|
}
|
|
684
|
-
e.key !== "Shift" &&
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
709
|
+
e.key !== "Shift" && h({
|
|
710
|
+
restoreFocus: !0,
|
|
711
|
+
preserveSelection: !0
|
|
712
|
+
});
|
|
713
|
+
}, y = (e) => {
|
|
714
|
+
if (!(jn(e) || r.composing)) {
|
|
715
|
+
if (Mn(e)) {
|
|
716
|
+
_(kn);
|
|
689
717
|
return;
|
|
690
718
|
}
|
|
691
|
-
|
|
719
|
+
_(0);
|
|
692
720
|
}
|
|
693
|
-
},
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
721
|
+
}, b = (e) => {
|
|
722
|
+
if (s = !0, !Nn(e.target)) {
|
|
723
|
+
h({
|
|
724
|
+
restoreFocus: !0,
|
|
725
|
+
preserveSelection: !0
|
|
726
|
+
});
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
h({ restoreFocus: !1 });
|
|
730
|
+
}, x = (e) => {
|
|
731
|
+
s = !1, e.type === "pointerup" && e.target instanceof Node && t.contains(e.target) && _(0);
|
|
732
|
+
}, S = (e) => {
|
|
733
|
+
c || s || e.target !== t || _(0);
|
|
734
|
+
}, C = () => {
|
|
735
|
+
if (r.composing) return;
|
|
736
|
+
let e = n.defaultView?.getSelection();
|
|
737
|
+
if (!e || e.rangeCount === 0 || e.isCollapsed || !e.anchorNode || !t.contains(e.anchorNode)) return;
|
|
738
|
+
let a = n.activeElement, o = a instanceof Node && t.contains(a) && a !== t;
|
|
739
|
+
(i || o) && h({
|
|
740
|
+
restoreFocus: t.getAttribute("contenteditable") === "true",
|
|
741
|
+
preserveSelection: !0
|
|
742
|
+
});
|
|
743
|
+
}, w = () => {
|
|
744
|
+
i || _(0);
|
|
745
|
+
}, T = (e) => {
|
|
746
|
+
if (u || i && a !== null && !a.isConnected) return;
|
|
703
747
|
if (e.relatedTarget instanceof Node && t.contains(e.relatedTarget)) {
|
|
704
|
-
|
|
748
|
+
i && e.target === t && e.stopImmediatePropagation();
|
|
705
749
|
return;
|
|
706
750
|
}
|
|
707
|
-
let
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
751
|
+
let s = e.target !== t, c = s ? a ?? (e.target instanceof HTMLElement ? e.target : null) : null, l = e.relatedTarget;
|
|
752
|
+
h({ restoreFocus: !1 }), s && (c !== null && (o = c), queueMicrotask(() => {
|
|
753
|
+
if (c !== null) {
|
|
754
|
+
if (o !== c) return;
|
|
755
|
+
if (o = null, !c.isConnected) {
|
|
756
|
+
g(r);
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
714
759
|
}
|
|
715
|
-
|
|
760
|
+
if (!(n.activeElement instanceof Node && t.contains(n.activeElement))) {
|
|
761
|
+
u = !0;
|
|
762
|
+
try {
|
|
763
|
+
t.dispatchEvent(new FocusEvent("blur", { relatedTarget: l }));
|
|
764
|
+
} finally {
|
|
765
|
+
u = !1;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}));
|
|
716
769
|
};
|
|
717
|
-
return t.addEventListener("keydown",
|
|
770
|
+
return t.addEventListener("keydown", v, !0), t.addEventListener("keyup", y, !0), t.addEventListener("pointerdown", b, !0), n.addEventListener("pointerup", x, !0), n.addEventListener("pointercancel", x, !0), t.addEventListener("focus", S, !0), n.addEventListener("selectionchange", C), t.addEventListener("compositionend", w, !1), t.addEventListener("blur", T, !0), {
|
|
718
771
|
update(e) {
|
|
719
|
-
|
|
772
|
+
if (r = e, i && a !== null && !a.isConnected || o !== null && !o.isConnected) {
|
|
773
|
+
g(e);
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
i && (!f() || !e.composing && !e.state.selection.empty) && h({
|
|
777
|
+
restoreFocus: t.getAttribute("contenteditable") === "true",
|
|
778
|
+
preserveSelection: !0
|
|
779
|
+
});
|
|
720
780
|
},
|
|
721
781
|
destroy() {
|
|
722
|
-
o(),
|
|
782
|
+
o = null, d(), h({ restoreFocus: !1 }), t.removeEventListener("keydown", v, !0), t.removeEventListener("keyup", y, !0), t.removeEventListener("pointerdown", b, !0), n.removeEventListener("pointerup", x, !0), n.removeEventListener("pointercancel", x, !0), t.removeEventListener("focus", S, !0), n.removeEventListener("selectionchange", C), t.removeEventListener("compositionend", w, !1), t.removeEventListener("blur", T, !0);
|
|
723
783
|
}
|
|
724
784
|
};
|
|
725
785
|
}
|
|
726
|
-
})),
|
|
786
|
+
})), zn = new R("ZT_MD_MARKDOWN_SYNC"), Bn = 30, Vn = 8e3, Hn = 450, Un = 30, Wn = 1e3, Gn = 400, Kn = (e) => {
|
|
727
787
|
let t = Math.max(0, e.debounceMs), n = !1, r = null, i = null, a = null, o = null, s = null, c = !1, l = null, u = null, d = null, f = 0, p = () => {
|
|
728
788
|
l !== null && (clearTimeout(l), l = null);
|
|
729
789
|
}, m = () => {
|
|
@@ -738,8 +798,8 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
738
798
|
f = Math.max(0, o - n), a = t.state.doc, r !== i && (i = r, e.onChange(r));
|
|
739
799
|
}, g = (e) => {
|
|
740
800
|
if (t <= 0) return 0;
|
|
741
|
-
if (e <
|
|
742
|
-
let n = e >=
|
|
801
|
+
if (e < Vn && f < Un) return t;
|
|
802
|
+
let n = e >= Vn ? Hn : 0, r = f >= Un ? Math.min(Wn, Math.round(f * 4)) : 0;
|
|
743
803
|
return Math.max(t, n, r);
|
|
744
804
|
}, _ = (e) => {
|
|
745
805
|
m();
|
|
@@ -750,10 +810,10 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
750
810
|
}
|
|
751
811
|
u = setTimeout(() => {
|
|
752
812
|
if (u = null, !(!o || o.composing || n)) {
|
|
753
|
-
if (o.state.doc.content.size >=
|
|
813
|
+
if (o.state.doc.content.size >= Vn && typeof requestIdleCallback == "function") {
|
|
754
814
|
d = requestIdleCallback(() => {
|
|
755
815
|
d = null, o && !o.composing && !n && h(o);
|
|
756
|
-
}, { timeout:
|
|
816
|
+
}, { timeout: Gn });
|
|
757
817
|
return;
|
|
758
818
|
}
|
|
759
819
|
h(o);
|
|
@@ -762,13 +822,13 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
762
822
|
};
|
|
763
823
|
return {
|
|
764
824
|
plugin: V(() => new L({
|
|
765
|
-
key:
|
|
825
|
+
key: zn,
|
|
766
826
|
props: { handleDOMEvents: {
|
|
767
827
|
keydown: (e, t) => ((t.isComposing || t.key === "Process" || t.keyCode === 229) && (p(), m()), !1),
|
|
768
828
|
compositionstart: () => (p(), m(), !1),
|
|
769
829
|
compositionend: () => (p(), l = setTimeout(() => {
|
|
770
830
|
l = null, o && !o.composing && !n && (c || o.state.doc !== a) && (c = !1, _(o));
|
|
771
|
-
},
|
|
831
|
+
}, Bn), !1),
|
|
772
832
|
blur: (e, t) => e.composing || n || t instanceof FocusEvent && t.relatedTarget instanceof Node && e.dom.contains(t.relatedTarget) ? !1 : (p(), m(), h(e), !1)
|
|
773
833
|
} },
|
|
774
834
|
view: (e) => (o = e, a = e.state.doc, {
|
|
@@ -816,23 +876,23 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
816
876
|
name: t,
|
|
817
877
|
plugin: n
|
|
818
878
|
});
|
|
819
|
-
},
|
|
879
|
+
}, qn = (e, t = {}) => {
|
|
820
880
|
let n = [], r = t.includeRuntime ?? !0;
|
|
821
|
-
return e.listener && K(n, "listener", e.listener), K(n, "commonmark", e.commonmark), K(n, "frontmatter", e.frontmatter), K(n, "task-list-transform-keymap", e.taskListTransformKeymap), K(n, "inline-code-boundary-navigation", e.inlineCodeBoundaryNavigation), K(n, "gfm", e.gfm), K(n, "cjk-friendly", e.cjkFriendly), K(n, "history", e.history), K(n, "editor-search", e.editorSearch), K(n, "code-block-prism", e.codeBlockPrism), K(n, "code-block-language-picker", e.codeBlockLanguagePicker), r && (K(n, "clipboard", e.clipboard), K(n, "indent", e.indent)), K(n, "image-delete-selection", e.imageDeleteSelection), K(n, "image-paste", e.imagePaste), K(n, "table-arrow-entry", e.tableArrowEntry), K(n, "block-boundary-navigation", e.blockBoundaryNavigation), K(n, "heading-backspace-empty-paragraph", e.headingBackspaceEmptyParagraph), K(n, "heading-focus-indicator", e.headingFocusIndicator), K(n, "math-backspace-entry", e.mathBackspaceEntry), K(n, "blockquote-backspace-lift", e.blockquoteBackspaceLift), K(n, "table-focus-actions", e.tableFocusActions), K(n, "selection-tooltip", e.selectionTooltip), K(n, "gap-cursor", e.gapCursor), K(n, "drop-cursor", e.dropCursor), K(n, "math", e.math), K(n, "math-inline-edit", e.mathInlineEdit), K(n, "math-inline-arrow-navigation", e.mathInlineArrowNavigation), K(n, "task-list-toggle", e.taskListToggle), K(n, "tab-space-indent", e.tabSpaceIndent), K(n, "code-block-mod-a-select", e.codeBlockModASelect),
|
|
822
|
-
},
|
|
823
|
-
color:
|
|
824
|
-
width:
|
|
825
|
-
})),
|
|
881
|
+
return e.listener && K(n, "listener", e.listener), e.slash && K(n, "slash", e.slash), K(n, "commonmark", e.commonmark), K(n, "frontmatter", e.frontmatter), K(n, "task-list-transform-keymap", e.taskListTransformKeymap), K(n, "inline-code-boundary-navigation", e.inlineCodeBoundaryNavigation), K(n, "gfm", e.gfm), K(n, "cjk-friendly", e.cjkFriendly), K(n, "history", e.history), K(n, "editor-search", e.editorSearch), K(n, "code-block-prism", e.codeBlockPrism), K(n, "code-block-language-picker", e.codeBlockLanguagePicker), r && (K(n, "clipboard", e.clipboard), K(n, "indent", e.indent)), K(n, "image-delete-selection", e.imageDeleteSelection), K(n, "image-paste", e.imagePaste), K(n, "table-arrow-entry", e.tableArrowEntry), K(n, "block-boundary-navigation", e.blockBoundaryNavigation), K(n, "heading-backspace-empty-paragraph", e.headingBackspaceEmptyParagraph), K(n, "heading-focus-indicator", e.headingFocusIndicator), K(n, "math-backspace-entry", e.mathBackspaceEntry), K(n, "blockquote-backspace-lift", e.blockquoteBackspaceLift), K(n, "table-focus-actions", e.tableFocusActions), K(n, "selection-tooltip", e.selectionTooltip), K(n, "gap-cursor", e.gapCursor), K(n, "drop-cursor", e.dropCursor), K(n, "math", e.math), K(n, "math-inline-edit", e.mathInlineEdit), K(n, "math-inline-arrow-navigation", e.mathInlineArrowNavigation), K(n, "task-list-toggle", e.taskListToggle), K(n, "tab-space-indent", e.tabSpaceIndent), K(n, "code-block-mod-a-select", e.codeBlockModASelect), n;
|
|
882
|
+
}, Jn = 2, Yn = "var(--zt-primary)", Xn = V(() => gt({
|
|
883
|
+
color: Yn,
|
|
884
|
+
width: Jn
|
|
885
|
+
})), Zn = V(() => vt()), Qn = -1, $n = 1, er = new Set([
|
|
826
886
|
"math_block",
|
|
827
887
|
"code_block",
|
|
828
888
|
"frontmatter",
|
|
829
889
|
"table",
|
|
830
890
|
"image",
|
|
831
891
|
"hr"
|
|
832
|
-
]),
|
|
892
|
+
]), tr = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, nr = (e, t, n) => {
|
|
833
893
|
let r = e.state.doc.resolve(t);
|
|
834
894
|
return _t.valid(r) ? new _t(r) : z.near(r, n);
|
|
835
|
-
},
|
|
895
|
+
}, rr = (e, t) => t === Qn ? e.nodeBefore !== null : e.nodeAfter !== null, ir = (e, t) => {
|
|
836
896
|
let n = e.state.schema.nodes.paragraph;
|
|
837
897
|
if (!n) return !1;
|
|
838
898
|
let r = e.state.doc.resolve(t), i = r.index();
|
|
@@ -841,53 +901,53 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
841
901
|
if (!a) return !1;
|
|
842
902
|
let o = e.state.tr.insert(t, a), s = t + 1;
|
|
843
903
|
return o.setSelection(z.near(o.doc.resolve(s), 1)).scrollIntoView(), e.dispatch(o), e.focus(), !0;
|
|
844
|
-
},
|
|
845
|
-
if (!
|
|
846
|
-
let i = r ===
|
|
904
|
+
}, ar = (e, t, n, r) => {
|
|
905
|
+
if (!er.has(n.type.name) || n.type.name === "frontmatter" && r === Qn) return !1;
|
|
906
|
+
let i = r === Qn ? t : t + n.nodeSize;
|
|
847
907
|
if (i < 0 || i > e.state.doc.content.size) return !1;
|
|
848
|
-
if (!
|
|
849
|
-
let a = e.state.tr.setSelection(
|
|
908
|
+
if (!rr(e.state.doc.resolve(i), r) && ir(e, i)) return !0;
|
|
909
|
+
let a = e.state.tr.setSelection(nr(e, i, r)).scrollIntoView();
|
|
850
910
|
return e.dispatch(a), e.focus(), !0;
|
|
851
|
-
},
|
|
911
|
+
}, or = (e) => {
|
|
852
912
|
for (let t = e.depth; t > 0; --t) {
|
|
853
913
|
let n = e.node(t);
|
|
854
|
-
if (
|
|
914
|
+
if (er.has(n.type.name)) return {
|
|
855
915
|
node: n,
|
|
856
916
|
position: e.before(t),
|
|
857
917
|
depth: t
|
|
858
918
|
};
|
|
859
919
|
}
|
|
860
920
|
return null;
|
|
861
|
-
},
|
|
921
|
+
}, sr = (e, t, n) => {
|
|
862
922
|
for (let r = t; r < e.depth; r += 1) {
|
|
863
923
|
let t = e.node(r);
|
|
864
|
-
if (e.index(r) !== (n ===
|
|
924
|
+
if (e.index(r) !== (n === Qn ? 0 : t.childCount - 1)) return !1;
|
|
865
925
|
}
|
|
866
926
|
return !0;
|
|
867
|
-
},
|
|
927
|
+
}, cr = (e, t) => {
|
|
868
928
|
let { selection: n } = e.state;
|
|
869
|
-
if (n instanceof I) return
|
|
929
|
+
if (n instanceof I) return ar(e, n.from, n.node, t);
|
|
870
930
|
if (!n.empty) return !1;
|
|
871
|
-
let r =
|
|
872
|
-
return !r || !
|
|
873
|
-
},
|
|
931
|
+
let r = or(n.$from);
|
|
932
|
+
return !r || !sr(n.$from, r.depth, t) || !e.endOfTextblock(t === Qn ? "up" : "down") ? !1 : ar(e, r.position, r.node, t);
|
|
933
|
+
}, lr = (e) => {
|
|
874
934
|
let { doc: t, selection: n } = e.state;
|
|
875
|
-
return !(n instanceof z) || !n.empty || !(n.$from.after(1) === t.content.size &&
|
|
876
|
-
},
|
|
877
|
-
ArrowUp: (e) =>
|
|
878
|
-
ArrowDown: (e) =>
|
|
879
|
-
},
|
|
880
|
-
let i = r === "ArrowUp" ?
|
|
881
|
-
return i === null ||
|
|
882
|
-
},
|
|
935
|
+
return !(n instanceof z) || !n.empty || !(n.$from.after(1) === t.content.size && sr(n.$from, 1, $n)) || !e.endOfTextblock("down") ? !1 : ir(e, t.content.size);
|
|
936
|
+
}, ur = {
|
|
937
|
+
ArrowUp: (e) => cr(e, Qn),
|
|
938
|
+
ArrowDown: (e) => cr(e, $n) || lr(e)
|
|
939
|
+
}, dr = (e, t) => t.defaultPrevented || t.altKey || t.ctrlKey || t.metaKey || t.shiftKey || !tr(e), fr = (e, t, n, r) => {
|
|
940
|
+
let i = r === "ArrowUp" ? Qn : r === "ArrowDown" ? $n : null;
|
|
941
|
+
return i === null || !tr(e) ? !1 : ar(e, t, n, i);
|
|
942
|
+
}, pr = V(() => new L({
|
|
883
943
|
key: new R("zt-md-block-boundary-navigation"),
|
|
884
944
|
props: { handleKeyDown: (e, t) => {
|
|
885
|
-
let n =
|
|
886
|
-
if (!n ||
|
|
945
|
+
let n = ur[t.key];
|
|
946
|
+
if (!n || dr(e, t)) return !1;
|
|
887
947
|
let r = n(e);
|
|
888
948
|
return r && t.preventDefault(), r;
|
|
889
949
|
} }
|
|
890
|
-
})),
|
|
950
|
+
})), mr = {
|
|
891
951
|
AlignCenter: [
|
|
892
952
|
["path", { d: "M21 5H3" }],
|
|
893
953
|
["path", { d: "M17 12H7" }],
|
|
@@ -1126,28 +1186,28 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1126
1186
|
["path", { d: "M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" }],
|
|
1127
1187
|
["path", { d: "M9 20h6" }]
|
|
1128
1188
|
]
|
|
1129
|
-
},
|
|
1130
|
-
let n = t.size ?? 16, r = t.strokeWidth ?? 2, i = t.ariaHidden ?? !0, a = `${e}:${n}:${r}:${i}`, o =
|
|
1189
|
+
}, hr = /* @__PURE__ */ new Map(), gr = (e) => Object.entries(e).map(([e, t]) => `${e}="${t}"`).join(" "), _r = (e, t) => e && Object.prototype.hasOwnProperty.call(mr, e) ? e : t, q = (e, t = {}) => {
|
|
1190
|
+
let n = t.size ?? 16, r = t.strokeWidth ?? 2, i = t.ariaHidden ?? !0, a = `${e}:${n}:${r}:${i}`, o = hr.get(a);
|
|
1131
1191
|
if (o !== void 0) return o;
|
|
1132
|
-
let s =
|
|
1133
|
-
return
|
|
1134
|
-
},
|
|
1192
|
+
let s = mr[e].map(([e, t]) => `<${e} ${gr(t)}></${e}>`).join(""), c = `<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${n}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${r}" stroke-linecap="round" stroke-linejoin="round"${i ? " aria-hidden=\"true\"" : ""}>${s}</svg>`;
|
|
1193
|
+
return hr.set(a, c), c;
|
|
1194
|
+
}, vr = new Set([
|
|
1135
1195
|
"http:",
|
|
1136
1196
|
"https:",
|
|
1137
1197
|
"mailto:",
|
|
1138
1198
|
"tel:"
|
|
1139
|
-
]),
|
|
1199
|
+
]), yr = new Set(["data:"]), br = /[\u0000-\u0020\u007f]+/g, xr = /^([a-z][a-z\d+\-.]*:)/i, Sr = /[<>"'`]/, Cr = new Set([
|
|
1140
1200
|
"src",
|
|
1141
1201
|
"alt",
|
|
1142
1202
|
"title",
|
|
1143
1203
|
"style"
|
|
1144
|
-
]),
|
|
1204
|
+
]), wr = (e, t) => {
|
|
1145
1205
|
if (typeof e != "string") return "";
|
|
1146
1206
|
let n = e.trim();
|
|
1147
|
-
if (!n ||
|
|
1148
|
-
let r = n.replace(
|
|
1207
|
+
if (!n || Sr.test(n) || /[\u0000-\u001f\u007f]/.test(n)) return "";
|
|
1208
|
+
let r = n.replace(br, "");
|
|
1149
1209
|
if (r.startsWith("//")) return "";
|
|
1150
|
-
let i = r.match(
|
|
1210
|
+
let i = r.match(xr)?.[1]?.toLowerCase() ?? "";
|
|
1151
1211
|
if (!i) return n;
|
|
1152
1212
|
if (!t.has(i)) return "";
|
|
1153
1213
|
try {
|
|
@@ -1155,11 +1215,11 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1155
1215
|
} catch {
|
|
1156
1216
|
return "";
|
|
1157
1217
|
}
|
|
1158
|
-
},
|
|
1159
|
-
...
|
|
1160
|
-
...
|
|
1218
|
+
}, Tr = (e) => wr(e, vr), Er = (e, t = []) => wr(e, new Set([
|
|
1219
|
+
...vr,
|
|
1220
|
+
...yr,
|
|
1161
1221
|
...t.map((e) => e.trim().toLowerCase())
|
|
1162
|
-
])),
|
|
1222
|
+
])), Dr = (e, t, n = []) => {
|
|
1163
1223
|
if (typeof e != "string") return null;
|
|
1164
1224
|
let r = e.trim();
|
|
1165
1225
|
if (!r) return null;
|
|
@@ -1172,32 +1232,32 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1172
1232
|
return null;
|
|
1173
1233
|
}
|
|
1174
1234
|
if (!a || a.tagName.toLowerCase() !== "img") return null;
|
|
1175
|
-
for (let e of Array.from(a.attributes)) if (!
|
|
1176
|
-
let o =
|
|
1235
|
+
for (let e of Array.from(a.attributes)) if (!Cr.has(e.name.toLowerCase())) return null;
|
|
1236
|
+
let o = Er(a.getAttribute("src") ?? "", n);
|
|
1177
1237
|
return o ? {
|
|
1178
1238
|
src: o,
|
|
1179
1239
|
alt: a.getAttribute("alt") ?? "",
|
|
1180
1240
|
title: a.getAttribute("title") ?? "",
|
|
1181
1241
|
style: t(a.getAttribute("style") ?? "")
|
|
1182
1242
|
} : null;
|
|
1183
|
-
},
|
|
1243
|
+
}, Or = /^\s*width\s*:\s*(\d{1,3})%\s*;?\s*$/i, kr = (e, t) => {
|
|
1184
1244
|
let n = Array.isArray(e.children) ? e.children : [], r = n[0];
|
|
1185
|
-
return n.length === 1 && (r?.type === "image" || r?.type === "html" &&
|
|
1186
|
-
},
|
|
1245
|
+
return n.length === 1 && (r?.type === "image" || r?.type === "html" && Dr(r.value, Nr, t) !== null) ? r : null;
|
|
1246
|
+
}, Ar = (e) => Math.min(100, Math.max(10, e)), jr = (e) => `width: ${Ar(Math.round(e))}%;`, Mr = (e) => {
|
|
1187
1247
|
if (typeof e != "string") return null;
|
|
1188
|
-
let t = e.match(
|
|
1248
|
+
let t = e.match(Or);
|
|
1189
1249
|
if (!t) return null;
|
|
1190
1250
|
let n = Number(t[1]);
|
|
1191
|
-
return Number.isFinite(n) ?
|
|
1192
|
-
},
|
|
1193
|
-
let t =
|
|
1194
|
-
return t === null ? "" :
|
|
1195
|
-
},
|
|
1196
|
-
let n =
|
|
1251
|
+
return Number.isFinite(n) ? Ar(n) : null;
|
|
1252
|
+
}, Nr = (e) => {
|
|
1253
|
+
let t = Mr(e);
|
|
1254
|
+
return t === null ? "" : jr(t);
|
|
1255
|
+
}, Pr = (e) => typeof e == "string" ? e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">") : "", Fr = (e, t) => {
|
|
1256
|
+
let n = Er(e.src, t);
|
|
1197
1257
|
if (!n) return "";
|
|
1198
|
-
let r = typeof e.alt == "string" ? e.alt : "", i = typeof e.title == "string" ? e.title : "", a = i ? ` title="${
|
|
1199
|
-
return `<img src="${
|
|
1200
|
-
},
|
|
1258
|
+
let r = typeof e.alt == "string" ? e.alt : "", i = typeof e.title == "string" ? e.title : "", a = i ? ` title="${Pr(i)}"` : "", o = Nr(e.style);
|
|
1259
|
+
return `<img src="${Pr(n)}" alt="${Pr(r)}"${a} style="${Pr(o)}">`;
|
|
1260
|
+
}, Ir = (e, t) => (n) => {
|
|
1201
1261
|
let r = e(n);
|
|
1202
1262
|
return {
|
|
1203
1263
|
...r,
|
|
@@ -1213,24 +1273,24 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1213
1273
|
parseDOM: [{
|
|
1214
1274
|
tag: "img[src]",
|
|
1215
1275
|
getAttrs: (e) => {
|
|
1216
|
-
let n = e, r =
|
|
1276
|
+
let n = e, r = Er(n.getAttribute("src") ?? "", t);
|
|
1217
1277
|
return r ? {
|
|
1218
1278
|
src: r,
|
|
1219
1279
|
alt: n.getAttribute("alt") ?? "",
|
|
1220
1280
|
title: n.getAttribute("title") ?? n.getAttribute("alt") ?? "",
|
|
1221
|
-
style:
|
|
1281
|
+
style: Nr(n.getAttribute("style") ?? "")
|
|
1222
1282
|
} : !1;
|
|
1223
1283
|
}
|
|
1224
1284
|
}],
|
|
1225
1285
|
parseMarkdown: {
|
|
1226
|
-
match: (e) => e.type === "image" || e.type === "html" &&
|
|
1286
|
+
match: (e) => e.type === "image" || e.type === "html" && Dr(e.value, Nr, t) !== null,
|
|
1227
1287
|
runner: (e, n, r) => {
|
|
1228
1288
|
if (n.type === "html") {
|
|
1229
|
-
let i =
|
|
1289
|
+
let i = Dr(n.value, Nr, t);
|
|
1230
1290
|
i && e.addNode(r, i);
|
|
1231
1291
|
return;
|
|
1232
1292
|
}
|
|
1233
|
-
let i =
|
|
1293
|
+
let i = Er(String(n.url ?? ""), t);
|
|
1234
1294
|
i && e.addNode(r, {
|
|
1235
1295
|
src: i,
|
|
1236
1296
|
alt: String(n.alt ?? ""),
|
|
@@ -1242,11 +1302,11 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1242
1302
|
toMarkdown: {
|
|
1243
1303
|
match: (e) => e.type.name === "image",
|
|
1244
1304
|
runner: (e, n) => {
|
|
1245
|
-
let r =
|
|
1305
|
+
let r = Er(n.attrs.src, t);
|
|
1246
1306
|
if (!r) return;
|
|
1247
|
-
let i =
|
|
1307
|
+
let i = Nr(n.attrs.style);
|
|
1248
1308
|
if (i) {
|
|
1249
|
-
let a =
|
|
1309
|
+
let a = Fr({
|
|
1250
1310
|
...n.attrs,
|
|
1251
1311
|
src: r,
|
|
1252
1312
|
style: i
|
|
@@ -1264,14 +1324,14 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1264
1324
|
}
|
|
1265
1325
|
}
|
|
1266
1326
|
};
|
|
1267
|
-
},
|
|
1327
|
+
}, Lr = (e, t) => (n) => {
|
|
1268
1328
|
let r = e(n);
|
|
1269
1329
|
return {
|
|
1270
1330
|
...r,
|
|
1271
1331
|
parseMarkdown: {
|
|
1272
1332
|
...r.parseMarkdown,
|
|
1273
1333
|
runner: (e, n, i) => {
|
|
1274
|
-
let a =
|
|
1334
|
+
let a = kr(n, t);
|
|
1275
1335
|
if (a) {
|
|
1276
1336
|
e.next(a);
|
|
1277
1337
|
return;
|
|
@@ -1280,32 +1340,32 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1280
1340
|
}
|
|
1281
1341
|
}
|
|
1282
1342
|
};
|
|
1283
|
-
},
|
|
1343
|
+
}, Rr = (e, t = []) => {
|
|
1284
1344
|
let n = e.get(Re.key), r = e.get(We.key);
|
|
1285
|
-
e.set(Re.key,
|
|
1286
|
-
},
|
|
1345
|
+
e.set(Re.key, Ir(n, t)), e.set(We.key, Lr(r, t));
|
|
1346
|
+
}, zr = "image", Br = "left", Vr = "right", Hr = 160, Ur = q("Trash2", {
|
|
1287
1347
|
size: 14,
|
|
1288
1348
|
strokeWidth: 2
|
|
1289
|
-
}),
|
|
1349
|
+
}), Wr = q("ImageOff", {
|
|
1290
1350
|
size: 14,
|
|
1291
1351
|
strokeWidth: 2
|
|
1292
|
-
}),
|
|
1352
|
+
}), Gr = (e) => typeof e == "function" ? e() : null, Kr = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, qr = class {
|
|
1293
1353
|
constructor(e, t, n, r) {
|
|
1294
1354
|
this.resizeState = null, this.isSelected = !1, this.currentImageSrc = "", this.imageLoadingStartedAt = 0, this.imageLoadingFinishTimer = null, this.handleDeleteClick = (e) => {
|
|
1295
|
-
e.preventDefault(), e.stopPropagation(),
|
|
1355
|
+
e.preventDefault(), e.stopPropagation(), Kr(this.view) && this.deleteCurrentImage();
|
|
1296
1356
|
}, this.handleImageLoad = () => {
|
|
1297
1357
|
delete this.dom.dataset.loadError, this.finishImageLoadingWithMinimumDuration();
|
|
1298
1358
|
}, this.handleImageError = () => {
|
|
1299
1359
|
this.dom.dataset.loadError = "true", this.finishImageLoadingWithMinimumDuration();
|
|
1300
1360
|
}, this.handleResizePointerDown = (e) => {
|
|
1301
|
-
if (e.preventDefault(), e.stopPropagation(), !
|
|
1361
|
+
if (e.preventDefault(), e.stopPropagation(), !Kr(this.view)) return;
|
|
1302
1362
|
let t = e.currentTarget;
|
|
1303
1363
|
if (!(t instanceof HTMLElement)) return;
|
|
1304
|
-
let n = t.dataset.side ===
|
|
1364
|
+
let n = t.dataset.side === Br ? Br : Vr, r = this.dom.parentElement;
|
|
1305
1365
|
if (!r) return;
|
|
1306
1366
|
let i = this.imageElement.getBoundingClientRect(), a = r.getBoundingClientRect();
|
|
1307
1367
|
if (i.width <= 0 || a.width <= 0) return;
|
|
1308
|
-
let o =
|
|
1368
|
+
let o = Ar(i.width / a.width * 100);
|
|
1309
1369
|
this.resizeState = {
|
|
1310
1370
|
side: n,
|
|
1311
1371
|
startClientX: e.clientX,
|
|
@@ -1316,13 +1376,13 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1316
1376
|
}, this.handleResizePointerMove = (e) => {
|
|
1317
1377
|
if (!this.resizeState) return;
|
|
1318
1378
|
e.preventDefault();
|
|
1319
|
-
let t = e.clientX - this.resizeState.startClientX, n = this.resizeState.side ===
|
|
1379
|
+
let t = e.clientX - this.resizeState.startClientX, n = this.resizeState.side === Br ? -t : t, r = Ar((this.resizeState.startWidth + n) / this.resizeState.containerWidth * 100);
|
|
1320
1380
|
this.resizeState.widthPercent = r, this.applyPreviewWidth(r);
|
|
1321
1381
|
}, this.handleResizePointerUp = (e) => {
|
|
1322
1382
|
if (e.preventDefault(), !this.resizeState) return;
|
|
1323
1383
|
let t = Math.round(this.resizeState.widthPercent);
|
|
1324
1384
|
this.resizeState = null, delete this.dom.dataset.resizing, this.removeResizeWindowListeners(), this.commitImageWidth(t);
|
|
1325
|
-
}, this.node = e, this.view = t, this.getPos = n, this.deleteAriaLabel = r.imageDeleteAriaLabel, this.dom = document.createElement("span"), this.dom.dataset.type =
|
|
1385
|
+
}, this.node = e, this.view = t, this.getPos = n, this.deleteAriaLabel = r.imageDeleteAriaLabel, this.dom = document.createElement("span"), this.dom.dataset.type = zr, this.dom.className = "zt-md-image", this.updateEditableState(), this.syncSelectedState(), this.imageElement = document.createElement("img"), this.imageElement.loading = "lazy", this.imageElement.decoding = "async", this.imageElement.addEventListener("load", this.handleImageLoad), this.imageElement.addEventListener("error", this.handleImageError), this.imageLoadErrorElement = document.createElement("span"), this.imageLoadErrorElement.className = "zt-md-image-load-error", this.imageLoadErrorElement.contentEditable = "false", this.imageLoadErrorElement.innerHTML = Wr, this.imageLoadErrorElement.append(r.imageUploadLoadFailed), this.leftResizeHandle = this.createResizeHandle(Br), this.rightResizeHandle = this.createResizeHandle(Vr), this.actionsContainer = document.createElement("span"), this.actionsContainer.className = "zt-md-image-actions", this.deleteButton = document.createElement("button"), this.deleteButton.type = "button", this.deleteButton.className = "zt-md-image-action-button zt-md-image-action-button-danger", this.deleteButton.setAttribute("aria-label", this.deleteAriaLabel), this.deleteButton.innerHTML = Ur, this.actionsContainer.appendChild(this.deleteButton), this.dom.append(this.imageElement, this.imageLoadErrorElement, this.leftResizeHandle, this.rightResizeHandle, this.actionsContainer), this.syncFromNode(e), this.deleteButton.addEventListener("click", this.handleDeleteClick), this.leftResizeHandle.addEventListener("pointerdown", this.handleResizePointerDown), this.rightResizeHandle.addEventListener("pointerdown", this.handleResizePointerDown), this.stopObservingMessages = G(r, () => {
|
|
1326
1386
|
this.deleteButton.setAttribute("aria-label", r.imageDeleteAriaLabel);
|
|
1327
1387
|
let e = this.imageLoadErrorElement.lastChild;
|
|
1328
1388
|
e && (e.textContent = r.imageUploadLoadFailed);
|
|
@@ -1333,7 +1393,7 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1333
1393
|
return t.className = `zt-md-image-resize-handle zt-md-image-resize-handle-${e}`, t.dataset.side = e, t.setAttribute("aria-hidden", "true"), t;
|
|
1334
1394
|
}
|
|
1335
1395
|
deleteCurrentImage() {
|
|
1336
|
-
let e =
|
|
1396
|
+
let e = Gr(this.getPos);
|
|
1337
1397
|
if (e === null) return;
|
|
1338
1398
|
let t = this.view.state.tr.delete(e, e + this.node.nodeSize).scrollIntoView();
|
|
1339
1399
|
this.view.dispatch(t), requestAnimationFrame(() => {
|
|
@@ -1341,7 +1401,7 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1341
1401
|
});
|
|
1342
1402
|
}
|
|
1343
1403
|
updateEditableState() {
|
|
1344
|
-
this.dom.dataset.editable =
|
|
1404
|
+
this.dom.dataset.editable = Kr(this.view) ? "true" : "false";
|
|
1345
1405
|
}
|
|
1346
1406
|
syncSelectedState() {
|
|
1347
1407
|
this.dom.dataset.selected = this.isSelected ? "true" : "false";
|
|
@@ -1353,7 +1413,7 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1353
1413
|
this.clearImageLoadingFinishTimer(), delete this.dom.dataset.loading;
|
|
1354
1414
|
}
|
|
1355
1415
|
finishImageLoadingWithMinimumDuration() {
|
|
1356
|
-
let e = performance.now() - this.imageLoadingStartedAt, t = Math.max(0,
|
|
1416
|
+
let e = performance.now() - this.imageLoadingStartedAt, t = Math.max(0, Hr - e);
|
|
1357
1417
|
if (t <= 0) {
|
|
1358
1418
|
this.finishImageLoading();
|
|
1359
1419
|
return;
|
|
@@ -1372,11 +1432,11 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1372
1432
|
this.dom.style.width = `${Math.round(e)}%`, this.dom.dataset.hasWidth = "true";
|
|
1373
1433
|
}
|
|
1374
1434
|
commitImageWidth(e) {
|
|
1375
|
-
let t =
|
|
1435
|
+
let t = Gr(this.getPos);
|
|
1376
1436
|
if (t === null) return;
|
|
1377
1437
|
let n = {
|
|
1378
1438
|
...this.node.attrs,
|
|
1379
|
-
style:
|
|
1439
|
+
style: jr(e)
|
|
1380
1440
|
}, r = this.view.state.tr.setNodeMarkup(t, void 0, n);
|
|
1381
1441
|
this.view.dispatch(r), requestAnimationFrame(() => {
|
|
1382
1442
|
this.view.focus();
|
|
@@ -1384,11 +1444,11 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1384
1444
|
}
|
|
1385
1445
|
syncFromNode(e) {
|
|
1386
1446
|
this.updateEditableState();
|
|
1387
|
-
let t = typeof e.attrs.src == "string" ? e.attrs.src : "", n = typeof e.attrs.alt == "string" ? e.attrs.alt : "", r = typeof e.attrs.title == "string" ? e.attrs.title : "", i =
|
|
1447
|
+
let t = typeof e.attrs.src == "string" ? e.attrs.src : "", n = typeof e.attrs.alt == "string" ? e.attrs.alt : "", r = typeof e.attrs.title == "string" ? e.attrs.title : "", i = Mr(Nr(e.attrs.style));
|
|
1388
1448
|
t !== this.currentImageSrc && (delete this.dom.dataset.loadError, t && this.markImageLoading()), this.imageElement.setAttribute("src", t), this.currentImageSrc = t, this.imageElement.setAttribute("alt", n), r ? this.imageElement.title = r : this.imageElement.removeAttribute("title"), i === null ? (this.dom.style.removeProperty("width"), delete this.dom.dataset.hasWidth) : (this.dom.style.width = `${i}%`, this.dom.dataset.hasWidth = "true"), t ? this.imageElement.complete && this.imageElement.naturalWidth > 0 && this.finishImageLoadingWithMinimumDuration() : this.finishImageLoading();
|
|
1389
1449
|
}
|
|
1390
1450
|
update(e) {
|
|
1391
|
-
return e.type.name ===
|
|
1451
|
+
return e.type.name === zr ? (this.node = e, this.syncFromNode(e), !0) : !1;
|
|
1392
1452
|
}
|
|
1393
1453
|
selectNode() {
|
|
1394
1454
|
this.isSelected = !0, this.syncSelectedState();
|
|
@@ -1406,63 +1466,63 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1406
1466
|
destroy() {
|
|
1407
1467
|
this.stopObservingMessages(), this.removeResizeWindowListeners(), this.clearImageLoadingFinishTimer(), this.imageElement.removeEventListener("load", this.handleImageLoad), this.imageElement.removeEventListener("error", this.handleImageError), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.leftResizeHandle.removeEventListener("pointerdown", this.handleResizePointerDown), this.rightResizeHandle.removeEventListener("pointerdown", this.handleResizePointerDown);
|
|
1408
1468
|
}
|
|
1409
|
-
},
|
|
1469
|
+
}, Jr = (e = W()) => (t, n, r) => new qr(t, n, typeof r == "function" ? () => {
|
|
1410
1470
|
let e = r();
|
|
1411
1471
|
return typeof e == "number" ? e : 0;
|
|
1412
|
-
} : !1, e),
|
|
1472
|
+
} : !1, e), Yr = "image", Xr = {
|
|
1413
1473
|
Backspace: "before",
|
|
1414
1474
|
Delete: "after"
|
|
1415
|
-
},
|
|
1475
|
+
}, Zr = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, Qr = (e) => e instanceof Element ? !!e.closest(".zt-md-image-actions, .zt-md-image-resize-handle") : !1, $r = (e) => e?.type.name === Yr, ei = (e, t) => !Xr[t.key] || t.defaultPrevented || t.altKey || t.ctrlKey || t.metaKey || t.shiftKey || !Zr(e) || Qr(t.target) || Qr(document.activeElement), ti = (e) => {
|
|
1416
1476
|
if (e.parent.type.name !== "paragraph" || e.parentOffset !== 0 || e.parent.textContent.length > 0 || e.depth < 1) return null;
|
|
1417
1477
|
let t = e.index(e.depth - 1);
|
|
1418
1478
|
if (t <= 0) return null;
|
|
1419
1479
|
let n = e.node(e.depth - 1).child(t - 1);
|
|
1420
|
-
return
|
|
1421
|
-
},
|
|
1480
|
+
return $r(n) ? { previousBlockStart: e.before(e.depth) - n.nodeSize } : null;
|
|
1481
|
+
}, ni = (e, t) => {
|
|
1422
1482
|
try {
|
|
1423
1483
|
return z.create(e, t);
|
|
1424
1484
|
} catch {
|
|
1425
1485
|
return z.near(e.resolve(t), -1);
|
|
1426
1486
|
}
|
|
1427
|
-
},
|
|
1487
|
+
}, ri = (e, t, n) => {
|
|
1428
1488
|
n.preventDefault();
|
|
1429
1489
|
let r = t.from, i = e.state.tr.delete(t.from, t.to), a = i.doc.content.size, o = Math.min(r, a);
|
|
1430
|
-
return i.setSelection(
|
|
1431
|
-
},
|
|
1490
|
+
return i.setSelection(ni(i.doc, o)).scrollIntoView(), e.dispatch(i), e.focus(), !0;
|
|
1491
|
+
}, ii = (e, t) => {
|
|
1432
1492
|
if (t.key !== "Backspace") return !1;
|
|
1433
1493
|
let { selection: n } = e.state;
|
|
1434
1494
|
if (!n.empty) return !1;
|
|
1435
|
-
let r = n.$from, i =
|
|
1495
|
+
let r = n.$from, i = ti(r);
|
|
1436
1496
|
if (!i) return !1;
|
|
1437
1497
|
let a = r.before(r.depth), o = a + r.parent.nodeSize;
|
|
1438
1498
|
t.preventDefault();
|
|
1439
1499
|
let s = e.state.tr;
|
|
1440
1500
|
return s.delete(a, o), s.setSelection(I.create(s.doc, i.previousBlockStart)).scrollIntoView(), e.dispatch(s), e.focus(), !0;
|
|
1441
|
-
},
|
|
1442
|
-
if (
|
|
1443
|
-
let n =
|
|
1501
|
+
}, ai = (e, t) => {
|
|
1502
|
+
if (ii(e, t)) return !0;
|
|
1503
|
+
let n = Xr[t.key];
|
|
1444
1504
|
if (!n) return !1;
|
|
1445
1505
|
let { selection: r } = e.state;
|
|
1446
1506
|
if (!r.empty) return !1;
|
|
1447
1507
|
let i = r.$from, a = n === "before" ? i.nodeBefore : i.nodeAfter;
|
|
1448
|
-
if (
|
|
1508
|
+
if (!$r(a)) return !1;
|
|
1449
1509
|
t.preventDefault();
|
|
1450
1510
|
let o = n === "before" ? r.from - a.nodeSize : r.from;
|
|
1451
1511
|
return e.dispatch(e.state.tr.setSelection(I.create(e.state.doc, o)).scrollIntoView()), e.focus(), !0;
|
|
1452
|
-
},
|
|
1453
|
-
if (
|
|
1512
|
+
}, oi = (e, t) => {
|
|
1513
|
+
if (ei(e, t)) return !1;
|
|
1454
1514
|
let { selection: n } = e.state;
|
|
1455
|
-
return n instanceof I &&
|
|
1456
|
-
},
|
|
1515
|
+
return n instanceof I && $r(n.node) ? ri(e, n, t) : ai(e, t);
|
|
1516
|
+
}, si = V(() => new L({
|
|
1457
1517
|
key: new R("zt-md-image-delete-selection"),
|
|
1458
|
-
props: { handleKeyDown: (e, t) =>
|
|
1459
|
-
})),
|
|
1518
|
+
props: { handleKeyDown: (e, t) => oi(e, t) }
|
|
1519
|
+
})), ci = (e) => e.state.schema.nodes.paragraph?.createAndFill() ?? null, li = (e, t) => e.state.schema.nodes.image?.create(t) ?? null, ui = (e) => {
|
|
1460
1520
|
let t = e.$to.parent;
|
|
1461
1521
|
if (e.$to.parentOffset < t.content.size) return !0;
|
|
1462
1522
|
if (e.$to.depth < 1) return !1;
|
|
1463
1523
|
let n = e.$to.node(e.$to.depth - 1);
|
|
1464
1524
|
return e.$to.index(e.$to.depth - 1) < n.childCount - 1;
|
|
1465
|
-
},
|
|
1525
|
+
}, di = (e, t) => {
|
|
1466
1526
|
let n = [
|
|
1467
1527
|
t,
|
|
1468
1528
|
t - 1,
|
|
@@ -1470,20 +1530,20 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1470
1530
|
];
|
|
1471
1531
|
for (let t of n) if (!(t < 0 || t > e.content.size) && e.nodeAt(t)?.type.name === "image") return t;
|
|
1472
1532
|
return null;
|
|
1473
|
-
},
|
|
1474
|
-
let n = e.selection.from - t, r =
|
|
1533
|
+
}, fi = (e, t) => {
|
|
1534
|
+
let n = e.selection.from - t, r = di(e.doc, n);
|
|
1475
1535
|
return r === null ? null : I.create(e.doc, r);
|
|
1476
|
-
},
|
|
1477
|
-
let r =
|
|
1536
|
+
}, pi = (e, t, n = e.state.selection) => {
|
|
1537
|
+
let r = li(e, t);
|
|
1478
1538
|
if (!r) return !1;
|
|
1479
|
-
let i =
|
|
1539
|
+
let i = ui(n), a = e.state.tr.setSelection(n).replaceSelectionWith(r), o = a.selection.to;
|
|
1480
1540
|
if (!i) {
|
|
1481
|
-
let t =
|
|
1541
|
+
let t = ci(e);
|
|
1482
1542
|
t && a.insert(o, t);
|
|
1483
1543
|
}
|
|
1484
|
-
let s =
|
|
1544
|
+
let s = fi(a, r.nodeSize);
|
|
1485
1545
|
return s ? (a.setSelection(s).scrollIntoView(), e.dispatch(a), !0) : !1;
|
|
1486
|
-
},
|
|
1546
|
+
}, mi = "zt-md-image-upload-file-input", hi = "zt-md-image-upload-alt-input", gi = (e) => new Promise((t, n) => {
|
|
1487
1547
|
let r = new FileReader();
|
|
1488
1548
|
r.onload = () => {
|
|
1489
1549
|
let e = r.result;
|
|
@@ -1495,77 +1555,77 @@ var mn = "code_block", hn = new R("MILKDOWN_PRISM"), gn = (e, t = []) => {
|
|
|
1495
1555
|
}, r.onerror = () => {
|
|
1496
1556
|
n(r.error ?? /* @__PURE__ */ Error("File read failed"));
|
|
1497
1557
|
}, r.readAsDataURL(e);
|
|
1498
|
-
}),
|
|
1558
|
+
}), _i = (e) => e < 1024 * 1024 ? `${Math.ceil(e / 1024)}KB` : `${(e / 1024 / 1024).toFixed(1)}MB`, vi = (e) => {
|
|
1499
1559
|
try {
|
|
1500
1560
|
let t = new URL(e);
|
|
1501
1561
|
return !!(t.protocol && t.host);
|
|
1502
1562
|
} catch {
|
|
1503
1563
|
return !1;
|
|
1504
1564
|
}
|
|
1505
|
-
},
|
|
1565
|
+
}, yi = (e) => new Promise((t, n) => {
|
|
1506
1566
|
let r = new Image();
|
|
1507
1567
|
r.onload = () => {
|
|
1508
1568
|
t();
|
|
1509
1569
|
}, r.onerror = () => {
|
|
1510
1570
|
n(/* @__PURE__ */ Error("Image load failed"));
|
|
1511
1571
|
}, r.src = e;
|
|
1512
|
-
}),
|
|
1572
|
+
}), bi = (e) => e.replace(/\.[^/.]+$/, ""), xi = new R("zt-md-image-paste"), Si = 0, Ci = (e) => (typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable) && !e.state.selection.$from.parent.type.spec.code, wi = (e) => Array.from(e.items).find((e) => e.kind === "file" && e.type.startsWith("image/"))?.getAsFile() || (Array.from(e.files).find((e) => e.type.startsWith("image/")) ?? null), Ti = () => (Si += 1, `image-paste-${Si}`), Ei = (e, t) => {
|
|
1513
1573
|
let n = /* @__PURE__ */ new Map();
|
|
1514
1574
|
t.forEach((t, r) => {
|
|
1515
1575
|
n.set(r, t.map(e.mapping));
|
|
1516
1576
|
});
|
|
1517
|
-
let r = e.getMeta(
|
|
1577
|
+
let r = e.getMeta(xi);
|
|
1518
1578
|
return r?.type === "add" && n.set(r.requestId, r.bookmark), r?.type === "remove" && n.delete(r.requestId), n;
|
|
1519
|
-
},
|
|
1520
|
-
e.isDestroyed || !
|
|
1579
|
+
}, Di = (e, t) => {
|
|
1580
|
+
e.isDestroyed || !xi.getState(e.state)?.has(t) || e.dispatch(e.state.tr.setMeta(xi, {
|
|
1521
1581
|
type: "remove",
|
|
1522
1582
|
requestId: t
|
|
1523
1583
|
}));
|
|
1524
|
-
},
|
|
1525
|
-
let r = t?.upload ? await t.upload(e) : await
|
|
1584
|
+
}, Oi = async (e, t, n) => {
|
|
1585
|
+
let r = t?.upload ? await t.upload(e) : await gi(e);
|
|
1526
1586
|
if (!r) throw Error(n.imageUploadFailed);
|
|
1527
1587
|
return r;
|
|
1528
|
-
},
|
|
1588
|
+
}, ki = async (e, t, n, r, i) => {
|
|
1529
1589
|
try {
|
|
1530
|
-
let a = await
|
|
1590
|
+
let a = await Oi(t, r, i);
|
|
1531
1591
|
if (e.isDestroyed) return;
|
|
1532
|
-
let o =
|
|
1592
|
+
let o = xi.getState(e.state)?.get(n);
|
|
1533
1593
|
if (!o) return;
|
|
1534
1594
|
let s = o.resolve(e.state.doc);
|
|
1535
|
-
|
|
1595
|
+
Di(e, n), pi(e, {
|
|
1536
1596
|
src: a,
|
|
1537
|
-
alt:
|
|
1597
|
+
alt: bi(t.name),
|
|
1538
1598
|
title: ""
|
|
1539
1599
|
}, s);
|
|
1540
1600
|
} catch (e) {
|
|
1541
1601
|
console.error(e);
|
|
1542
1602
|
} finally {
|
|
1543
|
-
|
|
1603
|
+
Di(e, n);
|
|
1544
1604
|
}
|
|
1545
|
-
},
|
|
1546
|
-
key:
|
|
1605
|
+
}, Ai = (e, t) => V(() => new L({
|
|
1606
|
+
key: xi,
|
|
1547
1607
|
state: {
|
|
1548
1608
|
init: () => /* @__PURE__ */ new Map(),
|
|
1549
|
-
apply:
|
|
1609
|
+
apply: Ei
|
|
1550
1610
|
},
|
|
1551
1611
|
props: { handlePaste: (n, r) => {
|
|
1552
|
-
if (!
|
|
1553
|
-
let i = r.clipboardData ?
|
|
1612
|
+
if (!Ci(n)) return !1;
|
|
1613
|
+
let i = r.clipboardData ? wi(r.clipboardData) : null;
|
|
1554
1614
|
if (!i) return !1;
|
|
1555
1615
|
r.preventDefault();
|
|
1556
1616
|
let a = e?.maxFileSize ?? 5242880;
|
|
1557
|
-
if (i.size > a) return console.error(Error(t.imageUploadFileSizeExceeded.replace("{size}",
|
|
1558
|
-
let o =
|
|
1559
|
-
return n.dispatch(n.state.tr.setMeta(
|
|
1617
|
+
if (i.size > a) return console.error(Error(t.imageUploadFileSizeExceeded.replace("{size}", _i(a)))), !0;
|
|
1618
|
+
let o = Ti(), s = n.state.selection.getBookmark();
|
|
1619
|
+
return n.dispatch(n.state.tr.setMeta(xi, {
|
|
1560
1620
|
type: "add",
|
|
1561
1621
|
requestId: o,
|
|
1562
1622
|
bookmark: s
|
|
1563
|
-
})),
|
|
1623
|
+
})), ki(n, i, o, e, t), !0;
|
|
1564
1624
|
} }
|
|
1565
1625
|
}));
|
|
1566
1626
|
//#endregion
|
|
1567
1627
|
//#region src/components/ui/dialog.tsx
|
|
1568
|
-
function
|
|
1628
|
+
function ji({ ...e }) {
|
|
1569
1629
|
return /* @__PURE__ */ P(N.Root, {
|
|
1570
1630
|
"data-slot": "dialog",
|
|
1571
1631
|
...e
|
|
@@ -1578,7 +1638,7 @@ e.forwardRef(function({ ...e }, t) {
|
|
|
1578
1638
|
...e
|
|
1579
1639
|
});
|
|
1580
1640
|
});
|
|
1581
|
-
function
|
|
1641
|
+
function Mi({ container: e, ...t }) {
|
|
1582
1642
|
return /* @__PURE__ */ P(N.Portal, {
|
|
1583
1643
|
"data-slot": "dialog-portal",
|
|
1584
1644
|
container: e ?? void 0,
|
|
@@ -1592,17 +1652,17 @@ e.forwardRef(function({ ...e }, t) {
|
|
|
1592
1652
|
...e
|
|
1593
1653
|
});
|
|
1594
1654
|
});
|
|
1595
|
-
var
|
|
1655
|
+
var Ni = e.forwardRef(function({ className: e, ...t }, n) {
|
|
1596
1656
|
return /* @__PURE__ */ P(N.Overlay, {
|
|
1597
1657
|
ref: n,
|
|
1598
1658
|
"data-slot": "dialog-overlay",
|
|
1599
1659
|
className: H("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", e),
|
|
1600
1660
|
...t
|
|
1601
1661
|
});
|
|
1602
|
-
}),
|
|
1603
|
-
return /* @__PURE__ */ F(
|
|
1662
|
+
}), Pi = e.forwardRef(function({ container: e, className: t, children: n, showCloseButton: r = !0, closeLabel: i = "Close", ...a }, o) {
|
|
1663
|
+
return /* @__PURE__ */ F(Mi, {
|
|
1604
1664
|
container: e,
|
|
1605
|
-
children: [/* @__PURE__ */ P(
|
|
1665
|
+
children: [/* @__PURE__ */ P(Ni, {}), /* @__PURE__ */ F(N.Content, {
|
|
1606
1666
|
ref: o,
|
|
1607
1667
|
"data-slot": "dialog-content",
|
|
1608
1668
|
className: H("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", t),
|
|
@@ -1623,14 +1683,14 @@ var ji = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1623
1683
|
})]
|
|
1624
1684
|
});
|
|
1625
1685
|
});
|
|
1626
|
-
function
|
|
1686
|
+
function Fi({ className: e, ...t }) {
|
|
1627
1687
|
return /* @__PURE__ */ P("div", {
|
|
1628
1688
|
"data-slot": "dialog-header",
|
|
1629
1689
|
className: H("flex flex-col gap-2", e),
|
|
1630
1690
|
...t
|
|
1631
1691
|
});
|
|
1632
1692
|
}
|
|
1633
|
-
function
|
|
1693
|
+
function Ii({ className: e, showCloseButton: t = !1, children: n, ...r }) {
|
|
1634
1694
|
return /* @__PURE__ */ F("div", {
|
|
1635
1695
|
"data-slot": "dialog-footer",
|
|
1636
1696
|
className: H("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end", e),
|
|
@@ -1644,22 +1704,22 @@ function Pi({ className: e, showCloseButton: t = !1, children: n, ...r }) {
|
|
|
1644
1704
|
})]
|
|
1645
1705
|
});
|
|
1646
1706
|
}
|
|
1647
|
-
var
|
|
1707
|
+
var Li = e.forwardRef(function({ className: e, ...t }, n) {
|
|
1648
1708
|
return /* @__PURE__ */ P(N.Title, {
|
|
1649
1709
|
ref: n,
|
|
1650
1710
|
"data-slot": "dialog-title",
|
|
1651
1711
|
className: H("text-base leading-none font-medium", e),
|
|
1652
1712
|
...t
|
|
1653
1713
|
});
|
|
1654
|
-
}),
|
|
1714
|
+
}), Ri = e.forwardRef(function({ className: e, ...t }, n) {
|
|
1655
1715
|
return /* @__PURE__ */ P(N.Description, {
|
|
1656
1716
|
ref: n,
|
|
1657
1717
|
"data-slot": "dialog-description",
|
|
1658
1718
|
className: H("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground", e),
|
|
1659
1719
|
...t
|
|
1660
1720
|
});
|
|
1661
|
-
}),
|
|
1662
|
-
let [l, u] = c("file"), [d, f] = c(""), [p, m] = c(""), [g, _] = c(!1), [v, y] = c(null), [b, x] = c(!1), [S, C] = c(!1), [w, T] = c(!1), E = s(null), D = s(null), O = s(!0), k = n?.maxFileSize ?? 5242880, A = b || S, ee = l === "file" && !!d && !A, re = (v ? "key" in v ? e[v.key].replace("{size}",
|
|
1721
|
+
}), zi = ({ messages: e, portalContainer: t, imageUpload: n, onConfirm: a, onCancel: o }) => {
|
|
1722
|
+
let [l, u] = c("file"), [d, f] = c(""), [p, m] = c(""), [g, _] = c(!1), [v, y] = c(null), [b, x] = c(!1), [S, C] = c(!1), [w, T] = c(!1), E = s(null), D = s(null), O = s(!0), k = n?.maxFileSize ?? 5242880, A = b || S, ee = l === "file" && !!d && !A, re = (v ? "key" in v ? e[v.key].replace("{size}", _i(k)) : v.text : "") || (ee ? e.imageUploadReselectHint : ""), j = !!v, M = !!re, ie = !!d && !v && !b && !g, oe = !d || !!v || A || g, se = r(async (e) => {
|
|
1663
1723
|
if (!e.type.startsWith("image/")) {
|
|
1664
1724
|
f(""), m(""), y({ key: "imageUploadInvalidType" });
|
|
1665
1725
|
return;
|
|
@@ -1668,9 +1728,9 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1668
1728
|
f(""), m(""), y({ key: "imageUploadFileSizeExceeded" });
|
|
1669
1729
|
return;
|
|
1670
1730
|
}
|
|
1671
|
-
y(null), m(
|
|
1731
|
+
y(null), m(bi(e.name)), _(!1), x(!0);
|
|
1672
1732
|
try {
|
|
1673
|
-
let t = n?.upload ? await n.upload(e) : await
|
|
1733
|
+
let t = n?.upload ? await n.upload(e) : await gi(e);
|
|
1674
1734
|
if (!O.current) return;
|
|
1675
1735
|
if (!t) {
|
|
1676
1736
|
f(""), y({ key: "imageUploadFailed" });
|
|
@@ -1692,7 +1752,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1692
1752
|
y(null);
|
|
1693
1753
|
return;
|
|
1694
1754
|
}
|
|
1695
|
-
y(
|
|
1755
|
+
y(vi(e) ? null : { key: "imageUploadInvalidUrl" });
|
|
1696
1756
|
}, []), ue = r((e) => {
|
|
1697
1757
|
e.preventDefault(), e.stopPropagation(), !A && (e.dataTransfer.dropEffect = "copy", T(!0));
|
|
1698
1758
|
}, [A]), de = r((e) => {
|
|
@@ -1712,13 +1772,13 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1712
1772
|
y({ key: "imageUploadSelectOrEnterImage" });
|
|
1713
1773
|
return;
|
|
1714
1774
|
}
|
|
1715
|
-
if (l === "url" && !
|
|
1775
|
+
if (l === "url" && !vi(d)) {
|
|
1716
1776
|
y({ key: "imageUploadInvalidUrl" });
|
|
1717
1777
|
return;
|
|
1718
1778
|
}
|
|
1719
1779
|
y(null), C(!0);
|
|
1720
1780
|
try {
|
|
1721
|
-
if (await
|
|
1781
|
+
if (await yi(d), !O.current) return;
|
|
1722
1782
|
a({
|
|
1723
1783
|
src: d,
|
|
1724
1784
|
alt: p.trim()
|
|
@@ -1741,10 +1801,10 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1741
1801
|
O.current = !1;
|
|
1742
1802
|
}), []), i(() => {
|
|
1743
1803
|
l === "url" && D.current?.focus();
|
|
1744
|
-
}, [l]), /* @__PURE__ */ P(
|
|
1804
|
+
}, [l]), /* @__PURE__ */ P(ji, {
|
|
1745
1805
|
open: !0,
|
|
1746
1806
|
onOpenChange: (e) => !e && o(),
|
|
1747
|
-
children: /* @__PURE__ */ F(
|
|
1807
|
+
children: /* @__PURE__ */ F(Pi, {
|
|
1748
1808
|
container: t,
|
|
1749
1809
|
className: "zt-md-image-upload-content-shell max-w-2xl sm:!max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",
|
|
1750
1810
|
closeLabel: e.imageUploadCancelLabel,
|
|
@@ -1752,7 +1812,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1752
1812
|
onMouseDown: (e) => e.stopPropagation(),
|
|
1753
1813
|
onKeyDown: me,
|
|
1754
1814
|
children: [
|
|
1755
|
-
/* @__PURE__ */ F(
|
|
1815
|
+
/* @__PURE__ */ F(Fi, { children: [/* @__PURE__ */ P(Li, { children: e.imageUploadDialogTitle }), /* @__PURE__ */ P(Ri, {
|
|
1756
1816
|
className: "sr-only",
|
|
1757
1817
|
children: `${e.imageUploadFileTab},${e.imageUploadUrlTab}`
|
|
1758
1818
|
})] }),
|
|
@@ -1789,14 +1849,14 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1789
1849
|
className: "zt-md-image-upload-file",
|
|
1790
1850
|
children: [/* @__PURE__ */ P("input", {
|
|
1791
1851
|
ref: E,
|
|
1792
|
-
id:
|
|
1852
|
+
id: mi,
|
|
1793
1853
|
type: "file",
|
|
1794
1854
|
accept: "image/*",
|
|
1795
1855
|
className: "zt-md-image-upload-file-input",
|
|
1796
1856
|
disabled: A,
|
|
1797
1857
|
onChange: ce
|
|
1798
1858
|
}), /* @__PURE__ */ P("label", {
|
|
1799
|
-
htmlFor:
|
|
1859
|
+
htmlFor: mi,
|
|
1800
1860
|
className: "zt-md-image-upload-file-label",
|
|
1801
1861
|
"data-drag-over": w ? "true" : "false",
|
|
1802
1862
|
"data-has-preview": d ? "true" : "false",
|
|
@@ -1839,7 +1899,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1839
1899
|
}),
|
|
1840
1900
|
/* @__PURE__ */ P("div", {
|
|
1841
1901
|
className: "zt-md-image-upload-file-hint",
|
|
1842
|
-
children: e.imageUploadSupportsAndMax.replace("{size}",
|
|
1902
|
+
children: e.imageUploadSupportsAndMax.replace("{size}", _i(k))
|
|
1843
1903
|
})
|
|
1844
1904
|
] })
|
|
1845
1905
|
})]
|
|
@@ -1879,10 +1939,10 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1879
1939
|
className: "zt-md-image-upload-alt",
|
|
1880
1940
|
children: [/* @__PURE__ */ P("label", {
|
|
1881
1941
|
className: "zt-md-image-upload-label",
|
|
1882
|
-
htmlFor:
|
|
1942
|
+
htmlFor: hi,
|
|
1883
1943
|
children: e.imageUploadAltLabel
|
|
1884
1944
|
}), /* @__PURE__ */ P("input", {
|
|
1885
|
-
id:
|
|
1945
|
+
id: hi,
|
|
1886
1946
|
type: "text",
|
|
1887
1947
|
className: "zt-md-image-upload-alt-input",
|
|
1888
1948
|
placeholder: e.imageUploadAltPlaceholder,
|
|
@@ -1909,7 +1969,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1909
1969
|
]
|
|
1910
1970
|
})
|
|
1911
1971
|
}),
|
|
1912
|
-
/* @__PURE__ */ F(
|
|
1972
|
+
/* @__PURE__ */ F(Ii, { children: [/* @__PURE__ */ P(U, {
|
|
1913
1973
|
type: "button",
|
|
1914
1974
|
variant: "outline",
|
|
1915
1975
|
onClick: o,
|
|
@@ -1925,7 +1985,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1925
1985
|
]
|
|
1926
1986
|
})
|
|
1927
1987
|
});
|
|
1928
|
-
},
|
|
1988
|
+
}, Bi = [
|
|
1929
1989
|
"--zt-font",
|
|
1930
1990
|
"--zt-font-mono",
|
|
1931
1991
|
"--zt-bg",
|
|
@@ -1951,18 +2011,18 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1951
2011
|
"--zt-shadow-lg",
|
|
1952
2012
|
"--zt-radius",
|
|
1953
2013
|
"--zt-radius-lg"
|
|
1954
|
-
],
|
|
2014
|
+
], Vi = (e, t) => {
|
|
1955
2015
|
if (!t) return;
|
|
1956
2016
|
let n = window.getComputedStyle(t);
|
|
1957
|
-
|
|
2017
|
+
Bi.forEach((t) => {
|
|
1958
2018
|
let r = n.getPropertyValue(t);
|
|
1959
2019
|
r && e.style.setProperty(t, r.trim());
|
|
1960
2020
|
});
|
|
1961
|
-
},
|
|
2021
|
+
}, Hi = (e, t) => {
|
|
1962
2022
|
let n = e.closest(".zt-md"), r = n?.classList.contains("zt-md-dark") ? "zt-md-dark" : "zt-md-light", i = document.createElement("div");
|
|
1963
|
-
return i.className = `zt-md zt-md-dialog-host ${t} ${r}`,
|
|
1964
|
-
},
|
|
1965
|
-
let t =
|
|
2023
|
+
return i.className = `zt-md zt-md-dialog-host ${t} ${r}`, Vi(i, n), document.body.appendChild(i), i;
|
|
2024
|
+
}, Ui = (e) => {
|
|
2025
|
+
let t = Hi(e.portalContainer, "zt-md-image-upload-host"), r = yt(t), i = (e) => {
|
|
1966
2026
|
s(), queueMicrotask(() => {
|
|
1967
2027
|
r.unmount(), t.remove(), e?.();
|
|
1968
2028
|
});
|
|
@@ -1971,12 +2031,12 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1971
2031
|
e.view?.focus?.();
|
|
1972
2032
|
});
|
|
1973
2033
|
}, o = () => {
|
|
1974
|
-
r.render(n(
|
|
2034
|
+
r.render(n(zi, {
|
|
1975
2035
|
messages: { ...e.messages },
|
|
1976
2036
|
portalContainer: t,
|
|
1977
2037
|
imageUpload: e.imageUpload,
|
|
1978
2038
|
onConfirm: (t) => {
|
|
1979
|
-
let n =
|
|
2039
|
+
let n = pi(e.view, {
|
|
1980
2040
|
src: t.src,
|
|
1981
2041
|
alt: t.alt,
|
|
1982
2042
|
title: ""
|
|
@@ -1989,39 +2049,39 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
1989
2049
|
}));
|
|
1990
2050
|
}, s = G(e.messages, o);
|
|
1991
2051
|
o();
|
|
1992
|
-
},
|
|
2052
|
+
}, Wi = "math_block", Gi = "Backspace", Ki = (e) => e.key !== Gi || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey, qi = (e) => {
|
|
1993
2053
|
if (e.parent.type.name !== "paragraph" || e.parentOffset !== 0 || e.depth < 1) return null;
|
|
1994
2054
|
let t = e.index(e.depth - 1);
|
|
1995
2055
|
if (t <= 0) return null;
|
|
1996
2056
|
let n = e.node(e.depth - 1).child(t - 1);
|
|
1997
|
-
return n.type.name ===
|
|
2057
|
+
return n.type.name === Wi ? {
|
|
1998
2058
|
previousBlock: n,
|
|
1999
2059
|
previousBlockStart: e.before(e.depth) - n.nodeSize
|
|
2000
2060
|
} : null;
|
|
2001
|
-
},
|
|
2061
|
+
}, Ji = (e, t) => {
|
|
2002
2062
|
let { selection: n } = e.state;
|
|
2003
2063
|
if (!n.empty) return !1;
|
|
2004
|
-
let r = n.$from, i =
|
|
2064
|
+
let r = n.$from, i = qi(r);
|
|
2005
2065
|
if (!i) return !1;
|
|
2006
2066
|
let a = r.parent.textContent.length === 0, o = r.before(r.depth), s = o + r.parent.nodeSize;
|
|
2007
2067
|
t.preventDefault();
|
|
2008
2068
|
let c = e.state.tr;
|
|
2009
2069
|
return a && c.delete(o, s), c.setSelection(I.create(c.doc, i.previousBlockStart)).scrollIntoView(), e.dispatch(c), !0;
|
|
2010
|
-
},
|
|
2070
|
+
}, Yi = V(() => new L({
|
|
2011
2071
|
key: new R("zt-md-math-backspace-entry"),
|
|
2012
|
-
props: { handleKeyDown: (e, t) =>
|
|
2013
|
-
})),
|
|
2072
|
+
props: { handleKeyDown: (e, t) => Ki(t) ? !1 : Ji(e, t) }
|
|
2073
|
+
})), Xi = "math_block", Zi = 5, Qi = 1200, $i = q("Copy", {
|
|
2014
2074
|
size: 14,
|
|
2015
2075
|
strokeWidth: 2
|
|
2016
|
-
}),
|
|
2076
|
+
}), ea = q("Check", {
|
|
2017
2077
|
size: 14,
|
|
2018
2078
|
strokeWidth: 2
|
|
2019
|
-
}),
|
|
2079
|
+
}), ta = q("Trash2", {
|
|
2020
2080
|
size: 14,
|
|
2021
2081
|
strokeWidth: 2
|
|
2022
|
-
}),
|
|
2082
|
+
}), na = (e) => typeof e == "function" ? e() : null, ra = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, ia = class {
|
|
2023
2083
|
syncEditableState() {
|
|
2024
|
-
this.dom.dataset.editable =
|
|
2084
|
+
this.dom.dataset.editable = ra(this.view) ? "true" : "false";
|
|
2025
2085
|
}
|
|
2026
2086
|
constructor(e, t, n, r) {
|
|
2027
2087
|
this.pointerStartX = null, this.pointerStartY = null, this.hasDragged = !1, this.isDeletingByBackspace = !1, this.copyFeedbackTimer = null, this.handleClick = () => {
|
|
@@ -2035,21 +2095,21 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2035
2095
|
}, this.handlePointerMove = (e) => {
|
|
2036
2096
|
if (this.pointerStartX === null || this.pointerStartY === null) return;
|
|
2037
2097
|
let t = Math.abs(e.clientX - this.pointerStartX), n = Math.abs(e.clientY - this.pointerStartY);
|
|
2038
|
-
(t >=
|
|
2098
|
+
(t >= Zi || n >= Zi) && (this.hasDragged = !0);
|
|
2039
2099
|
}, this.handlePointerUp = () => {
|
|
2040
2100
|
this.pointerStartX = null, this.pointerStartY = null;
|
|
2041
2101
|
}, this.handleCopyClick = (e) => {
|
|
2042
|
-
if (e.preventDefault(), e.stopPropagation(), !
|
|
2102
|
+
if (e.preventDefault(), e.stopPropagation(), !ra(this.view)) return;
|
|
2043
2103
|
let t = typeof this.node.attrs.value == "string" ? this.node.attrs.value : "";
|
|
2044
2104
|
(typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(t) : Promise.resolve()).then(() => {
|
|
2045
|
-
this.copyButton.innerHTML =
|
|
2046
|
-
this.copyButton.innerHTML =
|
|
2047
|
-
},
|
|
2105
|
+
this.copyButton.innerHTML = ea, this.copyButton.dataset.copied = "true", this.copyFeedbackTimer !== null && clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = setTimeout(() => {
|
|
2106
|
+
this.copyButton.innerHTML = $i, delete this.copyButton.dataset.copied, this.copyFeedbackTimer = null;
|
|
2107
|
+
}, Qi);
|
|
2048
2108
|
}).catch(() => {});
|
|
2049
2109
|
}, this.handleDeleteClick = (e) => {
|
|
2050
|
-
e.preventDefault(), e.stopPropagation(),
|
|
2110
|
+
e.preventDefault(), e.stopPropagation(), ra(this.view) && this.deleteCurrentMathBlock();
|
|
2051
2111
|
}, this.handleInput = () => {
|
|
2052
|
-
let e = this.sourceTextarea.value, t =
|
|
2112
|
+
let e = this.sourceTextarea.value, t = na(this.getPos);
|
|
2053
2113
|
if (t === null) return;
|
|
2054
2114
|
this.renderMath(e);
|
|
2055
2115
|
let n = this.view.state.tr.setNodeMarkup(t, void 0, {
|
|
@@ -2060,23 +2120,23 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2060
2120
|
}, this.handleKeyDown = (e) => {
|
|
2061
2121
|
let t = this.sourceTextarea.selectionStart, n = this.sourceTextarea.selectionEnd;
|
|
2062
2122
|
if (e.key === "Backspace") {
|
|
2063
|
-
if (!(t === 0 && n === 0) ||
|
|
2123
|
+
if (!(t === 0 && n === 0) || na(this.getPos) === null) return;
|
|
2064
2124
|
e.preventDefault(), this.deleteCurrentMathBlock();
|
|
2065
2125
|
return;
|
|
2066
2126
|
}
|
|
2067
2127
|
if (e.key !== "ArrowUp" && e.key !== "ArrowDown" || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || t !== n) return;
|
|
2068
2128
|
let r = this.sourceTextarea.value, i = r.slice(0, t), a = r.slice(n), o = !i.includes("\n"), s = !a.includes("\n");
|
|
2069
2129
|
if (!(e.key === "ArrowUp" && o || e.key === "ArrowDown" && s)) return;
|
|
2070
|
-
let c =
|
|
2071
|
-
c !== null &&
|
|
2130
|
+
let c = na(this.getPos);
|
|
2131
|
+
c !== null && fr(this.view, c, this.node, e.key) && e.preventDefault();
|
|
2072
2132
|
}, this.handleBlur = () => {
|
|
2073
2133
|
this.isDeletingByBackspace || this.exitEditMode();
|
|
2074
|
-
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("div"), this.dom.dataset.type =
|
|
2134
|
+
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("div"), this.dom.dataset.type = Xi, this.dom.className = "zt-md-math-block", this.syncEditableState(), this.sourceContainer = document.createElement("div"), this.sourceContainer.className = "zt-md-math-block-source", this.sourceContainer.hidden = !0, this.sourceTextarea = document.createElement("textarea"), this.sourceTextarea.className = "zt-md-math-block-textarea", this.sourceTextarea.setAttribute("aria-label", this.messages.mathBlockSourceAriaLabel), this.sourceTextarea.spellcheck = !1, this.previewContainer = document.createElement("div"), this.previewContainer.className = "zt-md-math-block-preview", this.actionsContainer = document.createElement("div"), this.actionsContainer.className = "zt-md-math-block-actions", this.copyButton = document.createElement("button"), this.copyButton.type = "button", this.copyButton.className = "zt-md-math-block-action-button", this.copyButton.setAttribute("aria-label", this.messages.mathBlockCopyAriaLabel), this.copyButton.innerHTML = $i, this.deleteButton = document.createElement("button"), this.deleteButton.type = "button", this.deleteButton.className = "zt-md-math-block-action-button zt-md-math-block-action-button-danger", this.deleteButton.setAttribute("aria-label", this.messages.mathBlockDeleteAriaLabel), this.deleteButton.innerHTML = ta, this.errorContainer = document.createElement("div"), this.errorContainer.className = "zt-md-math-block-error", this.errorContainer.hidden = !0, this.actionsContainer.append(this.copyButton, this.deleteButton), this.sourceContainer.appendChild(this.sourceTextarea), this.previewContainer.appendChild(this.errorContainer), this.dom.append(this.actionsContainer, this.sourceContainer, this.previewContainer), this.syncFromNode(e), this.dom.addEventListener("click", this.handleClick), this.dom.addEventListener("pointerdown", this.handlePointerDown), this.dom.addEventListener("pointermove", this.handlePointerMove), this.dom.addEventListener("pointerup", this.handlePointerUp), this.dom.addEventListener("pointercancel", this.handlePointerUp), this.copyButton.addEventListener("click", this.handleCopyClick), this.deleteButton.addEventListener("click", this.handleDeleteClick), this.sourceTextarea.addEventListener("input", this.handleInput), this.sourceTextarea.addEventListener("keydown", this.handleKeyDown), this.sourceTextarea.addEventListener("blur", this.handleBlur), this.stopObservingMessages = G(r, () => {
|
|
2075
2135
|
this.sourceTextarea.setAttribute("aria-label", r.mathBlockSourceAriaLabel), this.copyButton.setAttribute("aria-label", r.mathBlockCopyAriaLabel), this.deleteButton.setAttribute("aria-label", r.mathBlockDeleteAriaLabel), this.errorContainer.hidden || (this.errorContainer.textContent = r.mathRenderError);
|
|
2076
2136
|
});
|
|
2077
2137
|
}
|
|
2078
2138
|
deleteCurrentMathBlock() {
|
|
2079
|
-
let e =
|
|
2139
|
+
let e = na(this.getPos);
|
|
2080
2140
|
if (e === null) return;
|
|
2081
2141
|
this.isDeletingByBackspace = !0;
|
|
2082
2142
|
let t = this.view.state.tr.delete(e, e + this.node.nodeSize), n = Math.min(e, t.doc.content.size);
|
|
@@ -2100,13 +2160,13 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2100
2160
|
}
|
|
2101
2161
|
}
|
|
2102
2162
|
enterEditMode() {
|
|
2103
|
-
|
|
2163
|
+
ra(this.view) && (this.sourceContainer.hidden = !1, this.dom.classList.add("zt-md-math-block-editing"), this.sourceTextarea.focus());
|
|
2104
2164
|
}
|
|
2105
2165
|
exitEditMode() {
|
|
2106
2166
|
this.sourceContainer.hidden = !0, this.dom.classList.remove("zt-md-math-block-editing");
|
|
2107
2167
|
}
|
|
2108
2168
|
update(e) {
|
|
2109
|
-
return e.type.name ===
|
|
2169
|
+
return e.type.name === Xi ? (this.node = e, this.syncEditableState(), this.syncFromNode(e), !0) : !1;
|
|
2110
2170
|
}
|
|
2111
2171
|
selectNode() {
|
|
2112
2172
|
this.enterEditMode();
|
|
@@ -2122,18 +2182,18 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2122
2182
|
return !0;
|
|
2123
2183
|
}
|
|
2124
2184
|
destroy() {
|
|
2125
|
-
this.stopObservingMessages(), this.dom.removeEventListener("click", this.handleClick), this.dom.removeEventListener("pointerdown", this.handlePointerDown), this.dom.removeEventListener("pointermove", this.handlePointerMove), this.dom.removeEventListener("pointerup", this.handlePointerUp), this.dom.removeEventListener("pointercancel", this.handlePointerUp), this.copyButton.removeEventListener("click", this.handleCopyClick), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.sourceTextarea.removeEventListener("input", this.handleInput), this.sourceTextarea.removeEventListener("keydown", this.handleKeyDown), this.sourceTextarea.removeEventListener("blur", this.handleBlur), this.copyFeedbackTimer !== null && (clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = null), this.copyButton.innerHTML =
|
|
2185
|
+
this.stopObservingMessages(), this.dom.removeEventListener("click", this.handleClick), this.dom.removeEventListener("pointerdown", this.handlePointerDown), this.dom.removeEventListener("pointermove", this.handlePointerMove), this.dom.removeEventListener("pointerup", this.handlePointerUp), this.dom.removeEventListener("pointercancel", this.handlePointerUp), this.copyButton.removeEventListener("click", this.handleCopyClick), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.sourceTextarea.removeEventListener("input", this.handleInput), this.sourceTextarea.removeEventListener("keydown", this.handleKeyDown), this.sourceTextarea.removeEventListener("blur", this.handleBlur), this.copyFeedbackTimer !== null && (clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = null), this.copyButton.innerHTML = $i, delete this.copyButton.dataset.copied;
|
|
2126
2186
|
}
|
|
2127
|
-
},
|
|
2187
|
+
}, aa = (e = W()) => (t, n, r) => new ia(t, n, typeof r == "function" ? () => {
|
|
2128
2188
|
let e = r();
|
|
2129
2189
|
return typeof e == "number" ? e : 0;
|
|
2130
|
-
} : !1, e),
|
|
2131
|
-
|
|
2190
|
+
} : !1, e), oa = "math_inline", J = new R("zt-md-math-inline-edit"), sa = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, ca = (e) => e?.type.name === oa, la = (e) => String(e.attrs.value ?? e.textContent ?? ""), ua = (e, t, n) => {
|
|
2191
|
+
sa(e) && e.dispatch(e.state.tr.setMeta(J, {
|
|
2132
2192
|
type: "open",
|
|
2133
2193
|
position: t,
|
|
2134
2194
|
caret: n?.caret === "start" ? "start" : "end"
|
|
2135
2195
|
}));
|
|
2136
|
-
},
|
|
2196
|
+
}, da = class {
|
|
2137
2197
|
createSafeTextSelection(e, t) {
|
|
2138
2198
|
try {
|
|
2139
2199
|
return z.create(e, t);
|
|
@@ -2212,19 +2272,19 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2212
2272
|
resolveCurrentNode() {
|
|
2213
2273
|
if (this.currentPosition === null) return null;
|
|
2214
2274
|
let e = this.view.state.doc.nodeAt(this.currentPosition);
|
|
2215
|
-
return
|
|
2275
|
+
return ca(e) ? e : null;
|
|
2216
2276
|
}
|
|
2217
2277
|
openEditor(e) {
|
|
2218
|
-
if (!
|
|
2278
|
+
if (!sa(this.view)) {
|
|
2219
2279
|
this.closeEditor(!1);
|
|
2220
2280
|
return;
|
|
2221
2281
|
}
|
|
2222
2282
|
let t = this.view.state.doc.nodeAt(e);
|
|
2223
|
-
if (!
|
|
2283
|
+
if (!ca(t)) {
|
|
2224
2284
|
this.closeEditor(!1);
|
|
2225
2285
|
return;
|
|
2226
2286
|
}
|
|
2227
|
-
this.currentPosition = e, this.sourceInput.value =
|
|
2287
|
+
this.currentPosition = e, this.sourceInput.value = la(t), this.renderMath(this.sourceInput.value);
|
|
2228
2288
|
let n = this.resolveMathInlineElement(e);
|
|
2229
2289
|
if (!n) {
|
|
2230
2290
|
this.closeEditor(!1);
|
|
@@ -2262,7 +2322,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2262
2322
|
return t instanceof HTMLElement ? t : null;
|
|
2263
2323
|
}
|
|
2264
2324
|
update(e) {
|
|
2265
|
-
if (this.view = e, !
|
|
2325
|
+
if (this.view = e, !sa(e)) {
|
|
2266
2326
|
this.closeEditor(!1);
|
|
2267
2327
|
return;
|
|
2268
2328
|
}
|
|
@@ -2283,7 +2343,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2283
2343
|
destroy() {
|
|
2284
2344
|
this.stopObservingMessages(), this.sourceInput.removeEventListener("input", this.handleInput), this.sourceInput.removeEventListener("beforeinput", this.handleBeforeInput), this.sourceInput.removeEventListener("keydown", this.handleKeyDown), this.sourceInput.removeEventListener("blur", this.handleBlur), this.host.removeEventListener("mousedown", this.handleMouseDown), this.view.dom.removeEventListener("focusin", this.handleEditorFocusIn), this.closeEditor(!1);
|
|
2285
2345
|
}
|
|
2286
|
-
},
|
|
2346
|
+
}, fa = (e, t) => V(() => new L({
|
|
2287
2347
|
key: J,
|
|
2288
2348
|
state: {
|
|
2289
2349
|
init: () => ({
|
|
@@ -2302,7 +2362,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2302
2362
|
};
|
|
2303
2363
|
if (t.position === null || !e.docChanged) return t;
|
|
2304
2364
|
let r = e.mapping.map(t.position, -1);
|
|
2305
|
-
return
|
|
2365
|
+
return ca(e.doc.nodeAt(r)) ? {
|
|
2306
2366
|
position: r,
|
|
2307
2367
|
caret: t.caret
|
|
2308
2368
|
} : {
|
|
@@ -2311,24 +2371,24 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2311
2371
|
};
|
|
2312
2372
|
}
|
|
2313
2373
|
},
|
|
2314
|
-
view: (t) => new
|
|
2315
|
-
})),
|
|
2374
|
+
view: (t) => new da(t, e)
|
|
2375
|
+
})), pa = "math_inline", ma = (e) => typeof e == "function" ? e() : null, ha = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, ga = (e) => String(e.attrs.value ?? e.textContent ?? ""), _a = class {
|
|
2316
2376
|
syncEditableState() {
|
|
2317
|
-
this.dom.dataset.editable =
|
|
2377
|
+
this.dom.dataset.editable = ha(this.view) ? "true" : "false";
|
|
2318
2378
|
}
|
|
2319
2379
|
constructor(e, t, n, r) {
|
|
2320
2380
|
this.handleMouseDown = (e) => {
|
|
2321
|
-
|
|
2381
|
+
ha(this.view) || (e.preventDefault(), e.stopPropagation());
|
|
2322
2382
|
}, this.handleClick = (e) => {
|
|
2323
|
-
if (e.preventDefault(), e.stopPropagation(), !
|
|
2324
|
-
let t =
|
|
2325
|
-
t !== null &&
|
|
2326
|
-
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("span"), this.dom.dataset.type =
|
|
2383
|
+
if (e.preventDefault(), e.stopPropagation(), !ha(this.view)) return;
|
|
2384
|
+
let t = ma(this.getPos);
|
|
2385
|
+
t !== null && ua(this.view, t);
|
|
2386
|
+
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("span"), this.dom.dataset.type = pa, this.dom.className = "zt-md-math-inline", this.dom.dataset.editing = "false", this.syncEditableState(), this.previewContainer = document.createElement("span"), this.previewContainer.className = "zt-md-math-inline-preview", this.errorContainer = document.createElement("span"), this.errorContainer.className = "zt-md-math-inline-error", this.errorContainer.hidden = !0, this.dom.append(this.previewContainer, this.errorContainer), this.syncFromNode(e), this.dom.addEventListener("mousedown", this.handleMouseDown), this.dom.addEventListener("click", this.handleClick), this.stopObservingMessages = G(r, () => {
|
|
2327
2387
|
this.errorContainer.hidden || (this.errorContainer.textContent = r.mathRenderError);
|
|
2328
2388
|
});
|
|
2329
2389
|
}
|
|
2330
2390
|
syncFromNode(e) {
|
|
2331
|
-
let t =
|
|
2391
|
+
let t = ga(e);
|
|
2332
2392
|
this.dom.dataset.value = t, this.renderMath(t);
|
|
2333
2393
|
}
|
|
2334
2394
|
renderMath(e) {
|
|
@@ -2343,7 +2403,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2343
2403
|
}
|
|
2344
2404
|
}
|
|
2345
2405
|
update(e) {
|
|
2346
|
-
return e.type.name ===
|
|
2406
|
+
return e.type.name === pa ? (this.node = e, this.syncEditableState(), this.syncFromNode(e), !0) : !1;
|
|
2347
2407
|
}
|
|
2348
2408
|
stopEvent(e) {
|
|
2349
2409
|
let t = e.target;
|
|
@@ -2355,72 +2415,72 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2355
2415
|
destroy() {
|
|
2356
2416
|
this.stopObservingMessages(), this.dom.removeEventListener("mousedown", this.handleMouseDown), this.dom.removeEventListener("click", this.handleClick);
|
|
2357
2417
|
}
|
|
2358
|
-
},
|
|
2418
|
+
}, va = (e = W()) => (t, n, r) => new _a(t, n, typeof r == "function" ? () => {
|
|
2359
2419
|
let e = r();
|
|
2360
2420
|
return typeof e == "number" ? e : 0;
|
|
2361
|
-
} : !1, e),
|
|
2421
|
+
} : !1, e), ya = "math_inline", ba = "zt-md-math-inline-arrow-navigation", xa = {
|
|
2362
2422
|
ArrowLeft: { positionKey: "from" },
|
|
2363
2423
|
ArrowRight: { positionKey: "to" }
|
|
2364
|
-
},
|
|
2424
|
+
}, Sa = {
|
|
2365
2425
|
ArrowLeft: "end",
|
|
2366
2426
|
ArrowRight: "start"
|
|
2367
|
-
},
|
|
2427
|
+
}, Ca = {
|
|
2368
2428
|
Backspace: "before",
|
|
2369
2429
|
Delete: "after"
|
|
2370
|
-
},
|
|
2371
|
-
if (!
|
|
2430
|
+
}, wa = (e) => e instanceof Element ? !!e.closest(".zt-md-math-inline-editor") : !1, Ta = (e) => e?.type.name === ya, Ea = (e) => !Ca[e.key] || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || wa(e.target) || wa(document.activeElement), Da = (e, t) => {
|
|
2431
|
+
if (!xa[t.key] || wa(t.target)) return !1;
|
|
2372
2432
|
let { selection: n } = e.state;
|
|
2373
|
-
return !(n instanceof I) || n.node.type.name !==
|
|
2374
|
-
},
|
|
2375
|
-
let n =
|
|
2376
|
-
if (!n ||
|
|
2433
|
+
return !(n instanceof I) || n.node.type.name !== ya ? !1 : (t.preventDefault(), ua(e, n.from, { caret: Sa[t.key] ?? "end" }), !0);
|
|
2434
|
+
}, Oa = (e, t) => {
|
|
2435
|
+
let n = xa[t.key];
|
|
2436
|
+
if (!n || wa(t.target)) return !1;
|
|
2377
2437
|
let { selection: r } = e.state;
|
|
2378
2438
|
if (!r.empty) return !1;
|
|
2379
2439
|
let i = r.$from, a = n.positionKey === "from" ? i.nodeBefore : i.nodeAfter;
|
|
2380
|
-
return
|
|
2381
|
-
},
|
|
2440
|
+
return Ta(a) ? (t.preventDefault(), ua(e, n.positionKey === "from" ? r.from - a.nodeSize : r.from, { caret: Sa[t.key] ?? "end" }), !0) : !1;
|
|
2441
|
+
}, ka = (e, t) => {
|
|
2382
2442
|
try {
|
|
2383
2443
|
return z.create(e, t);
|
|
2384
2444
|
} catch {
|
|
2385
2445
|
return z.near(e.resolve(t), -1);
|
|
2386
2446
|
}
|
|
2387
|
-
},
|
|
2447
|
+
}, Aa = (e, t, n) => {
|
|
2388
2448
|
n.preventDefault();
|
|
2389
2449
|
let r = t.from, i = e.state.tr.delete(t.from, t.to), a = i.doc.content.size, o = Math.min(r, a);
|
|
2390
|
-
return i.setSelection(
|
|
2391
|
-
},
|
|
2392
|
-
let n =
|
|
2450
|
+
return i.setSelection(ka(i.doc, o)).scrollIntoView(), e.dispatch(i), e.focus(), !0;
|
|
2451
|
+
}, ja = (e, t) => {
|
|
2452
|
+
let n = Ca[t.key];
|
|
2393
2453
|
if (!n) return !1;
|
|
2394
2454
|
let { selection: r } = e.state;
|
|
2395
2455
|
if (!r.empty) return !1;
|
|
2396
2456
|
let i = r.$from, a = n === "before" ? i.nodeBefore : i.nodeAfter;
|
|
2397
|
-
if (!
|
|
2457
|
+
if (!Ta(a)) return !1;
|
|
2398
2458
|
t.preventDefault();
|
|
2399
2459
|
let o = n === "before" ? r.from - a.nodeSize : r.from;
|
|
2400
2460
|
return e.dispatch(e.state.tr.setSelection(I.create(e.state.doc, o)).scrollIntoView()), e.focus(), !0;
|
|
2401
|
-
},
|
|
2402
|
-
if (
|
|
2461
|
+
}, Ma = (e, t) => {
|
|
2462
|
+
if (Ea(t)) return !1;
|
|
2403
2463
|
let { selection: n } = e.state;
|
|
2404
|
-
return n instanceof I &&
|
|
2405
|
-
},
|
|
2406
|
-
if (
|
|
2464
|
+
return n instanceof I && Ta(n.node) ? Aa(e, n, t) : ja(e, t);
|
|
2465
|
+
}, Na = (e, t) => {
|
|
2466
|
+
if (wa(document.activeElement)) return !1;
|
|
2407
2467
|
let { selection: n } = e.state;
|
|
2408
|
-
if (!(n instanceof I) || n.node.type.name !==
|
|
2468
|
+
if (!(n instanceof I) || n.node.type.name !== ya) return !1;
|
|
2409
2469
|
let r = n.to, i = r + t.length, a = e.state.tr.insertText(t, r, r);
|
|
2410
2470
|
return a.setSelection(z.create(a.doc, i)).scrollIntoView(), e.dispatch(a), e.focus(), !0;
|
|
2411
|
-
},
|
|
2412
|
-
key: new R(
|
|
2471
|
+
}, Pa = V(() => new L({
|
|
2472
|
+
key: new R(ba),
|
|
2413
2473
|
props: {
|
|
2414
|
-
handleKeyDown: (e, t) =>
|
|
2415
|
-
handleTextInput: (e, t, n, r) =>
|
|
2474
|
+
handleKeyDown: (e, t) => Oa(e, t) || Ma(e, t) ? !0 : Da(e, t),
|
|
2475
|
+
handleTextInput: (e, t, n, r) => Na(e, r)
|
|
2416
2476
|
}
|
|
2417
|
-
})),
|
|
2477
|
+
})), Fa = "math_inline", Ia = "math_block", La = /(?:\$)([^$]+)(?:\$)$/, Ra = /^\$\$\s$/, za = pt("remarkMath", () => St), Ba = ut({}, "katexOptions"), Va = ft(Fa, (e) => ({
|
|
2418
2478
|
group: "inline",
|
|
2419
2479
|
inline: !0,
|
|
2420
2480
|
atom: !0,
|
|
2421
2481
|
attrs: { value: { default: "" } },
|
|
2422
2482
|
parseDOM: [{
|
|
2423
|
-
tag: `span[data-type="${
|
|
2483
|
+
tag: `span[data-type="${Fa}"]`,
|
|
2424
2484
|
getAttrs: (e) => {
|
|
2425
2485
|
let t = e;
|
|
2426
2486
|
return { value: t.dataset.value ?? t.textContent ?? "" };
|
|
@@ -2428,7 +2488,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2428
2488
|
}],
|
|
2429
2489
|
toDOM: (t) => {
|
|
2430
2490
|
let n = String(t.attrs.value ?? t.textContent ?? ""), r = document.createElement("span");
|
|
2431
|
-
return r.dataset.type =
|
|
2491
|
+
return r.dataset.type = Fa, r.dataset.value = n, bt.render(n, r, e.get(Ba.key)), r;
|
|
2432
2492
|
},
|
|
2433
2493
|
parseMarkdown: {
|
|
2434
2494
|
match: (e) => e.type === "inlineMath",
|
|
@@ -2438,13 +2498,13 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2438
2498
|
}
|
|
2439
2499
|
},
|
|
2440
2500
|
toMarkdown: {
|
|
2441
|
-
match: (e) => e.type.name ===
|
|
2501
|
+
match: (e) => e.type.name === Fa,
|
|
2442
2502
|
runner: (e, t) => {
|
|
2443
2503
|
let n = String(t.attrs.value ?? t.textContent ?? "");
|
|
2444
2504
|
e.addNode("inlineMath", void 0, n);
|
|
2445
2505
|
}
|
|
2446
2506
|
}
|
|
2447
|
-
})),
|
|
2507
|
+
})), Ha = ft(Ia, (e) => ({
|
|
2448
2508
|
content: "text*",
|
|
2449
2509
|
group: "block",
|
|
2450
2510
|
marks: "",
|
|
@@ -2453,13 +2513,13 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2453
2513
|
isolating: !0,
|
|
2454
2514
|
attrs: { value: { default: "" } },
|
|
2455
2515
|
parseDOM: [{
|
|
2456
|
-
tag: `div[data-type="${
|
|
2516
|
+
tag: `div[data-type="${Ia}"]`,
|
|
2457
2517
|
preserveWhitespace: "full",
|
|
2458
2518
|
getAttrs: (e) => ({ value: e.dataset.value ?? "" })
|
|
2459
2519
|
}],
|
|
2460
2520
|
toDOM: (t) => {
|
|
2461
2521
|
let n = String(t.attrs.value ?? ""), r = document.createElement("div");
|
|
2462
|
-
return r.dataset.type =
|
|
2522
|
+
return r.dataset.type = Ia, r.dataset.value = n, bt.render(n, r, e.get(Ba.key)), r;
|
|
2463
2523
|
},
|
|
2464
2524
|
parseMarkdown: {
|
|
2465
2525
|
match: (e) => e.type === "math",
|
|
@@ -2469,30 +2529,30 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2469
2529
|
}
|
|
2470
2530
|
},
|
|
2471
2531
|
toMarkdown: {
|
|
2472
|
-
match: (e) => e.type.name ===
|
|
2532
|
+
match: (e) => e.type.name === Ia,
|
|
2473
2533
|
runner: (e, t) => {
|
|
2474
2534
|
let n = String(t.attrs.value ?? "");
|
|
2475
2535
|
e.addNode("math", void 0, n);
|
|
2476
2536
|
}
|
|
2477
2537
|
}
|
|
2478
|
-
})),
|
|
2479
|
-
let a =
|
|
2538
|
+
})), Ua = dt((e) => new xt(La, (t, n, r, i) => {
|
|
2539
|
+
let a = Va.type(e), o = n[1] ?? "", s = t.doc.resolve(r);
|
|
2480
2540
|
return s.parent.canReplaceWith(s.index(), s.indexAfter(), a) ? t.tr.replaceWith(r, i, a.create({ value: o })) : null;
|
|
2481
|
-
})),
|
|
2482
|
-
La,
|
|
2483
|
-
Ra,
|
|
2541
|
+
})), Wa = [
|
|
2484
2542
|
za,
|
|
2485
2543
|
Ba,
|
|
2486
|
-
|
|
2487
|
-
|
|
2544
|
+
Va,
|
|
2545
|
+
Ha,
|
|
2546
|
+
dt((e) => new xt(Ra, (t, n, r, i) => {
|
|
2547
|
+
let a = t.doc.resolve(r), o = Ha.type(e);
|
|
2488
2548
|
return a.node(-1).canReplaceWith(a.index(-1), a.indexAfter(-1), o) ? t.tr.delete(r, i).setBlockType(r, r, o) : null;
|
|
2489
2549
|
})),
|
|
2490
|
-
|
|
2491
|
-
].flat(),
|
|
2492
|
-
if (e.parent.type.name !==
|
|
2550
|
+
Ua
|
|
2551
|
+
].flat(), Ga = "blockquote", Ka = "paragraph", qa = "Backspace", Ja = (e) => e.key !== qa || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey, Ya = (e) => {
|
|
2552
|
+
if (e.parent.type.name !== Ka || e.parentOffset !== 0) return null;
|
|
2493
2553
|
for (let t = e.depth; t > 0; --t) {
|
|
2494
2554
|
let n = e.node(t);
|
|
2495
|
-
if (n.type.name !==
|
|
2555
|
+
if (n.type.name !== Ga) continue;
|
|
2496
2556
|
let r = e.depth, i = e.index(t);
|
|
2497
2557
|
return r <= t || i !== 0 ? null : {
|
|
2498
2558
|
paragraphDepth: r,
|
|
@@ -2501,10 +2561,10 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2501
2561
|
};
|
|
2502
2562
|
}
|
|
2503
2563
|
return null;
|
|
2504
|
-
},
|
|
2564
|
+
}, Xa = (e, t) => {
|
|
2505
2565
|
let { selection: n } = e.state;
|
|
2506
2566
|
if (!n.empty) return !1;
|
|
2507
|
-
let r = n.$from, i =
|
|
2567
|
+
let r = n.$from, i = Ya(r);
|
|
2508
2568
|
if (!i) return !1;
|
|
2509
2569
|
let a = r.blockRange(r, (e) => e.type === i.blockquoteType);
|
|
2510
2570
|
if (!a) return !1;
|
|
@@ -2513,70 +2573,70 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2513
2573
|
t.preventDefault();
|
|
2514
2574
|
let s = e.state.tr.lift(a, o).scrollIntoView();
|
|
2515
2575
|
return e.dispatch(s), !0;
|
|
2516
|
-
},
|
|
2576
|
+
}, Za = V(() => new L({
|
|
2517
2577
|
key: new R("zt-md-blockquote-backspace-lift"),
|
|
2518
|
-
props: { handleKeyDown: (e, t) =>
|
|
2519
|
-
})),
|
|
2520
|
-
if (e.type.name !==
|
|
2578
|
+
props: { handleKeyDown: (e, t) => Ja(t) ? !1 : Xa(e, t) }
|
|
2579
|
+
})), Qa = "Backspace", $a = "heading", eo = "paragraph", to = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, no = (e) => {
|
|
2580
|
+
if (e.type.name !== eo) return !1;
|
|
2521
2581
|
let t = e.textContent;
|
|
2522
2582
|
return t.trim().length === 0 && e.content.size === t.length;
|
|
2523
|
-
},
|
|
2524
|
-
if (e.parent.type.name !==
|
|
2583
|
+
}, ro = (e) => {
|
|
2584
|
+
if (e.parent.type.name !== $a || e.parentOffset !== 0 || e.depth < 1) return null;
|
|
2525
2585
|
let t = e.index(e.depth - 1);
|
|
2526
2586
|
if (t <= 0) return null;
|
|
2527
2587
|
let n = e.node(e.depth - 1).child(t - 1);
|
|
2528
|
-
if (!
|
|
2588
|
+
if (!no(n)) return null;
|
|
2529
2589
|
let r = e.before(e.depth);
|
|
2530
2590
|
return {
|
|
2531
2591
|
from: r - n.nodeSize,
|
|
2532
2592
|
to: r
|
|
2533
2593
|
};
|
|
2534
|
-
},
|
|
2535
|
-
if (t.key !==
|
|
2594
|
+
}, io = (e, t) => {
|
|
2595
|
+
if (t.key !== Qa || t.defaultPrevented || t.altKey || t.ctrlKey || t.metaKey || t.shiftKey || !to(e)) return !1;
|
|
2536
2596
|
let { selection: n } = e.state;
|
|
2537
2597
|
if (!n.empty) return !1;
|
|
2538
|
-
let r =
|
|
2598
|
+
let r = ro(n.$from);
|
|
2539
2599
|
if (!r) return !1;
|
|
2540
2600
|
t.preventDefault();
|
|
2541
2601
|
let i = e.state.tr.delete(r.from, r.to);
|
|
2542
2602
|
return i.setSelection(z.create(i.doc, r.from + 1)).scrollIntoView(), e.dispatch(i), !0;
|
|
2543
|
-
},
|
|
2603
|
+
}, ao = V(() => new L({
|
|
2544
2604
|
key: new R("zt-md-heading-backspace-empty-paragraph"),
|
|
2545
|
-
props: { handleKeyDown: (e, t) =>
|
|
2546
|
-
})),
|
|
2605
|
+
props: { handleKeyDown: (e, t) => io(e, t) }
|
|
2606
|
+
})), oo = "heading", so = "zt-md-heading-focused", co = "zt-md-heading-focus-indicator", lo = (e) => {
|
|
2547
2607
|
let t = e.selection.$from;
|
|
2548
2608
|
for (let n = t.depth; n > 0; --n) {
|
|
2549
2609
|
let r = t.node(n);
|
|
2550
|
-
if (r.type.name !==
|
|
2610
|
+
if (r.type.name !== oo) continue;
|
|
2551
2611
|
let i = t.before(n), a = Number(r.attrs.level), o = lt.node(i, i + r.nodeSize, {
|
|
2552
|
-
class:
|
|
2612
|
+
class: so,
|
|
2553
2613
|
"data-heading-level": `H${a}`
|
|
2554
2614
|
});
|
|
2555
2615
|
return B.create(e.doc, [o]);
|
|
2556
2616
|
}
|
|
2557
2617
|
return B.empty;
|
|
2558
|
-
},
|
|
2559
|
-
key: new R(
|
|
2560
|
-
props: { decorations:
|
|
2561
|
-
})),
|
|
2618
|
+
}, uo = V(() => new L({
|
|
2619
|
+
key: new R(co),
|
|
2620
|
+
props: { decorations: lo }
|
|
2621
|
+
})), fo = "MILKDOWN_HEADING_ID", po = "table", mo = (e, t, n, r) => {
|
|
2562
2622
|
let i = Math.max(0, Math.min(e.content.size, t)), a = Math.max(i, Math.min(e.content.size, n)), o = e.resolve(i);
|
|
2563
2623
|
for (let e = o.depth; e > 0; --e) if (o.node(e).type === r) return !0;
|
|
2564
2624
|
if (a > i) {
|
|
2565
2625
|
let t = e.resolve(a);
|
|
2566
2626
|
for (let e = t.depth; e > 0; --e) if (t.node(e).type === r) return !0;
|
|
2567
2627
|
let n = !1;
|
|
2568
|
-
if (e.nodesBetween(i, a, (e) => e.type === r ? (n = !0, !1) : e.isTextblock || e.type.name ===
|
|
2628
|
+
if (e.nodesBetween(i, a, (e) => e.type === r ? (n = !0, !1) : e.isTextblock || e.type.name === po ? !1 : !n), n) return !0;
|
|
2569
2629
|
}
|
|
2570
2630
|
return !1;
|
|
2571
|
-
},
|
|
2631
|
+
}, ho = (e, t, n) => {
|
|
2572
2632
|
let r = e.content.findDiffStart(t.content);
|
|
2573
2633
|
if (r == null) return !1;
|
|
2574
2634
|
let i = e.content.findDiffEnd(t.content);
|
|
2575
2635
|
if (!i) return !1;
|
|
2576
2636
|
let a = Math.max(i.a, r), o = Math.max(i.b, r);
|
|
2577
|
-
return
|
|
2578
|
-
},
|
|
2579
|
-
let t = new R(
|
|
2637
|
+
return mo(e, r, a, n) || mo(t, r, o, n);
|
|
2638
|
+
}, go = V((e) => {
|
|
2639
|
+
let t = new R(fo), n = Le.type(e), r = (r) => {
|
|
2580
2640
|
if (r.composing) return;
|
|
2581
2641
|
let i = e.get(Fe.key), a = r.state.tr.setMeta("addToHistory", !1), o = !1, s = {};
|
|
2582
2642
|
r.state.doc.descendants((e, r) => {
|
|
@@ -2588,7 +2648,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2588
2648
|
id: c
|
|
2589
2649
|
})), !1;
|
|
2590
2650
|
}
|
|
2591
|
-
return !(e.isTextblock || e.type.name ===
|
|
2651
|
+
return !(e.isTextblock || e.type.name === po);
|
|
2592
2652
|
}), o && r.dispatch(a);
|
|
2593
2653
|
};
|
|
2594
2654
|
return new L({
|
|
@@ -2600,7 +2660,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2600
2660
|
!e.composing && t && (t = !1, r(e));
|
|
2601
2661
|
return;
|
|
2602
2662
|
}
|
|
2603
|
-
if (
|
|
2663
|
+
if (ho(i.doc, e.state.doc, n)) {
|
|
2604
2664
|
if (e.composing) {
|
|
2605
2665
|
t = !0;
|
|
2606
2666
|
return;
|
|
@@ -2610,23 +2670,23 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2610
2670
|
} };
|
|
2611
2671
|
}
|
|
2612
2672
|
});
|
|
2613
|
-
}),
|
|
2673
|
+
}), _o = "text", vo = {
|
|
2614
2674
|
svg: "svg",
|
|
2615
2675
|
html: "html"
|
|
2616
|
-
},
|
|
2676
|
+
}, yo = {
|
|
2617
2677
|
html: !0,
|
|
2618
2678
|
svg: !0
|
|
2619
2679
|
}, Y = (e) => {
|
|
2620
2680
|
let t = e.trim().toLowerCase();
|
|
2621
|
-
return t ? t.startsWith("canvas-") ? Object.entries(
|
|
2622
|
-
},
|
|
2681
|
+
return t ? t.startsWith("canvas-") ? Object.entries(vo).find(([e]) => t.includes(e))?.[1] ?? t : t : _o;
|
|
2682
|
+
}, bo = (e) => (t) => {
|
|
2623
2683
|
let n = e(t);
|
|
2624
2684
|
return {
|
|
2625
2685
|
...n,
|
|
2626
2686
|
attrs: {
|
|
2627
2687
|
...n.attrs,
|
|
2628
2688
|
language: {
|
|
2629
|
-
default:
|
|
2689
|
+
default: _o,
|
|
2630
2690
|
validate: "string"
|
|
2631
2691
|
}
|
|
2632
2692
|
},
|
|
@@ -2648,10 +2708,10 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2648
2708
|
}
|
|
2649
2709
|
}
|
|
2650
2710
|
};
|
|
2651
|
-
},
|
|
2711
|
+
}, xo = (e) => {
|
|
2652
2712
|
let t = e.get(Ne.key);
|
|
2653
|
-
e.set(Ne.key,
|
|
2654
|
-
},
|
|
2713
|
+
e.set(Ne.key, bo(t));
|
|
2714
|
+
}, So = (e) => yo[Y(e)] === !0, Co = "code_block", wo = 1200, To = "html", Eo = "ZT_MD_CODE_BLOCK_PREVIEW_LAYOUT", Do = [
|
|
2655
2715
|
"default-src 'none'",
|
|
2656
2716
|
"style-src 'unsafe-inline'",
|
|
2657
2717
|
"img-src data: blob:",
|
|
@@ -2662,27 +2722,27 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2662
2722
|
"object-src 'none'",
|
|
2663
2723
|
"form-action 'none'",
|
|
2664
2724
|
"base-uri 'none'"
|
|
2665
|
-
],
|
|
2725
|
+
], Oo = q("Copy", {
|
|
2666
2726
|
size: 14,
|
|
2667
2727
|
strokeWidth: 2
|
|
2668
|
-
}),
|
|
2728
|
+
}), ko = q("Check", {
|
|
2669
2729
|
size: 14,
|
|
2670
2730
|
strokeWidth: 2
|
|
2671
|
-
}),
|
|
2731
|
+
}), Ao = q("Trash2", {
|
|
2672
2732
|
size: 14,
|
|
2673
2733
|
strokeWidth: 2
|
|
2674
|
-
}),
|
|
2734
|
+
}), jo = q("Eye", {
|
|
2675
2735
|
size: 14,
|
|
2676
2736
|
strokeWidth: 2
|
|
2677
|
-
}),
|
|
2737
|
+
}), Mo = q("Code2", {
|
|
2678
2738
|
size: 14,
|
|
2679
2739
|
strokeWidth: 2
|
|
2680
|
-
}),
|
|
2740
|
+
}), No = (e, t) => `<!doctype html>
|
|
2681
2741
|
<html>
|
|
2682
2742
|
<head>
|
|
2683
2743
|
<meta charset="UTF-8" />
|
|
2684
2744
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
2685
|
-
<meta http-equiv="Content-Security-Policy" content="${[...
|
|
2745
|
+
<meta http-equiv="Content-Security-Policy" content="${[...Do, ...t ? ["script-src 'unsafe-inline'"] : []].join("; ")}" />
|
|
2686
2746
|
<style>
|
|
2687
2747
|
*, *::before, *::after { box-sizing: border-box; }
|
|
2688
2748
|
html, body { min-height: 100%; margin: 0; }
|
|
@@ -2691,7 +2751,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2691
2751
|
</style>
|
|
2692
2752
|
</head>
|
|
2693
2753
|
<body>${e}</body>
|
|
2694
|
-
</html>`,
|
|
2754
|
+
</html>`, Po = (e) => typeof e == "function" ? e() : null, Fo = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, Io = class {
|
|
2695
2755
|
syncLanguageAttribute(e) {
|
|
2696
2756
|
let t = typeof e.attrs.language == "string" ? e.attrs.language.trim() : "";
|
|
2697
2757
|
if (!t) {
|
|
@@ -2702,29 +2762,29 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2702
2762
|
}
|
|
2703
2763
|
constructor(e, t, n, r) {
|
|
2704
2764
|
this.previewFrame = null, this.isPreviewAvailable = !1, this.isPreviewMode = !1, this.renderedPreviewKey = null, this.copyFeedbackTimer = null, this.handlePreviewClick = (e) => {
|
|
2705
|
-
e.preventDefault(), e.stopPropagation(), this.isPreviewAvailable && (this.isPreviewMode = !this.isPreviewMode, this.syncPreviewState(), this.view.dispatch(this.view.state.tr.setMeta(
|
|
2765
|
+
e.preventDefault(), e.stopPropagation(), this.isPreviewAvailable && (this.isPreviewMode = !this.isPreviewMode, this.syncPreviewState(), this.view.dispatch(this.view.state.tr.setMeta(Eo, !0)));
|
|
2706
2766
|
}, this.handlePreviewKeyDown = (e) => {
|
|
2707
2767
|
if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
2708
|
-
let t =
|
|
2709
|
-
t !== null &&
|
|
2768
|
+
let t = Po(this.getPos);
|
|
2769
|
+
t !== null && fr(this.view, t, this.node, e.key) && e.preventDefault();
|
|
2710
2770
|
}, this.handleCopyClick = (e) => {
|
|
2711
|
-
if (e.preventDefault(), e.stopPropagation(), !
|
|
2771
|
+
if (e.preventDefault(), e.stopPropagation(), !Fo(this.view)) return;
|
|
2712
2772
|
let t = this.node.textContent;
|
|
2713
2773
|
(typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(t) : Promise.resolve()).then(() => {
|
|
2714
|
-
this.copyButton.innerHTML =
|
|
2715
|
-
this.copyButton.innerHTML =
|
|
2716
|
-
},
|
|
2774
|
+
this.copyButton.innerHTML = ko, this.copyButton.dataset.copied = "true", this.copyFeedbackTimer !== null && clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = setTimeout(() => {
|
|
2775
|
+
this.copyButton.innerHTML = Oo, delete this.copyButton.dataset.copied, this.copyFeedbackTimer = null;
|
|
2776
|
+
}, wo);
|
|
2717
2777
|
}).catch(() => {});
|
|
2718
2778
|
}, this.handleDeleteClick = (e) => {
|
|
2719
|
-
e.preventDefault(), e.stopPropagation(),
|
|
2720
|
-
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("div"), this.dom.className = "zt-md-code-block", this.dom.dataset.type =
|
|
2779
|
+
e.preventDefault(), e.stopPropagation(), Fo(this.view) && this.deleteCurrentCodeBlock();
|
|
2780
|
+
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("div"), this.dom.className = "zt-md-code-block", this.dom.dataset.type = Co, this.contentDOM = document.createElement("pre"), this.previewContainer = document.createElement("div"), this.previewContainer.className = "zt-md-code-block-preview", this.previewContainer.contentEditable = "false", this.previewContainer.hidden = !0, this.previewContainer.tabIndex = -1, this.previewContainer.setAttribute("role", "region"), this.previewContainer.setAttribute("aria-label", r.codeBlockPreviewAriaLabel), this.actionsContainer = document.createElement("span"), this.actionsContainer.className = "zt-md-code-block-actions", this.actionsContainer.contentEditable = "false", this.previewButton = document.createElement("button"), this.previewButton.type = "button", this.previewButton.className = "zt-md-code-block-action-button", this.previewButton.hidden = !0, this.previewButton.innerHTML = jo, this.copyButton = document.createElement("button"), this.copyButton.type = "button", this.copyButton.className = "zt-md-code-block-action-button zt-md-code-block-editable-action", this.copyButton.setAttribute("aria-label", r.codeBlockCopyAriaLabel), this.copyButton.innerHTML = Oo, this.deleteButton = document.createElement("button"), this.deleteButton.type = "button", this.deleteButton.className = "zt-md-code-block-action-button zt-md-code-block-editable-action zt-md-code-block-action-button-danger", this.deleteButton.setAttribute("aria-label", r.codeBlockDeleteAriaLabel), this.deleteButton.innerHTML = Ao, this.actionsContainer.append(this.previewButton, this.copyButton, this.deleteButton), this.dom.append(this.contentDOM, this.previewContainer, this.actionsContainer), this.updateEditableState(), this.syncLanguageAttribute(e), this.syncPreviewAvailability(e), this.previewButton.addEventListener("click", this.handlePreviewClick), this.copyButton.addEventListener("click", this.handleCopyClick), this.deleteButton.addEventListener("click", this.handleDeleteClick), this.previewContainer.addEventListener("keydown", this.handlePreviewKeyDown), this.stopObservingMessages = G(r, () => {
|
|
2721
2781
|
this.previewContainer.setAttribute("aria-label", r.codeBlockPreviewAriaLabel), this.copyButton.setAttribute("aria-label", r.codeBlockCopyAriaLabel), this.deleteButton.setAttribute("aria-label", r.codeBlockDeleteAriaLabel);
|
|
2722
2782
|
let e = this.isPreviewAvailable && this.isPreviewMode ? r.codeBlockSourceAriaLabel : r.codeBlockPreviewAriaLabel;
|
|
2723
2783
|
this.previewButton.setAttribute("aria-label", e), this.previewButton.title = e, this.previewFrame && (this.previewFrame.title = r.codeBlockPreviewAriaLabel);
|
|
2724
2784
|
});
|
|
2725
2785
|
}
|
|
2726
2786
|
deleteCurrentCodeBlock() {
|
|
2727
|
-
let e =
|
|
2787
|
+
let e = Po(this.getPos);
|
|
2728
2788
|
if (e === null) return;
|
|
2729
2789
|
let t = this.view.state.tr.delete(e, e + this.node.nodeSize), n = Math.min(e, t.doc.content.size);
|
|
2730
2790
|
t.setSelection(z.near(t.doc.resolve(n), -1)).scrollIntoView(), this.view.dispatch(t), requestAnimationFrame(() => {
|
|
@@ -2732,36 +2792,36 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2732
2792
|
});
|
|
2733
2793
|
}
|
|
2734
2794
|
updateEditableState() {
|
|
2735
|
-
this.dom.dataset.editable =
|
|
2795
|
+
this.dom.dataset.editable = Fo(this.view) ? "true" : "false";
|
|
2736
2796
|
}
|
|
2737
2797
|
syncPreviewAvailability(e) {
|
|
2738
2798
|
let t = typeof e.attrs.language == "string" ? e.attrs.language : "";
|
|
2739
|
-
this.isPreviewAvailable =
|
|
2799
|
+
this.isPreviewAvailable = So(t), this.isPreviewAvailable || (this.isPreviewMode = !1), this.previewButton.hidden = !this.isPreviewAvailable, this.syncPreviewState(), this.syncActionsVisibility();
|
|
2740
2800
|
}
|
|
2741
2801
|
syncPreviewState() {
|
|
2742
2802
|
let e = this.isPreviewAvailable && this.isPreviewMode, t = e ? this.messages.codeBlockSourceAriaLabel : this.messages.codeBlockPreviewAriaLabel;
|
|
2743
|
-
if (this.dom.dataset.viewMode = e ? "preview" : "source", this.previewContainer.hidden = !e, this.previewContainer.tabIndex = e ? 0 : -1, this.previewButton.dataset.active = e ? "true" : "false", this.previewButton.setAttribute("aria-pressed", e ? "true" : "false"), this.previewButton.setAttribute("aria-label", t), this.previewButton.title = t, this.previewButton.innerHTML = e ?
|
|
2803
|
+
if (this.dom.dataset.viewMode = e ? "preview" : "source", this.previewContainer.hidden = !e, this.previewContainer.tabIndex = e ? 0 : -1, this.previewButton.dataset.active = e ? "true" : "false", this.previewButton.setAttribute("aria-pressed", e ? "true" : "false"), this.previewButton.setAttribute("aria-label", t), this.previewButton.title = t, this.previewButton.innerHTML = e ? Mo : jo, e) {
|
|
2744
2804
|
this.contentDOM.setAttribute("aria-hidden", "true"), this.renderPreview();
|
|
2745
2805
|
return;
|
|
2746
2806
|
}
|
|
2747
2807
|
this.contentDOM.removeAttribute("aria-hidden"), this.clearPreview();
|
|
2748
2808
|
}
|
|
2749
2809
|
syncActionsVisibility() {
|
|
2750
|
-
let e =
|
|
2810
|
+
let e = Fo(this.view) || this.isPreviewAvailable;
|
|
2751
2811
|
this.actionsContainer.dataset.visible = e ? "true" : "false";
|
|
2752
2812
|
}
|
|
2753
2813
|
renderPreview() {
|
|
2754
|
-
let e = this.node.textContent, t = Y(String(this.node.attrs.language ?? "")), n = t ===
|
|
2814
|
+
let e = this.node.textContent, t = Y(String(this.node.attrs.language ?? "")), n = t === To, r = `${t}\u0000${e}`;
|
|
2755
2815
|
if (this.renderedPreviewKey === r) return;
|
|
2756
2816
|
this.renderedPreviewKey = r;
|
|
2757
2817
|
let i = document.createElement("iframe");
|
|
2758
|
-
i.className = "zt-md-code-block-preview-frame", i.title = this.messages.codeBlockPreviewAriaLabel, i.tabIndex = -1, i.referrerPolicy = "no-referrer", i.setAttribute("sandbox", n ? "allow-scripts" : ""), i.srcdoc =
|
|
2818
|
+
i.className = "zt-md-code-block-preview-frame", i.title = this.messages.codeBlockPreviewAriaLabel, i.tabIndex = -1, i.referrerPolicy = "no-referrer", i.setAttribute("sandbox", n ? "allow-scripts" : ""), i.srcdoc = No(e, n), this.previewContainer.replaceChildren(i), this.previewFrame = i;
|
|
2759
2819
|
}
|
|
2760
2820
|
clearPreview() {
|
|
2761
2821
|
this.renderedPreviewKey = null, this.previewFrame?.remove(), this.previewFrame = null;
|
|
2762
2822
|
}
|
|
2763
2823
|
update(e) {
|
|
2764
|
-
return e.type.name ===
|
|
2824
|
+
return e.type.name === Co ? (this.node = e, this.updateEditableState(), this.syncLanguageAttribute(e), this.syncPreviewAvailability(e), !0) : !1;
|
|
2765
2825
|
}
|
|
2766
2826
|
stopEvent(e) {
|
|
2767
2827
|
let t = e.target;
|
|
@@ -2771,30 +2831,30 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2771
2831
|
return e.type === "selection" ? !1 : e.type === "attributes" && (e.target === this.dom && e.attributeName === "data-view-mode" || e.target === this.contentDOM && e.attributeName === "aria-hidden") ? !0 : this.actionsContainer.contains(e.target) || this.previewContainer.contains(e.target);
|
|
2772
2832
|
}
|
|
2773
2833
|
destroy() {
|
|
2774
|
-
this.stopObservingMessages(), this.previewButton.removeEventListener("click", this.handlePreviewClick), this.copyButton.removeEventListener("click", this.handleCopyClick), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.previewContainer.removeEventListener("keydown", this.handlePreviewKeyDown), this.copyFeedbackTimer !== null && (clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = null), this.copyButton.innerHTML =
|
|
2834
|
+
this.stopObservingMessages(), this.previewButton.removeEventListener("click", this.handlePreviewClick), this.copyButton.removeEventListener("click", this.handleCopyClick), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.previewContainer.removeEventListener("keydown", this.handlePreviewKeyDown), this.copyFeedbackTimer !== null && (clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = null), this.copyButton.innerHTML = Oo, delete this.copyButton.dataset.copied, this.clearPreview();
|
|
2775
2835
|
}
|
|
2776
|
-
},
|
|
2836
|
+
}, Lo = (e = W()) => (t, n, r) => new Io(t, n, typeof r == "function" ? () => {
|
|
2777
2837
|
let e = r();
|
|
2778
2838
|
return typeof e == "number" ? e : 0;
|
|
2779
|
-
} : !1, e),
|
|
2780
|
-
Array.from(
|
|
2781
|
-
},
|
|
2782
|
-
|
|
2839
|
+
} : !1, e), Ro = /* @__PURE__ */ new Set(), zo = !1, Bo = () => typeof document < "u", Vo = (e) => {
|
|
2840
|
+
Array.from(Ro).forEach((t) => t(e));
|
|
2841
|
+
}, Ho = () => {
|
|
2842
|
+
zo || !Bo() || (document.addEventListener("scroll", Vo, {
|
|
2783
2843
|
capture: !0,
|
|
2784
2844
|
passive: !0
|
|
2785
|
-
}),
|
|
2786
|
-
},
|
|
2787
|
-
!
|
|
2788
|
-
},
|
|
2789
|
-
if (!
|
|
2845
|
+
}), zo = !0);
|
|
2846
|
+
}, Uo = () => {
|
|
2847
|
+
!zo || !Bo() || (document.removeEventListener("scroll", Vo, !0), zo = !1);
|
|
2848
|
+
}, Wo = (e) => {
|
|
2849
|
+
if (!Bo()) return () => void 0;
|
|
2790
2850
|
let t = !0;
|
|
2791
|
-
return
|
|
2792
|
-
t && (t = !1,
|
|
2851
|
+
return Ro.add(e), Ho(), () => {
|
|
2852
|
+
t && (t = !1, Ro.delete(e), Ro.size === 0 && Uo());
|
|
2793
2853
|
};
|
|
2794
|
-
},
|
|
2854
|
+
}, Go = (e) => e ? e.closest(".zt-md-editor") ?? e : null, Ko = (e, t, n) => {
|
|
2795
2855
|
let r = typeof window > "u" ? e.bottom : window.innerHeight, i = n?.top ?? 0, a = n?.bottom ?? r, o = e.top - i, s = a - e.bottom;
|
|
2796
2856
|
return s < t && o > s ? "top" : "bottom";
|
|
2797
|
-
},
|
|
2857
|
+
}, qo = (e, t, n) => {
|
|
2798
2858
|
let r = n ?? t.getBoundingClientRect();
|
|
2799
2859
|
return {
|
|
2800
2860
|
anchorTopInContent: e.top - r.top + t.scrollTop,
|
|
@@ -2802,28 +2862,28 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2802
2862
|
anchorLeftInContent: e.left - r.left + t.scrollLeft,
|
|
2803
2863
|
anchorRightInContent: e.right - r.left + t.scrollLeft
|
|
2804
2864
|
};
|
|
2805
|
-
},
|
|
2865
|
+
}, Jo = (e) => {
|
|
2806
2866
|
let { anchor: t, overlaySize: n, horizontalAlign: r = "start" } = e, i = t.anchorRightInContent ?? t.anchorLeftInContent;
|
|
2807
2867
|
return r === "end" ? i - n.width : r === "center" ? t.anchorLeftInContent + (i - t.anchorLeftInContent - n.width) / 2 : t.anchorLeftInContent;
|
|
2808
|
-
},
|
|
2809
|
-
let { wrapper: n, anchor: r, overlaySize: i, placement: a, offsetY: o, boundaryInset: s } = e, c = t ?? n.getBoundingClientRect(), l = n.scrollLeft + s, u = n.scrollLeft + n.clientWidth - i.width - s, d =
|
|
2868
|
+
}, Yo = (e, t) => {
|
|
2869
|
+
let { wrapper: n, anchor: r, overlaySize: i, placement: a, offsetY: o, boundaryInset: s } = e, c = t ?? n.getBoundingClientRect(), l = n.scrollLeft + s, u = n.scrollLeft + n.clientWidth - i.width - s, d = Jo(e), f = Math.min(Math.max(d, l), Math.max(l, u)), p = a === "top" ? r.anchorTopInContent - (i.height ?? 0) - o : r.anchorBottomInContent + o;
|
|
2810
2870
|
return {
|
|
2811
2871
|
left: c.left + f - n.scrollLeft,
|
|
2812
2872
|
top: c.top + p - n.scrollTop
|
|
2813
2873
|
};
|
|
2814
|
-
},
|
|
2815
|
-
let r =
|
|
2874
|
+
}, Xo = (e, t, n) => {
|
|
2875
|
+
let r = Yo(e, n), i = t.getBoundingClientRect();
|
|
2816
2876
|
return {
|
|
2817
2877
|
left: r.left - i.left,
|
|
2818
2878
|
top: r.top - i.top
|
|
2819
2879
|
};
|
|
2820
|
-
},
|
|
2880
|
+
}, Zo = (e) => {
|
|
2821
2881
|
let t = 0, n = null, r = null, i = () => {
|
|
2822
2882
|
typeof window > "u" || (t && window.cancelAnimationFrame(t), t = window.requestAnimationFrame(() => {
|
|
2823
2883
|
t = 0, e();
|
|
2824
2884
|
}));
|
|
2825
2885
|
}, a = () => {
|
|
2826
|
-
window.addEventListener("resize", i), r ||=
|
|
2886
|
+
window.addEventListener("resize", i), r ||= Wo(i);
|
|
2827
2887
|
}, o = () => {
|
|
2828
2888
|
window.removeEventListener("resize", i), r?.(), r = null;
|
|
2829
2889
|
}, s = (e) => {
|
|
@@ -2838,18 +2898,18 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2838
2898
|
typeof window < "u" && t && (window.cancelAnimationFrame(t), t = 0), o(), s(null);
|
|
2839
2899
|
}
|
|
2840
2900
|
};
|
|
2841
|
-
},
|
|
2901
|
+
}, Qo = (e, t, n, r) => {
|
|
2842
2902
|
let i = t.top - r.top, a = r.bottom - t.bottom;
|
|
2843
2903
|
return e === "top" ? i < n && a > i ? "bottom" : "top" : a < n && i > a ? "top" : "bottom";
|
|
2844
|
-
},
|
|
2904
|
+
}, $o = ({ open: e, portalContainer: t, editorWrapper: n, defaultPlacement: o = "bottom", horizontalAlign: c = "start", offsetY: l = 8, boundaryInset: u = 2, fallbackWidth: d, fallbackHeight: f, onOutside: p }) => {
|
|
2845
2905
|
let m = s(null), h = s(null), g = s(e), _ = s(p);
|
|
2846
2906
|
_.current = p;
|
|
2847
2907
|
let v = r(() => {
|
|
2848
2908
|
let e = m.current, r = h.current;
|
|
2849
2909
|
if (!g.current || !e || !r || !t || !n) return;
|
|
2850
|
-
let i = e.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r.offsetWidth || d, p = r.offsetHeight || f, _ =
|
|
2910
|
+
let i = e.getBoundingClientRect(), a = n.getBoundingClientRect(), s = r.offsetWidth || d, p = r.offsetHeight || f, _ = Qo(o, i, p, a), v = Xo({
|
|
2851
2911
|
wrapper: n,
|
|
2852
|
-
anchor:
|
|
2912
|
+
anchor: qo(i, n, a),
|
|
2853
2913
|
overlaySize: {
|
|
2854
2914
|
width: s,
|
|
2855
2915
|
height: p
|
|
@@ -2880,7 +2940,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2880
2940
|
v();
|
|
2881
2941
|
}, [e, v]), i(() => {
|
|
2882
2942
|
if (!e) return;
|
|
2883
|
-
let t =
|
|
2943
|
+
let t = Zo(v);
|
|
2884
2944
|
return t.bindGlobal(), t.bindWrapper(n ?? null), t.schedule(), () => {
|
|
2885
2945
|
t.destroy();
|
|
2886
2946
|
};
|
|
@@ -2903,7 +2963,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2903
2963
|
panelRef: y,
|
|
2904
2964
|
updatePosition: v
|
|
2905
2965
|
};
|
|
2906
|
-
},
|
|
2966
|
+
}, es = ({ panel: e, portalContainer: t, className: r, role: i, onMouseDown: a, children: o }) => !e.open || !t ? null : wt(n("div", {
|
|
2907
2967
|
ref: e.panelRef,
|
|
2908
2968
|
role: i,
|
|
2909
2969
|
className: r,
|
|
@@ -2912,7 +2972,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2912
2972
|
visibility: "hidden"
|
|
2913
2973
|
},
|
|
2914
2974
|
onMouseDown: a
|
|
2915
|
-
}, o), t),
|
|
2975
|
+
}, o), t), ts = "code_block", ns = "ZT_MD_CODE_BLOCK_LANGUAGE_PICKER", rs = 8, is = 96, as = 26, os = 224, ss = 220, cs = [
|
|
2916
2976
|
"javascript",
|
|
2917
2977
|
"typescript",
|
|
2918
2978
|
"tsx",
|
|
@@ -2933,16 +2993,16 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2933
2993
|
"csharp",
|
|
2934
2994
|
"php",
|
|
2935
2995
|
"docker"
|
|
2936
|
-
],
|
|
2937
|
-
let t = Ye.listLanguages(), n = new Set(t.map((e) => Y(e)).filter((e) => e !==
|
|
2938
|
-
for (let e of
|
|
2996
|
+
], ls = (e) => {
|
|
2997
|
+
let t = Ye.listLanguages(), n = new Set(t.map((e) => Y(e)).filter((e) => e !== _o)), r = [];
|
|
2998
|
+
for (let e of cs) n.delete(e) && r.push({
|
|
2939
2999
|
value: e,
|
|
2940
3000
|
label: e
|
|
2941
3001
|
});
|
|
2942
3002
|
let i = [...n].sort((e, t) => e.localeCompare(t));
|
|
2943
3003
|
return [
|
|
2944
3004
|
{
|
|
2945
|
-
value:
|
|
3005
|
+
value: _o,
|
|
2946
3006
|
label: e
|
|
2947
3007
|
},
|
|
2948
3008
|
...r,
|
|
@@ -2951,21 +3011,21 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2951
3011
|
label: e
|
|
2952
3012
|
}))
|
|
2953
3013
|
];
|
|
2954
|
-
},
|
|
3014
|
+
}, us = (e) => {
|
|
2955
3015
|
let t = e.state.selection.$from;
|
|
2956
3016
|
for (let e = t.depth; e >= 0; --e) {
|
|
2957
3017
|
let n = t.node(e);
|
|
2958
|
-
if (n.type.name ===
|
|
3018
|
+
if (n.type.name === ts) return {
|
|
2959
3019
|
position: e === 0 ? 0 : t.before(e),
|
|
2960
3020
|
node: n
|
|
2961
3021
|
};
|
|
2962
3022
|
}
|
|
2963
3023
|
return null;
|
|
2964
|
-
},
|
|
3024
|
+
}, ds = (e, t) => {
|
|
2965
3025
|
let n = e.nodeDOM(t);
|
|
2966
3026
|
return n instanceof HTMLPreElement ? n : n instanceof HTMLElement ? n.querySelector("pre") : null;
|
|
2967
|
-
},
|
|
2968
|
-
let [r, l] = c(!1), [u, d] = c(""), [f, p] = c(0), m = s(null), h = s(null), g = Y(e.currentLanguage), _ = g === "text" ? e.messages.codeBlockLanguagePlainText : g, v = o(() =>
|
|
3027
|
+
}, fs = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, ps = (e) => {
|
|
3028
|
+
let [r, l] = c(!1), [u, d] = c(""), [f, p] = c(0), m = s(null), h = s(null), g = Y(e.currentLanguage), _ = g === "text" ? e.messages.codeBlockLanguagePlainText : g, v = o(() => ls(e.messages.codeBlockLanguagePlainText), [e.messages.codeBlockLanguagePlainText]), y = o(() => {
|
|
2969
3029
|
let e = u.trim().toLowerCase();
|
|
2970
3030
|
if (!e) return v;
|
|
2971
3031
|
let t = [], n = [];
|
|
@@ -2974,14 +3034,14 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
2974
3034
|
a.startsWith(e) || i.startsWith(e) ? t.push(r) : (a.includes(e) || i.includes(e)) && n.push(r);
|
|
2975
3035
|
}
|
|
2976
3036
|
return [...t, ...n];
|
|
2977
|
-
}, [u, v]), S =
|
|
3037
|
+
}, [u, v]), S = $o({
|
|
2978
3038
|
open: r,
|
|
2979
3039
|
portalContainer: e.portalContainer,
|
|
2980
3040
|
editorWrapper: e.collisionBoundary,
|
|
2981
3041
|
horizontalAlign: "end",
|
|
2982
3042
|
offsetY: 6,
|
|
2983
|
-
fallbackWidth:
|
|
2984
|
-
fallbackHeight:
|
|
3043
|
+
fallbackWidth: os,
|
|
3044
|
+
fallbackHeight: ss,
|
|
2985
3045
|
onOutside: () => l(!1)
|
|
2986
3046
|
}), C = (e) => e instanceof HTMLElement ? e.closest("input, textarea, [contenteditable]:not([contenteditable=\"false\"])") !== null : !1, w = (e) => {
|
|
2987
3047
|
C(e.target) || e.preventDefault();
|
|
@@ -3031,7 +3091,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3031
3091
|
size: 14,
|
|
3032
3092
|
strokeWidth: 2,
|
|
3033
3093
|
"aria-hidden": "true"
|
|
3034
|
-
}))), n(
|
|
3094
|
+
}))), n(es, {
|
|
3035
3095
|
panel: S,
|
|
3036
3096
|
portalContainer: e.portalContainer,
|
|
3037
3097
|
className: "zt-md-code-language-picker-panel",
|
|
@@ -3076,13 +3136,13 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3076
3136
|
strokeWidth: 2,
|
|
3077
3137
|
"aria-hidden": "true"
|
|
3078
3138
|
}) : null)) : n("div", { className: "zt-md-code-language-picker-empty" }, "-"))));
|
|
3079
|
-
},
|
|
3139
|
+
}, ms = class {
|
|
3080
3140
|
constructor(e, t, n) {
|
|
3081
|
-
this.isAttached = !1, this.currentCodeBlockPosition = null, this.currentPreElement = null, this.currentActionsContainer = null, this.currentRenderedLanguage = null, this.hasPositionContext = !1, this.repositionScheduler =
|
|
3141
|
+
this.isAttached = !1, this.currentCodeBlockPosition = null, this.currentPreElement = null, this.currentActionsContainer = null, this.currentRenderedLanguage = null, this.hasPositionContext = !1, this.repositionScheduler = Zo(() => {
|
|
3082
3142
|
this.hasPositionContext && this.updateOverlayPosition();
|
|
3083
3143
|
}), this.handlePickerLayoutChange = () => {
|
|
3084
3144
|
this.hasPositionContext && this.updateOverlayPosition();
|
|
3085
|
-
}, this.view = e, this.messages = t, this.portalContainer = n, this.editorWrapper =
|
|
3145
|
+
}, this.view = e, this.messages = t, this.portalContainer = n, this.editorWrapper = Go(e.dom), this.host = document.createElement("span"), this.host.className = "zt-md-code-language-picker-host", this.hostRoot = yt(this.host), this.update(e), this.stopObservingMessages = G(t, () => {
|
|
3086
3146
|
let e = this.currentRenderedLanguage;
|
|
3087
3147
|
this.currentRenderedLanguage = null, e !== null && this.render(e);
|
|
3088
3148
|
});
|
|
@@ -3090,7 +3150,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3090
3150
|
applyLanguage(e) {
|
|
3091
3151
|
if (this.currentCodeBlockPosition === null) return;
|
|
3092
3152
|
let t = this.view.state.doc.nodeAt(this.currentCodeBlockPosition);
|
|
3093
|
-
if (!t || t.type.name !==
|
|
3153
|
+
if (!t || t.type.name !== ts) return;
|
|
3094
3154
|
let n = Y(e), r = {
|
|
3095
3155
|
...t.attrs,
|
|
3096
3156
|
language: n
|
|
@@ -3100,7 +3160,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3100
3160
|
this.view.dispatch(i), this.view.focus();
|
|
3101
3161
|
}
|
|
3102
3162
|
render(e) {
|
|
3103
|
-
this.currentRenderedLanguage !== null && this.currentRenderedLanguage === e || (this.hostRoot.render(n(
|
|
3163
|
+
this.currentRenderedLanguage !== null && this.currentRenderedLanguage === e || (this.hostRoot.render(n(ps, {
|
|
3104
3164
|
currentLanguage: e,
|
|
3105
3165
|
messages: { ...this.messages },
|
|
3106
3166
|
portalContainer: this.portalContainer,
|
|
@@ -3117,14 +3177,14 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3117
3177
|
}
|
|
3118
3178
|
updateOverlayPosition() {
|
|
3119
3179
|
if (!this.editorWrapper || !this.currentPreElement || this.host.parentElement !== this.portalContainer) return;
|
|
3120
|
-
let e = this.editorWrapper.getBoundingClientRect(), t = this.currentPreElement.getBoundingClientRect(), n =
|
|
3180
|
+
let e = this.editorWrapper.getBoundingClientRect(), t = this.currentPreElement.getBoundingClientRect(), n = qo(t, this.editorWrapper, e), r = n.anchorRightInContent ?? n.anchorLeftInContent + t.width, i = Math.max(0, Math.min(t.width, this.editorWrapper.clientWidth) - rs * 2);
|
|
3121
3181
|
this.host.style.setProperty("--zt-md-code-language-picker-max-width", `${i}px`);
|
|
3122
|
-
let a = this.host.offsetWidth || Math.min(
|
|
3182
|
+
let a = this.host.offsetWidth || Math.min(is, i), o = this.host.offsetHeight || as, s = Xo({
|
|
3123
3183
|
wrapper: this.editorWrapper,
|
|
3124
3184
|
anchor: {
|
|
3125
|
-
anchorLeftInContent: r - a -
|
|
3126
|
-
anchorTopInContent: n.anchorTopInContent + t.height - o -
|
|
3127
|
-
anchorBottomInContent: n.anchorTopInContent + t.height - o -
|
|
3185
|
+
anchorLeftInContent: r - a - rs,
|
|
3186
|
+
anchorTopInContent: n.anchorTopInContent + t.height - o - rs,
|
|
3187
|
+
anchorBottomInContent: n.anchorTopInContent + t.height - o - rs
|
|
3128
3188
|
},
|
|
3129
3189
|
overlaySize: { width: a },
|
|
3130
3190
|
placement: "top",
|
|
@@ -3135,16 +3195,16 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3135
3195
|
}
|
|
3136
3196
|
update(e) {
|
|
3137
3197
|
if (this.view = e, e.composing) return;
|
|
3138
|
-
if (!
|
|
3198
|
+
if (!fs(e) || !this.editorWrapper) {
|
|
3139
3199
|
this.detach();
|
|
3140
3200
|
return;
|
|
3141
3201
|
}
|
|
3142
|
-
let t =
|
|
3202
|
+
let t = us(e);
|
|
3143
3203
|
if (!t) {
|
|
3144
3204
|
this.detach();
|
|
3145
3205
|
return;
|
|
3146
3206
|
}
|
|
3147
|
-
let n =
|
|
3207
|
+
let n = ds(e, t.position);
|
|
3148
3208
|
if (!n) {
|
|
3149
3209
|
this.detach();
|
|
3150
3210
|
return;
|
|
@@ -3159,13 +3219,13 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3159
3219
|
destroy() {
|
|
3160
3220
|
this.stopObservingMessages(), this.detach(), this.repositionScheduler.destroy(), this.hostRoot.unmount();
|
|
3161
3221
|
}
|
|
3162
|
-
},
|
|
3163
|
-
key: new R(
|
|
3164
|
-
view: (n) => new
|
|
3165
|
-
})),
|
|
3222
|
+
}, hs = (e, t) => V(() => new L({
|
|
3223
|
+
key: new R(ns),
|
|
3224
|
+
view: (n) => new ms(n, e, t)
|
|
3225
|
+
})), gs = new Set(["code_block", "frontmatter"]), _s = "a", vs = "zt-md-code-block-mod-a-select", ys = (e) => e.key.toLowerCase() !== _s || e.defaultPrevented || e.altKey || e.shiftKey || !e.ctrlKey && !e.metaKey, bs = (e) => {
|
|
3166
3226
|
for (let t = e.depth; t >= 0; --t) {
|
|
3167
3227
|
let n = e.node(t);
|
|
3168
|
-
if (!
|
|
3228
|
+
if (!gs.has(n.type.name)) continue;
|
|
3169
3229
|
let r = t === 0 ? 0 : e.before(t);
|
|
3170
3230
|
return {
|
|
3171
3231
|
codeBlockStart: r + 1,
|
|
@@ -3173,15 +3233,15 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3173
3233
|
};
|
|
3174
3234
|
}
|
|
3175
3235
|
return null;
|
|
3176
|
-
},
|
|
3177
|
-
let n = e.state.selection.$from, r =
|
|
3236
|
+
}, xs = (e, t) => {
|
|
3237
|
+
let n = e.state.selection.$from, r = bs(n);
|
|
3178
3238
|
if (!r) return !1;
|
|
3179
3239
|
let i = e.state.tr.setSelection(z.create(e.state.doc, r.codeBlockStart, r.codeBlockEnd));
|
|
3180
3240
|
return t.preventDefault(), e.dispatch(i), !0;
|
|
3181
|
-
},
|
|
3182
|
-
key: new R(
|
|
3183
|
-
props: { handleKeyDown: (e, t) =>
|
|
3184
|
-
})),
|
|
3241
|
+
}, Ss = V(() => new L({
|
|
3242
|
+
key: new R(vs),
|
|
3243
|
+
props: { handleKeyDown: (e, t) => ys(t) ? !1 : xs(e, t) }
|
|
3244
|
+
})), Cs = "frontmatter", ws = ["yaml", "toml"], Ts = (e) => e === "toml" ? "toml" : "yaml", Es = [pt("remarkFrontmatter", () => Tt, [...ws]), ft(Cs, () => ({
|
|
3185
3245
|
content: "text*",
|
|
3186
3246
|
group: "block",
|
|
3187
3247
|
marks: "",
|
|
@@ -3193,48 +3253,48 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3193
3253
|
validate: "string"
|
|
3194
3254
|
} },
|
|
3195
3255
|
parseDOM: [{
|
|
3196
|
-
tag: `pre[data-type="${
|
|
3256
|
+
tag: `pre[data-type="${Cs}"]`,
|
|
3197
3257
|
preserveWhitespace: "full",
|
|
3198
|
-
getAttrs: (e) => ({ format:
|
|
3258
|
+
getAttrs: (e) => ({ format: Ts(e.dataset.format) })
|
|
3199
3259
|
}],
|
|
3200
3260
|
toDOM: (e) => [
|
|
3201
3261
|
"pre",
|
|
3202
3262
|
{
|
|
3203
|
-
"data-type":
|
|
3204
|
-
"data-format":
|
|
3263
|
+
"data-type": Cs,
|
|
3264
|
+
"data-format": Ts(e.attrs.format)
|
|
3205
3265
|
},
|
|
3206
3266
|
["code", 0]
|
|
3207
3267
|
],
|
|
3208
3268
|
parseMarkdown: {
|
|
3209
3269
|
match: (e) => e.type === "yaml" || e.type === "toml",
|
|
3210
3270
|
runner: (e, t, n) => {
|
|
3211
|
-
let r =
|
|
3271
|
+
let r = Ts(t.type), i = typeof t.value == "string" ? t.value : "";
|
|
3212
3272
|
e.openNode(n, { format: r }), i && e.addText(i), e.closeNode();
|
|
3213
3273
|
}
|
|
3214
3274
|
},
|
|
3215
3275
|
toMarkdown: {
|
|
3216
|
-
match: (e) => e.type.name ===
|
|
3276
|
+
match: (e) => e.type.name === Cs,
|
|
3217
3277
|
runner: (e, t) => {
|
|
3218
|
-
let n =
|
|
3278
|
+
let n = Ts(t.attrs.format);
|
|
3219
3279
|
e.addNode(n, void 0, t.textContent);
|
|
3220
3280
|
}
|
|
3221
3281
|
}
|
|
3222
|
-
}))].flat(),
|
|
3282
|
+
}))].flat(), Ds = 1200, Os = {
|
|
3223
3283
|
yaml: "frontmatterYamlLabel",
|
|
3224
3284
|
toml: "frontmatterTomlLabel"
|
|
3225
|
-
},
|
|
3285
|
+
}, ks = q("ChevronDown", {
|
|
3226
3286
|
size: 14,
|
|
3227
3287
|
strokeWidth: 2
|
|
3228
|
-
}),
|
|
3288
|
+
}), As = q("Copy", {
|
|
3229
3289
|
size: 14,
|
|
3230
3290
|
strokeWidth: 2
|
|
3231
|
-
}),
|
|
3291
|
+
}), js = q("Check", {
|
|
3232
3292
|
size: 14,
|
|
3233
3293
|
strokeWidth: 2
|
|
3234
|
-
}),
|
|
3294
|
+
}), Ms = q("Trash2", {
|
|
3235
3295
|
size: 14,
|
|
3236
3296
|
strokeWidth: 2
|
|
3237
|
-
}),
|
|
3297
|
+
}), Ns = (e) => typeof e == "function" ? e() : null, Ps = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, Fs = class {
|
|
3238
3298
|
constructor(e, t, n, r) {
|
|
3239
3299
|
this.isCollapsed = !1, this.copyFeedbackTimer = null, this.handleToggleClick = (e) => {
|
|
3240
3300
|
e.preventDefault(), e.stopPropagation(), this.isCollapsed = !this.isCollapsed, this.syncCollapsedState(), this.syncLocalizedLabels();
|
|
@@ -3242,13 +3302,13 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3242
3302
|
e.preventDefault(), e.stopPropagation();
|
|
3243
3303
|
let t = this.node.textContent;
|
|
3244
3304
|
(typeof navigator < "u" && navigator.clipboard?.writeText ? navigator.clipboard.writeText(t) : Promise.resolve()).then(() => {
|
|
3245
|
-
this.copyButton.innerHTML =
|
|
3246
|
-
this.copyButton.innerHTML =
|
|
3247
|
-
},
|
|
3305
|
+
this.copyButton.innerHTML = js, this.copyButton.dataset.copied = "true", this.copyFeedbackTimer !== null && clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = setTimeout(() => {
|
|
3306
|
+
this.copyButton.innerHTML = As, delete this.copyButton.dataset.copied, this.copyFeedbackTimer = null;
|
|
3307
|
+
}, Ds);
|
|
3248
3308
|
}).catch(() => {});
|
|
3249
3309
|
}, this.handleDeleteClick = (e) => {
|
|
3250
|
-
if (e.preventDefault(), e.stopPropagation(), !
|
|
3251
|
-
let t =
|
|
3310
|
+
if (e.preventDefault(), e.stopPropagation(), !Ps(this.view)) return;
|
|
3311
|
+
let t = Ns(this.getPos);
|
|
3252
3312
|
if (t === null) return;
|
|
3253
3313
|
let n = t + this.node.nodeSize, r = t === 0 && n === this.view.state.doc.content.size, i = this.view.state.schema.nodes.paragraph, a = r ? i?.createAndFill() : null;
|
|
3254
3314
|
if (a) {
|
|
@@ -3258,23 +3318,23 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3258
3318
|
}
|
|
3259
3319
|
let o = this.view.state.tr.delete(t, n), s = Math.min(t, o.doc.content.size);
|
|
3260
3320
|
o.setSelection(z.near(o.doc.resolve(s), 1)).scrollIntoView(), this.view.dispatch(o), this.view.focus();
|
|
3261
|
-
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("div"), this.dom.className = "zt-md-frontmatter", this.dom.dataset.type =
|
|
3321
|
+
}, this.node = e, this.view = t, this.getPos = n, this.messages = r, this.dom = document.createElement("div"), this.dom.className = "zt-md-frontmatter", this.dom.dataset.type = Cs, this.headerContainer = document.createElement("div"), this.headerContainer.className = "zt-md-frontmatter-header", this.headerContainer.contentEditable = "false", this.toggleButton = document.createElement("button"), this.toggleButton.type = "button", this.toggleButton.className = "zt-md-frontmatter-toggle", this.chevronIcon = document.createElement("span"), this.chevronIcon.className = "zt-md-frontmatter-chevron", this.chevronIcon.innerHTML = ks, this.titleSpan = document.createElement("span"), this.titleSpan.className = "zt-md-frontmatter-title", this.toggleButton.append(this.chevronIcon, this.titleSpan), this.actionsContainer = document.createElement("span"), this.actionsContainer.className = "zt-md-frontmatter-actions", this.copyButton = document.createElement("button"), this.copyButton.type = "button", this.copyButton.className = "zt-md-frontmatter-action-button", this.copyButton.innerHTML = As, this.deleteButton = document.createElement("button"), this.deleteButton.type = "button", this.deleteButton.className = "zt-md-frontmatter-action-button zt-md-frontmatter-editable-action zt-md-frontmatter-action-button-danger", this.deleteButton.innerHTML = Ms, this.actionsContainer.append(this.copyButton, this.deleteButton), this.headerContainer.append(this.toggleButton, this.actionsContainer), this.contentDOM = document.createElement("pre"), this.contentDOM.className = "zt-md-frontmatter-body", this.dom.append(this.headerContainer, this.contentDOM), this.syncFormatState(e), this.syncEditableState(), this.syncCollapsedState(), this.syncLocalizedLabels(), this.toggleButton.addEventListener("click", this.handleToggleClick), this.copyButton.addEventListener("click", this.handleCopyClick), this.deleteButton.addEventListener("click", this.handleDeleteClick), this.stopObservingMessages = G(r, () => {
|
|
3262
3322
|
this.syncLocalizedLabels();
|
|
3263
3323
|
});
|
|
3264
3324
|
}
|
|
3265
3325
|
syncFormatState(e) {
|
|
3266
|
-
let t =
|
|
3267
|
-
this.dom.dataset.format = t, this.titleSpan.textContent = this.messages[
|
|
3326
|
+
let t = Ts(e.attrs.format);
|
|
3327
|
+
this.dom.dataset.format = t, this.titleSpan.textContent = this.messages[Os[t]];
|
|
3268
3328
|
}
|
|
3269
3329
|
syncEditableState() {
|
|
3270
|
-
this.dom.dataset.editable =
|
|
3330
|
+
this.dom.dataset.editable = Ps(this.view) ? "true" : "false";
|
|
3271
3331
|
}
|
|
3272
3332
|
syncCollapsedState() {
|
|
3273
3333
|
this.dom.dataset.collapsed = this.isCollapsed ? "true" : "false", this.toggleButton.setAttribute("aria-expanded", String(!this.isCollapsed)), this.contentDOM.hidden = this.isCollapsed, this.contentDOM.setAttribute("aria-hidden", String(this.isCollapsed));
|
|
3274
3334
|
}
|
|
3275
3335
|
syncLocalizedLabels() {
|
|
3276
|
-
let e =
|
|
3277
|
-
this.titleSpan.textContent = this.messages[
|
|
3336
|
+
let e = Ts(this.node.attrs.format);
|
|
3337
|
+
this.titleSpan.textContent = this.messages[Os[e]];
|
|
3278
3338
|
let t = this.isCollapsed ? this.messages.frontmatterExpandAriaLabel : this.messages.frontmatterCollapseAriaLabel;
|
|
3279
3339
|
this.toggleButton.setAttribute("aria-label", t), this.toggleButton.title = t, this.copyButton.setAttribute("aria-label", this.messages.frontmatterCopyAriaLabel), this.copyButton.title = this.messages.frontmatterCopyAriaLabel, this.deleteButton.setAttribute("aria-label", this.messages.frontmatterDeleteAriaLabel), this.deleteButton.title = this.messages.frontmatterDeleteAriaLabel;
|
|
3280
3340
|
}
|
|
@@ -3291,10 +3351,10 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3291
3351
|
destroy() {
|
|
3292
3352
|
this.stopObservingMessages(), this.toggleButton.removeEventListener("click", this.handleToggleClick), this.copyButton.removeEventListener("click", this.handleCopyClick), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.copyFeedbackTimer !== null && (clearTimeout(this.copyFeedbackTimer), this.copyFeedbackTimer = null);
|
|
3293
3353
|
}
|
|
3294
|
-
},
|
|
3354
|
+
}, Is = (e = W()) => (t, n, r) => new Fs(t, n, typeof r == "function" ? () => {
|
|
3295
3355
|
let e = r();
|
|
3296
3356
|
return typeof e == "number" ? e : 0;
|
|
3297
|
-
} : !1, e),
|
|
3357
|
+
} : !1, e), Ls = (e, t) => e(t.state, t.dispatch, t), Rs = (e, t) => {
|
|
3298
3358
|
let n = e?.state?.selection?.$from;
|
|
3299
3359
|
if (!n || !e?.dispatch) return !1;
|
|
3300
3360
|
for (let r = n.depth; r > 0; --r) {
|
|
@@ -3308,17 +3368,17 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3308
3368
|
})), !0;
|
|
3309
3369
|
}
|
|
3310
3370
|
return !1;
|
|
3311
|
-
},
|
|
3371
|
+
}, zs = {
|
|
3312
3372
|
heading1: 1,
|
|
3313
3373
|
heading2: 2,
|
|
3314
3374
|
heading3: 3,
|
|
3315
3375
|
heading4: 4,
|
|
3316
3376
|
heading5: 5,
|
|
3317
3377
|
heading6: 6
|
|
3318
|
-
},
|
|
3378
|
+
}, Bs = {
|
|
3319
3379
|
bulletList: "bullet_list",
|
|
3320
3380
|
orderedList: "ordered_list"
|
|
3321
|
-
},
|
|
3381
|
+
}, Vs = [
|
|
3322
3382
|
"codeBlock",
|
|
3323
3383
|
"heading1",
|
|
3324
3384
|
"heading2",
|
|
@@ -3331,35 +3391,35 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3331
3391
|
"bulletList",
|
|
3332
3392
|
"blockquote",
|
|
3333
3393
|
"paragraph"
|
|
3334
|
-
],
|
|
3394
|
+
], Hs = (e, t) => {
|
|
3335
3395
|
if (!e?.state || !e?.dispatch) return !1;
|
|
3336
3396
|
let n = e.state.schema.nodes;
|
|
3337
3397
|
if (t === "paragraph") {
|
|
3338
3398
|
let t = n.paragraph;
|
|
3339
|
-
return t ?
|
|
3399
|
+
return t ? Ls(Dt(t), e) : !1;
|
|
3340
3400
|
}
|
|
3341
|
-
if (t in
|
|
3342
|
-
let r = n.heading, i =
|
|
3343
|
-
return !r || typeof i != "number" ? !1 :
|
|
3401
|
+
if (t in zs) {
|
|
3402
|
+
let r = n.heading, i = zs[t];
|
|
3403
|
+
return !r || typeof i != "number" ? !1 : Ls(Dt(r, { level: i }), e);
|
|
3344
3404
|
}
|
|
3345
3405
|
if (t === "blockquote") {
|
|
3346
3406
|
let t = n.blockquote;
|
|
3347
|
-
return t ?
|
|
3407
|
+
return t ? Ls(kt(t), e) : !1;
|
|
3348
3408
|
}
|
|
3349
3409
|
if (t === "taskList") {
|
|
3350
3410
|
let t = n.bullet_list;
|
|
3351
|
-
return !t || !
|
|
3411
|
+
return !t || !Ls(Mt(t), e) ? !1 : Rs(e, !1);
|
|
3352
3412
|
}
|
|
3353
3413
|
if (t === "codeBlock") {
|
|
3354
3414
|
let t = n.code_block;
|
|
3355
|
-
return t ?
|
|
3415
|
+
return t ? Ls(Dt(t, { language: "text" }), e) : !1;
|
|
3356
3416
|
}
|
|
3357
|
-
if (t in
|
|
3358
|
-
let r = n[
|
|
3359
|
-
return r ?
|
|
3417
|
+
if (t in Bs) {
|
|
3418
|
+
let r = n[Bs[t]];
|
|
3419
|
+
return r ? Ls(Mt(r), e) : !1;
|
|
3360
3420
|
}
|
|
3361
3421
|
return !1;
|
|
3362
|
-
},
|
|
3422
|
+
}, Us = (e) => {
|
|
3363
3423
|
let t = e.state.selection.$from, n = /* @__PURE__ */ new Set();
|
|
3364
3424
|
for (let e = t.depth; e > 0; --e) {
|
|
3365
3425
|
let r = t.node(e), i = r.type.name;
|
|
@@ -3398,10 +3458,10 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3398
3458
|
i === "paragraph" && n.add("paragraph");
|
|
3399
3459
|
}
|
|
3400
3460
|
return n.has("taskList") && n.delete("bulletList"), n.size === 0 && n.add("paragraph"), n;
|
|
3401
|
-
},
|
|
3402
|
-
let t =
|
|
3403
|
-
return
|
|
3404
|
-
},
|
|
3461
|
+
}, Ws = (e) => {
|
|
3462
|
+
let t = Us(e);
|
|
3463
|
+
return Vs.find((e) => t.has(e)) || "paragraph";
|
|
3464
|
+
}, Gs = /Mac|iPhone|iPad|iPod/, Ks = {
|
|
3405
3465
|
paragraph: {
|
|
3406
3466
|
key: "p",
|
|
3407
3467
|
code: "KeyP",
|
|
@@ -3474,25 +3534,25 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3474
3534
|
key: "i",
|
|
3475
3535
|
code: "KeyI"
|
|
3476
3536
|
}
|
|
3477
|
-
},
|
|
3537
|
+
}, qs = (e) => Object.fromEntries(Object.entries(Ks).map(([t, n]) => [t, n.modeOverrides?.[e] ?? n])), Js = {
|
|
3478
3538
|
Mod: "Ctrl",
|
|
3479
3539
|
Alt: "Alt",
|
|
3480
3540
|
Shift: "Shift"
|
|
3481
|
-
},
|
|
3541
|
+
}, Ys = {
|
|
3482
3542
|
Mod: "⌘",
|
|
3483
3543
|
Alt: "⌥",
|
|
3484
3544
|
Shift: "⇧"
|
|
3485
|
-
},
|
|
3486
|
-
let t = e === "modAlt" ? "Mod-Alt" : "Mod-Shift", n =
|
|
3545
|
+
}, Xs = () => typeof navigator < "u" && Gs.test(navigator.platform), Zs = (e) => {
|
|
3546
|
+
let t = e === "modAlt" ? "Mod-Alt" : "Mod-Shift", n = qs(e);
|
|
3487
3547
|
return Object.fromEntries(Object.entries(n).map(([e, n]) => [e, `${t}-${n.key}`]));
|
|
3488
|
-
}, Xs = (e) => {
|
|
3489
|
-
let t = Js(), n = t ? qs : Ks;
|
|
3490
|
-
return e.split("-").map((e) => n[e] ?? e.toUpperCase()).join(t ? "" : "+");
|
|
3491
|
-
}, Zs = (e) => {
|
|
3492
|
-
let t = Ys(e);
|
|
3493
|
-
return Object.fromEntries(Object.entries(t).map(([e, t]) => [e, Xs(t)]));
|
|
3494
3548
|
}, Qs = (e) => {
|
|
3549
|
+
let t = Xs(), n = t ? Ys : Js;
|
|
3550
|
+
return e.split("-").map((e) => n[e] ?? e.toUpperCase()).join(t ? "" : "+");
|
|
3551
|
+
}, $s = (e) => {
|
|
3495
3552
|
let t = Zs(e);
|
|
3553
|
+
return Object.fromEntries(Object.entries(t).map(([e, t]) => [e, Qs(t)]));
|
|
3554
|
+
}, ec = (e) => {
|
|
3555
|
+
let t = $s(e);
|
|
3496
3556
|
return {
|
|
3497
3557
|
paragraph: t.paragraph,
|
|
3498
3558
|
heading1: t.heading1,
|
|
@@ -3507,8 +3567,8 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3507
3567
|
blockquote: t.blockquote,
|
|
3508
3568
|
codeBlock: t.codeBlock
|
|
3509
3569
|
};
|
|
3510
|
-
},
|
|
3511
|
-
let n =
|
|
3570
|
+
}, tc = (e, t) => {
|
|
3571
|
+
let n = Zs(t);
|
|
3512
3572
|
e.update(Ue.key, (e) => ({
|
|
3513
3573
|
...e,
|
|
3514
3574
|
TurnIntoText: {
|
|
@@ -3572,13 +3632,13 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3572
3632
|
shortcuts: n.inlineCode
|
|
3573
3633
|
}
|
|
3574
3634
|
}));
|
|
3575
|
-
},
|
|
3576
|
-
let t =
|
|
3635
|
+
}, nc = (e) => {
|
|
3636
|
+
let t = Zs(e).taskList;
|
|
3577
3637
|
return mt("taskListTransform", { WrapInTaskList: {
|
|
3578
3638
|
shortcuts: t,
|
|
3579
|
-
command: () => (e, t, n) => n ?
|
|
3639
|
+
command: () => (e, t, n) => n ? Hs(n, "taskList") : !1
|
|
3580
3640
|
} });
|
|
3581
|
-
},
|
|
3641
|
+
}, rc = "zt-md-selection-tooltip", ic = (e) => [
|
|
3582
3642
|
{
|
|
3583
3643
|
command: "strong",
|
|
3584
3644
|
iconName: "Bold",
|
|
@@ -3622,8 +3682,8 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3622
3682
|
taskList: M,
|
|
3623
3683
|
blockquote: se,
|
|
3624
3684
|
codeBlock: w
|
|
3625
|
-
},
|
|
3626
|
-
let n =
|
|
3685
|
+
}, ac = (e, t) => {
|
|
3686
|
+
let n = ec(t);
|
|
3627
3687
|
return [
|
|
3628
3688
|
{
|
|
3629
3689
|
command: "paragraph",
|
|
@@ -3698,31 +3758,31 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3698
3758
|
shortcut: n.codeBlock
|
|
3699
3759
|
}
|
|
3700
3760
|
];
|
|
3701
|
-
},
|
|
3761
|
+
}, oc = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, Z = (e, t) => {
|
|
3702
3762
|
let n = e.state.schema.marks, r = t.find((e) => n[e]);
|
|
3703
3763
|
return r ? n[r] ?? null : null;
|
|
3704
|
-
},
|
|
3764
|
+
}, sc = (e, t) => {
|
|
3705
3765
|
let { from: n, to: r } = e.selection;
|
|
3706
3766
|
return e.doc.rangeHasMark(n, r, t);
|
|
3707
|
-
},
|
|
3767
|
+
}, cc = (e, t) => {
|
|
3708
3768
|
let { from: n, to: r } = e.selection, i = "";
|
|
3709
3769
|
return e.doc.nodesBetween(n, r, (e) => {
|
|
3710
3770
|
let n = e.marks.find((e) => e.type === t);
|
|
3711
3771
|
return n ? (i = typeof n.attrs.href == "string" ? n.attrs.href : "", !1) : !0;
|
|
3712
3772
|
}), i;
|
|
3713
|
-
},
|
|
3773
|
+
}, lc = (e) => {
|
|
3714
3774
|
Ot(e.markType)(e.view.state, e.view.dispatch, e.view), e.view.focus();
|
|
3715
|
-
},
|
|
3775
|
+
}, uc = (e) => {
|
|
3716
3776
|
e.toggleLinkPopover(e.view);
|
|
3717
|
-
},
|
|
3777
|
+
}, dc = (e, t) => {
|
|
3718
3778
|
({
|
|
3719
|
-
strong:
|
|
3720
|
-
em:
|
|
3721
|
-
strike:
|
|
3722
|
-
inlineCode:
|
|
3723
|
-
link:
|
|
3779
|
+
strong: lc,
|
|
3780
|
+
em: lc,
|
|
3781
|
+
strike: lc,
|
|
3782
|
+
inlineCode: lc,
|
|
3783
|
+
link: uc
|
|
3724
3784
|
})[e](t);
|
|
3725
|
-
},
|
|
3785
|
+
}, fc = (e, t, n, r) => {
|
|
3726
3786
|
let i = document.createElement("button");
|
|
3727
3787
|
i.type = "button", i.className = "zt-md-selection-tooltip-button", i.dataset.command = e.command, i.title = e.title, i.setAttribute("aria-label", e.title);
|
|
3728
3788
|
let a = document.createElement("span");
|
|
@@ -3734,20 +3794,20 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3734
3794
|
}), i.addEventListener("click", (i) => {
|
|
3735
3795
|
i.preventDefault();
|
|
3736
3796
|
let a = n();
|
|
3737
|
-
!a || a.state.selection.empty ||
|
|
3797
|
+
!a || a.state.selection.empty || dc(e.command, {
|
|
3738
3798
|
view: a,
|
|
3739
3799
|
markType: t,
|
|
3740
3800
|
toggleLinkPopover: r
|
|
3741
3801
|
});
|
|
3742
3802
|
}), i;
|
|
3743
|
-
},
|
|
3803
|
+
}, pc = (e, t, n, r, i) => {
|
|
3744
3804
|
let a = document.createElement("div");
|
|
3745
3805
|
return a.className = "zt-md-selection-tooltip", a.append(i), t.forEach((t) => {
|
|
3746
3806
|
let i = Z(e, t.markNames);
|
|
3747
|
-
i && t.command !== "link" && a.append(
|
|
3807
|
+
i && t.command !== "link" && a.append(fc(t, i, n, r));
|
|
3748
3808
|
}), a;
|
|
3749
|
-
},
|
|
3750
|
-
let r =
|
|
3809
|
+
}, mc = (e) => {
|
|
3810
|
+
let r = $o({
|
|
3751
3811
|
open: e.open,
|
|
3752
3812
|
portalContainer: e.portalContainer,
|
|
3753
3813
|
editorWrapper: e.collisionBoundary,
|
|
@@ -3763,7 +3823,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3763
3823
|
e.onOpenChange(!1);
|
|
3764
3824
|
return;
|
|
3765
3825
|
}
|
|
3766
|
-
|
|
3826
|
+
Hs(n, t), e.onOpenChange(!1), n.focus();
|
|
3767
3827
|
};
|
|
3768
3828
|
return n(t, null, n("button", {
|
|
3769
3829
|
ref: r.triggerRef,
|
|
@@ -3784,7 +3844,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3784
3844
|
size: e.iconSize,
|
|
3785
3845
|
strokeWidth: e.iconStrokeWidth,
|
|
3786
3846
|
"aria-hidden": "true"
|
|
3787
|
-
})), n(
|
|
3847
|
+
})), n(es, {
|
|
3788
3848
|
panel: r,
|
|
3789
3849
|
portalContainer: e.portalContainer,
|
|
3790
3850
|
className: "zt-md-selection-transform-popover !w-[224px] p-1",
|
|
@@ -3805,7 +3865,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3805
3865
|
"aria-hidden": "true"
|
|
3806
3866
|
}), n("span", { className: "zt-md-selection-transform-item-label" }, t.label), n("kbd", { className: "zt-md-selection-transform-item-shortcut" }, t.shortcut));
|
|
3807
3867
|
}))));
|
|
3808
|
-
},
|
|
3868
|
+
}, hc = (e) => {
|
|
3809
3869
|
let [r, a] = c(""), o = s(null), l = (e) => {
|
|
3810
3870
|
e.preventDefault();
|
|
3811
3871
|
}, u = (t) => {
|
|
@@ -3819,7 +3879,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3819
3879
|
e.onOpenChange(!1);
|
|
3820
3880
|
return;
|
|
3821
3881
|
}
|
|
3822
|
-
let i =
|
|
3882
|
+
let i = Tr(t), { from: a, to: o } = n.state.selection, s = n.state.tr.removeMark(a, o, r);
|
|
3823
3883
|
i && s.addMark(a, o, r.create({ href: i })), n.dispatch(s.scrollIntoView()), e.onOpenChange(!1), n.focus();
|
|
3824
3884
|
}, d = (t) => {
|
|
3825
3885
|
if (!t) {
|
|
@@ -3831,8 +3891,8 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3831
3891
|
e.onOpenChange(!1);
|
|
3832
3892
|
return;
|
|
3833
3893
|
}
|
|
3834
|
-
a(
|
|
3835
|
-
}, f =
|
|
3894
|
+
a(Tr(cc(n.state, r))), e.onOpenChange(!0);
|
|
3895
|
+
}, f = $o({
|
|
3836
3896
|
open: e.open,
|
|
3837
3897
|
portalContainer: e.portalContainer,
|
|
3838
3898
|
editorWrapper: e.collisionBoundary,
|
|
@@ -3873,7 +3933,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3873
3933
|
}, n("span", { className: "zt-md-selection-tooltip-button-icon" }, n(re, {
|
|
3874
3934
|
size: e.iconSize,
|
|
3875
3935
|
strokeWidth: e.iconStrokeWidth
|
|
3876
|
-
}))), n(
|
|
3936
|
+
}))), n(es, {
|
|
3877
3937
|
panel: f,
|
|
3878
3938
|
portalContainer: e.portalContainer,
|
|
3879
3939
|
className: "zt-md-selection-link-popover w-fit min-w-0 gap-0 p-2"
|
|
@@ -3906,39 +3966,39 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3906
3966
|
size: e.iconSize,
|
|
3907
3967
|
strokeWidth: e.iconStrokeWidth
|
|
3908
3968
|
})))));
|
|
3909
|
-
},
|
|
3969
|
+
}, gc = (e, t, n) => {
|
|
3910
3970
|
n.forEach((n) => {
|
|
3911
3971
|
let r = Z(t, n.markNames);
|
|
3912
3972
|
if (!r) return;
|
|
3913
3973
|
let i = e.querySelector(`[data-command="${n.command}"]`);
|
|
3914
|
-
i instanceof HTMLButtonElement && (i.dataset.active =
|
|
3974
|
+
i instanceof HTMLButtonElement && (i.dataset.active = sc(t.state, r) ? "true" : "false");
|
|
3915
3975
|
});
|
|
3916
|
-
},
|
|
3976
|
+
}, _c = (e) => {
|
|
3917
3977
|
let { from: t, to: n } = e.state.selection, r = !1;
|
|
3918
3978
|
return e.state.doc.nodesBetween(t, n, (e) => e.type.name === "code_block" ? (r = !0, !1) : !0), r;
|
|
3919
|
-
},
|
|
3979
|
+
}, vc = (e, t, n) => (r) => {
|
|
3920
3980
|
let { selection: i, doc: a } = r.state, o = e.contains(document.activeElement);
|
|
3921
|
-
return !
|
|
3922
|
-
},
|
|
3981
|
+
return !oc(r) || i.empty || !(i instanceof z) || !r.hasFocus() && !o && !t() && !n() || _c(r) ? !1 : e.childElementCount > 0 && a.textBetween(i.from, i.to).trim().length > 0;
|
|
3982
|
+
}, yc = (e) => {
|
|
3923
3983
|
let { $from: t } = e.state.selection;
|
|
3924
3984
|
for (let e = t.depth; e > 0; --e) {
|
|
3925
3985
|
let n = t.node(e).type.name;
|
|
3926
3986
|
if (n === "table" || n === "table_cell" || n === "table_header") return !0;
|
|
3927
3987
|
}
|
|
3928
3988
|
return !1;
|
|
3929
|
-
},
|
|
3930
|
-
let a =
|
|
3989
|
+
}, bc = (e, t, r, i) => {
|
|
3990
|
+
let a = ic(r), o = ac(r, i), s = e, c = !1, l = !1, u = !1, d = 0, f = "", p = document.createElement("span"), m = yt(p), h = document.createElement("span"), g = null, _ = yt(h), v = t.closest(".zt-md-editor"), y = (e) => {
|
|
3931
3991
|
c !== e && (c = e, C());
|
|
3932
3992
|
}, b = (e) => {
|
|
3933
3993
|
l !== e && (l = e, S());
|
|
3934
3994
|
}, x = (e) => {
|
|
3935
3995
|
e.state.selection.empty || y(!c);
|
|
3936
3996
|
}, S = () => {
|
|
3937
|
-
let e = s ?
|
|
3997
|
+
let e = s ? Us(s) : new Set(["paragraph"]), i = s ? Ws(s) : "paragraph", a = `${d}:${i}:${l}:${Array.from(e).sort().join(",")}`;
|
|
3938
3998
|
if (f === a) return;
|
|
3939
3999
|
f = a;
|
|
3940
4000
|
let c = o.find((e) => e.command === i) ?? o[0];
|
|
3941
|
-
m.render(n(
|
|
4001
|
+
m.render(n(mc, {
|
|
3942
4002
|
getCurrentView: () => s,
|
|
3943
4003
|
portalContainer: t,
|
|
3944
4004
|
collisionBoundary: v,
|
|
@@ -3952,7 +4012,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3952
4012
|
activeCommands: e
|
|
3953
4013
|
}));
|
|
3954
4014
|
}, C = () => {
|
|
3955
|
-
_.render(n(
|
|
4015
|
+
_.render(n(hc, {
|
|
3956
4016
|
getCurrentView: () => s,
|
|
3957
4017
|
portalContainer: t,
|
|
3958
4018
|
collisionBoundary: v,
|
|
@@ -3965,9 +4025,9 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3965
4025
|
onOpenChange: y,
|
|
3966
4026
|
messages: r
|
|
3967
4027
|
}));
|
|
3968
|
-
}, w =
|
|
4028
|
+
}, w = pc(e, a, () => s, x, p);
|
|
3969
4029
|
S(), Z(e, ["link"]) && (w.append(h), C());
|
|
3970
|
-
let T =
|
|
4030
|
+
let T = vc(w, () => c, () => l), E = new Et({
|
|
3971
4031
|
content: w,
|
|
3972
4032
|
debounce: 80,
|
|
3973
4033
|
offset: 8,
|
|
@@ -3991,7 +4051,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
3991
4051
|
};
|
|
3992
4052
|
e.dom.addEventListener("blur", ee), document.addEventListener("mousedown", te, !0);
|
|
3993
4053
|
let ne = G(r, () => {
|
|
3994
|
-
d += 1, a =
|
|
4054
|
+
d += 1, a = ic(r), o = ac(r, i), a.forEach((e) => {
|
|
3995
4055
|
let t = w.querySelector(`[data-command="${e.command}"]`);
|
|
3996
4056
|
t && (t.title = e.title, t.setAttribute("aria-label", e.title));
|
|
3997
4057
|
}), S(), Z(e, ["link"]) && C();
|
|
@@ -4006,10 +4066,10 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4006
4066
|
E.hide(), O();
|
|
4007
4067
|
return;
|
|
4008
4068
|
}
|
|
4009
|
-
let n =
|
|
4010
|
-
if (p.hidden = n, n ? b(!1) : S(),
|
|
4069
|
+
let n = yc(s);
|
|
4070
|
+
if (p.hidden = n, n ? b(!1) : S(), gc(w, s, a), g) {
|
|
4011
4071
|
let e = Z(s, ["link"]);
|
|
4012
|
-
g.dataset.active = e &&
|
|
4072
|
+
g.dataset.active = e && sc(s.state, e) ? "true" : "false";
|
|
4013
4073
|
}
|
|
4014
4074
|
D(), E.update(s, t);
|
|
4015
4075
|
},
|
|
@@ -4017,21 +4077,21 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4017
4077
|
ne(), u = !0, s = null, e.dom.removeEventListener("blur", ee), document.removeEventListener("mousedown", te, !0), m.unmount(), _.unmount(), E.destroy(), w.remove();
|
|
4018
4078
|
}
|
|
4019
4079
|
};
|
|
4020
|
-
},
|
|
4021
|
-
key: new R(
|
|
4022
|
-
view: (r) =>
|
|
4023
|
-
})),
|
|
4080
|
+
}, xc = (e, t, n) => V(() => new L({
|
|
4081
|
+
key: new R(rc),
|
|
4082
|
+
view: (r) => bc(r, e, t, n)
|
|
4083
|
+
})), Sc = (e, t) => e(t.state, t.dispatch, t), Cc = (e) => {
|
|
4024
4084
|
let t = e?.state?.selection?.$from;
|
|
4025
4085
|
if (!t) return !1;
|
|
4026
4086
|
for (let e = t.depth; e > 0; --e) if (t.node(e)?.type?.name === "table") return !0;
|
|
4027
4087
|
return !1;
|
|
4028
|
-
},
|
|
4088
|
+
}, wc = (e, t) => {
|
|
4029
4089
|
let n = e?.state?.doc;
|
|
4030
4090
|
if (!n || typeof t != "number") return -1;
|
|
4031
4091
|
let r = Math.min(Math.max(t, 0), n.content.size), i = n.resolve(r);
|
|
4032
4092
|
for (let e = i.depth; e > 0; --e) if (i.node(e)?.type?.name === "table") return i.before(e);
|
|
4033
4093
|
return -1;
|
|
4034
|
-
},
|
|
4094
|
+
}, Tc = (e, t, n, r) => {
|
|
4035
4095
|
let i = e?.state?.schema?.nodes;
|
|
4036
4096
|
if (!i) return null;
|
|
4037
4097
|
let a = i.table, o = i.table_header_row, s = i.table_row, c = i.table_header, l = i.table_cell;
|
|
@@ -4041,21 +4101,21 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4041
4101
|
return i.create(null, u);
|
|
4042
4102
|
});
|
|
4043
4103
|
return a.create(null, f);
|
|
4044
|
-
},
|
|
4045
|
-
if (!e?.state || !e?.dispatch ||
|
|
4046
|
-
let t = e.state.selection.from, n =
|
|
4104
|
+
}, Ec = (e) => {
|
|
4105
|
+
if (!e?.state || !e?.dispatch || Cc(e)) return !1;
|
|
4106
|
+
let t = e.state.selection.from, n = Tc(e, 3, 3, !0);
|
|
4047
4107
|
if (!n) return !1;
|
|
4048
4108
|
e.dispatch(e.state.tr.replaceSelectionWith(n).scrollIntoView());
|
|
4049
|
-
let r =
|
|
4050
|
-
if (r < 0 && t > 0 && (r =
|
|
4109
|
+
let r = wc(e, t);
|
|
4110
|
+
if (r < 0 && t > 0 && (r = wc(e, t - 1)), r < 0) return !0;
|
|
4051
4111
|
let i = r + 2;
|
|
4052
4112
|
if (i > e.state.doc.content.size) return !0;
|
|
4053
4113
|
let a = z.near(e.state.doc.resolve(i), 1);
|
|
4054
4114
|
return e.dispatch(e.state.tr.setSelection(a).scrollIntoView()), e.focus(), !0;
|
|
4055
|
-
},
|
|
4115
|
+
}, Dc = (e, t) => {
|
|
4056
4116
|
let n = e?.state?.schema?.marks ?? {}, r = t.find((e) => n[e]);
|
|
4057
4117
|
return r ? n[r] ?? null : null;
|
|
4058
|
-
},
|
|
4118
|
+
}, Oc = new Set([
|
|
4059
4119
|
"paragraph",
|
|
4060
4120
|
"heading1",
|
|
4061
4121
|
"heading2",
|
|
@@ -4068,10 +4128,10 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4068
4128
|
"taskList",
|
|
4069
4129
|
"blockquote",
|
|
4070
4130
|
"codeBlock"
|
|
4071
|
-
]),
|
|
4131
|
+
]), kc = (e) => Oc.has(e), Ac = {
|
|
4072
4132
|
inlineCode: (e) => {
|
|
4073
|
-
let t =
|
|
4074
|
-
return t ?
|
|
4133
|
+
let t = Dc(e, ["inlineCode", "code_inline"]);
|
|
4134
|
+
return t ? Sc(Ot(t), e) : !1;
|
|
4075
4135
|
},
|
|
4076
4136
|
inlineMath: (e) => {
|
|
4077
4137
|
let t = e?.state?.schema?.nodes?.math_inline;
|
|
@@ -4084,7 +4144,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4084
4144
|
},
|
|
4085
4145
|
mathBlock: (e) => {
|
|
4086
4146
|
let t = e.state.schema.nodes?.math_block;
|
|
4087
|
-
if (!t || !
|
|
4147
|
+
if (!t || !Sc(Dt(t), e)) return !1;
|
|
4088
4148
|
let n = e.state.selection?.$from;
|
|
4089
4149
|
if (!n) return !0;
|
|
4090
4150
|
let r = null;
|
|
@@ -4096,8 +4156,8 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4096
4156
|
let i = I.create(e.state.doc, r);
|
|
4097
4157
|
return e.dispatch(e.state.tr.setSelection(i).scrollIntoView()), !0;
|
|
4098
4158
|
},
|
|
4099
|
-
table:
|
|
4100
|
-
},
|
|
4159
|
+
table: Ec
|
|
4160
|
+
}, jc = (e, t) => !e?.state || !e?.dispatch ? !1 : kc(t) ? Hs(e, t) : t === "image" ? !1 : Ac[t](e), Mc = (e) => typeof e?.props?.editable == "function" ? e.props.editable(e.state) : !!e?.editable, Nc = [
|
|
4101
4161
|
{
|
|
4102
4162
|
id: "paragraph",
|
|
4103
4163
|
label: "普通文本",
|
|
@@ -4217,7 +4277,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4217
4277
|
icon: "Image",
|
|
4218
4278
|
command: "image"
|
|
4219
4279
|
}
|
|
4220
|
-
],
|
|
4280
|
+
], Pc = [
|
|
4221
4281
|
{
|
|
4222
4282
|
id: "paragraph",
|
|
4223
4283
|
label: "Paragraph",
|
|
@@ -4337,7 +4397,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4337
4397
|
icon: "Image",
|
|
4338
4398
|
command: "image"
|
|
4339
4399
|
}
|
|
4340
|
-
],
|
|
4400
|
+
], Fc = (e, t = "zh-CN") => e?.items && e.items.length > 0 ? e.items : t === "en-US" ? Pc : Nc, Ic = (e) => {
|
|
4341
4401
|
let t = e?.state?.selection?.$from;
|
|
4342
4402
|
if (!t) return !1;
|
|
4343
4403
|
let n = String(t.parent?.type?.name ?? "");
|
|
@@ -4347,17 +4407,17 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4347
4407
|
if (n === "table" || n === "table_cell" || n === "table_header") return !0;
|
|
4348
4408
|
}
|
|
4349
4409
|
return !1;
|
|
4350
|
-
},
|
|
4410
|
+
}, Lc = (e) => {
|
|
4351
4411
|
let t = e?.state, n = t?.selection?.$from;
|
|
4352
4412
|
if (!t || !n) return "";
|
|
4353
4413
|
let r = n.start(), i = n.pos;
|
|
4354
4414
|
return t.doc.textBetween(r, i, "\n", "\n");
|
|
4355
|
-
},
|
|
4356
|
-
let t =
|
|
4415
|
+
}, Rc = (e) => {
|
|
4416
|
+
let t = Lc(e), n = t.lastIndexOf("/");
|
|
4357
4417
|
if (n < 0) return null;
|
|
4358
4418
|
let r = t.slice(n + 1);
|
|
4359
4419
|
return /\s/.test(r) ? null : r;
|
|
4360
|
-
},
|
|
4420
|
+
}, zc = (e, t) => {
|
|
4361
4421
|
if (t === null || t.length === 0) return e;
|
|
4362
4422
|
let n = t.toLowerCase();
|
|
4363
4423
|
return e.filter((e) => [
|
|
@@ -4366,27 +4426,27 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4366
4426
|
e.command,
|
|
4367
4427
|
e.id
|
|
4368
4428
|
].some((e) => String(e).toLowerCase().startsWith(n)));
|
|
4369
|
-
},
|
|
4370
|
-
if (!
|
|
4429
|
+
}, Bc = (e, t) => {
|
|
4430
|
+
if (!Mc(e)) return {
|
|
4371
4431
|
visibleItems: [],
|
|
4372
4432
|
shouldShow: !1
|
|
4373
4433
|
};
|
|
4374
|
-
let n =
|
|
4434
|
+
let n = Rc(e), r = zc(t, n);
|
|
4375
4435
|
return {
|
|
4376
4436
|
visibleItems: r,
|
|
4377
|
-
shouldShow: !
|
|
4437
|
+
shouldShow: !Ic(e) && n !== null && r.length > 0
|
|
4378
4438
|
};
|
|
4379
|
-
},
|
|
4439
|
+
}, Vc = (e) => {
|
|
4380
4440
|
let t = e?.state, n = t?.selection?.$from;
|
|
4381
4441
|
if (!t || !n || !e?.dispatch) return !1;
|
|
4382
4442
|
let r = n.start(), i = n.pos, a = t.doc.textBetween(r, i, "\n", "\n").lastIndexOf("/");
|
|
4383
4443
|
if (a < 0) return !1;
|
|
4384
4444
|
let o = r + a, s = t.tr.delete(o, i);
|
|
4385
4445
|
return e.dispatch(s.scrollIntoView()), !0;
|
|
4386
|
-
},
|
|
4446
|
+
}, Hc = (e, t) => {
|
|
4387
4447
|
let n = t ? "true" : "false";
|
|
4388
4448
|
e.dataset.selected = n, e.setAttribute("aria-selected", n);
|
|
4389
|
-
},
|
|
4449
|
+
}, Uc = (e, t, n, r) => {
|
|
4390
4450
|
e.innerHTML = "";
|
|
4391
4451
|
let i = [], a = "";
|
|
4392
4452
|
return t.forEach((t, o) => {
|
|
@@ -4395,9 +4455,9 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4395
4455
|
n.className = "slash-menu-group", n.textContent = t.group, e.appendChild(n), a = t.group;
|
|
4396
4456
|
}
|
|
4397
4457
|
let s = document.createElement("div");
|
|
4398
|
-
s.className = "slash-menu-item", s.setAttribute("role", "option"), s.dataset.command = t.command, s.dataset.index = String(o),
|
|
4458
|
+
s.className = "slash-menu-item", s.setAttribute("role", "option"), s.dataset.command = t.command, s.dataset.index = String(o), Hc(s, o === n);
|
|
4399
4459
|
let c = document.createElement("span");
|
|
4400
|
-
c.className = "slash-menu-item-icon", t.icon && (c.innerHTML = q(
|
|
4460
|
+
c.className = "slash-menu-item-icon", t.icon && (c.innerHTML = q(_r(t.icon, "Circle"), {
|
|
4401
4461
|
size: 16,
|
|
4402
4462
|
strokeWidth: 2
|
|
4403
4463
|
}));
|
|
@@ -4406,12 +4466,12 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4406
4466
|
let u = r[t.command], d = u ? document.createElement("kbd") : null;
|
|
4407
4467
|
d && (d.className = "slash-menu-item-shortcut", d.textContent = u), s.appendChild(c), s.appendChild(l), d && s.appendChild(d), e.appendChild(s), i.push(s);
|
|
4408
4468
|
}), i;
|
|
4409
|
-
},
|
|
4469
|
+
}, Wc = (e, t) => {
|
|
4410
4470
|
let n = document.createElement("div");
|
|
4411
4471
|
n.className = "slash-menu", n.setAttribute("role", "listbox"), n.style.display = "none", e.appendChild(n);
|
|
4412
|
-
let r = !1, i = "", a = -1, o = [], s = !1, c = null, l =
|
|
4472
|
+
let r = !1, i = "", a = -1, o = [], s = !1, c = null, l = $s(t), u = () => {
|
|
4413
4473
|
if (!r || !c) return;
|
|
4414
|
-
let { editorWrapper: t, anchorTopInContent: i, anchorBottomInContent: a, anchorLeftInContent: o, placement: s, offsetY: l } = c, u =
|
|
4474
|
+
let { editorWrapper: t, anchorTopInContent: i, anchorBottomInContent: a, anchorLeftInContent: o, placement: s, offsetY: l } = c, u = Xo({
|
|
4415
4475
|
wrapper: t,
|
|
4416
4476
|
anchor: {
|
|
4417
4477
|
anchorTopInContent: i,
|
|
@@ -4424,7 +4484,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4424
4484
|
boundaryInset: 4
|
|
4425
4485
|
}, e);
|
|
4426
4486
|
n.style.left = `${u.left}px`, n.style.top = `${u.top}px`, n.dataset.placement = s;
|
|
4427
|
-
}, d =
|
|
4487
|
+
}, d = Zo(() => {
|
|
4428
4488
|
r && u();
|
|
4429
4489
|
}), f = () => {
|
|
4430
4490
|
n.style.top = "", n.style.left = "", n.style.transform = "", delete n.dataset.placement;
|
|
@@ -4449,10 +4509,10 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4449
4509
|
e.icon
|
|
4450
4510
|
]));
|
|
4451
4511
|
if (i !== r) {
|
|
4452
|
-
o =
|
|
4512
|
+
o = Uc(n, e, t, l), i = r, a = t;
|
|
4453
4513
|
return;
|
|
4454
4514
|
}
|
|
4455
|
-
a !== t && (a >= 0 && o[a] &&
|
|
4515
|
+
a !== t && (a >= 0 && o[a] && Hc(o[a], !1), t >= 0 && o[t] && Hc(o[t], !0), a = t);
|
|
4456
4516
|
},
|
|
4457
4517
|
scrollActiveItemIntoView: (e) => {
|
|
4458
4518
|
let t = o[a] ?? null;
|
|
@@ -4469,55 +4529,55 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4469
4529
|
d.destroy(), o = [], n.remove();
|
|
4470
4530
|
}
|
|
4471
4531
|
};
|
|
4472
|
-
},
|
|
4532
|
+
}, Gc = (e, t) => {
|
|
4473
4533
|
if (!(!e || typeof e != "object")) return e[t];
|
|
4474
|
-
},
|
|
4534
|
+
}, Kc = () => {
|
|
4475
4535
|
if (typeof Nt != "function") return console.error("[zt-md/slash] slashFactory not found"), null;
|
|
4476
4536
|
let e = Nt("zt-md-slash"), t = Array.isArray(e) ? e[0] : void 0, n = Array.isArray(e) ? e[1] : e, r = Array.isArray(e) ? e[2] : void 0;
|
|
4477
4537
|
if (!n) return null;
|
|
4478
|
-
let i = Array.isArray(e) ? e.filter((e, t) => t < 2 && e != null) : [n], a =
|
|
4538
|
+
let i = Array.isArray(e) ? e.filter((e, t) => t < 2 && e != null) : [n], a = Gc(t, "key") ?? Gc(n, "key") ?? Gc(r, "key") ?? Gc(e, "key");
|
|
4479
4539
|
return i.length === 0 || a === void 0 ? null : {
|
|
4480
4540
|
plugins: i,
|
|
4481
4541
|
key: a
|
|
4482
4542
|
};
|
|
4483
|
-
},
|
|
4543
|
+
}, qc = (e, t, n, r, i = "zh-CN", a = "modShift") => {
|
|
4484
4544
|
if (t?.enabled === !1) return {
|
|
4485
4545
|
plugins: [],
|
|
4486
4546
|
config: null
|
|
4487
4547
|
};
|
|
4488
4548
|
try {
|
|
4489
|
-
let o =
|
|
4549
|
+
let o = Kc();
|
|
4490
4550
|
if (!o) return {
|
|
4491
4551
|
plugins: [],
|
|
4492
4552
|
config: null
|
|
4493
4553
|
};
|
|
4494
|
-
let s =
|
|
4554
|
+
let s = Fc(t, i), c = Wc(e, a), l = 0, u = null, d = s, f = !1, p = new Set([
|
|
4495
4555
|
"ArrowDown",
|
|
4496
4556
|
"ArrowUp",
|
|
4497
4557
|
"Enter",
|
|
4498
4558
|
"Escape"
|
|
4499
|
-
]), m = (e) => e.isComposing || !p.has(e.key) || !f ? !1 : e.key === "ArrowDown" ? (e.preventDefault(), d.length === 0 ? !0 : (l = (l + 1) % d.length, c.renderIfNeeded(d, l), c.scrollActiveItemIntoView(() => {
|
|
4559
|
+
]), m = (e) => e.isComposing || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || !p.has(e.key) || !f || !c.isVisible() ? !1 : e.key === "ArrowDown" ? (e.preventDefault(), d.length === 0 ? !0 : (l = (l + 1) % d.length, c.renderIfNeeded(d, l), c.scrollActiveItemIntoView(() => {
|
|
4500
4560
|
c.updatePosition();
|
|
4501
4561
|
}), !0)) : e.key === "ArrowUp" ? (e.preventDefault(), d.length === 0 ? !0 : (l = (l - 1 + d.length) % d.length, c.renderIfNeeded(d, l), c.scrollActiveItemIntoView(() => {
|
|
4502
4562
|
c.updatePosition();
|
|
4503
|
-
}), !0)) : e.key === "Enter" ? (e.preventDefault(), _(), !0) : e.key === "Escape" ? (e.preventDefault(), c.setVisible(!1), !0) : !1, h = (e) => {
|
|
4563
|
+
}), !0)) : e.key === "Enter" ? (e.preventDefault(), _(), !0) : e.key === "Escape" ? (e.preventDefault(), f = !1, c.updatePositionContext(null), c.setVisible(!1), !0) : !1, h = (e) => {
|
|
4504
4564
|
let t = e?.state?.selection?.from;
|
|
4505
4565
|
if (typeof t != "number") return null;
|
|
4506
4566
|
let n = e?.coordsAtPos?.(t);
|
|
4507
4567
|
return n ? new DOMRect(n.left, n.top, Math.max(n.right - n.left, 1), n.bottom - n.top) : null;
|
|
4508
4568
|
}, g = (e) => {
|
|
4509
|
-
if (!
|
|
4569
|
+
if (!Mc(e)) {
|
|
4510
4570
|
d = [], f = !1, c.updatePositionContext(null), c.setVisible(!1);
|
|
4511
4571
|
return;
|
|
4512
4572
|
}
|
|
4513
|
-
let t =
|
|
4573
|
+
let t = Bc(e, s);
|
|
4514
4574
|
if (d = t.visibleItems, f = t.shouldShow, t.shouldShow && l >= d.length && (l = 0), t.shouldShow && !c.isVisible() && (l = 0), !t.shouldShow) {
|
|
4515
4575
|
c.updatePositionContext(null), c.setVisible(!1);
|
|
4516
4576
|
return;
|
|
4517
4577
|
}
|
|
4518
|
-
let n = h(e), r =
|
|
4578
|
+
let n = h(e), r = Go(e?.dom);
|
|
4519
4579
|
if (n && r) {
|
|
4520
|
-
let e =
|
|
4580
|
+
let e = Ko(n, 320), t = qo(n, r);
|
|
4521
4581
|
c.updatePositionContext({
|
|
4522
4582
|
editorWrapper: r,
|
|
4523
4583
|
anchorTopInContent: t.anchorTopInContent,
|
|
@@ -4531,15 +4591,15 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4531
4591
|
c.updatePosition();
|
|
4532
4592
|
});
|
|
4533
4593
|
}, _ = () => {
|
|
4534
|
-
if (!
|
|
4594
|
+
if (!Mc(u)) {
|
|
4535
4595
|
f = !1, c.updatePositionContext(null), c.setVisible(!1);
|
|
4536
4596
|
return;
|
|
4537
4597
|
}
|
|
4538
4598
|
if (!u || l < 0 || l >= d.length) return;
|
|
4539
4599
|
let t = d[l];
|
|
4540
|
-
if (
|
|
4600
|
+
if (Vc(u)) {
|
|
4541
4601
|
if (t.command === "image") {
|
|
4542
|
-
c.setVisible(!1), n &&
|
|
4602
|
+
c.setVisible(!1), n && Ui({
|
|
4543
4603
|
portalContainer: e,
|
|
4544
4604
|
view: u,
|
|
4545
4605
|
messages: n,
|
|
@@ -4547,7 +4607,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4547
4607
|
});
|
|
4548
4608
|
return;
|
|
4549
4609
|
}
|
|
4550
|
-
|
|
4610
|
+
jc(u, t.command) && (c.setVisible(!1), t.command === "mathBlock" && queueMicrotask(() => {
|
|
4551
4611
|
let e = u?.dom?.querySelector?.(".zt-md-math-block-editing .zt-md-math-block-textarea");
|
|
4552
4612
|
!e || document.activeElement === e || e.focus();
|
|
4553
4613
|
}));
|
|
@@ -4581,8 +4641,8 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4581
4641
|
updateLocale: (e) => {
|
|
4582
4642
|
if (i === e) return;
|
|
4583
4643
|
let n = d[l]?.command;
|
|
4584
|
-
if (i = e, s =
|
|
4585
|
-
let e =
|
|
4644
|
+
if (i = e, s = Fc(t, i), u) {
|
|
4645
|
+
let e = Bc(u, s).visibleItems;
|
|
4586
4646
|
l = Math.max(0, e.findIndex((e) => e.command === n)), g(u);
|
|
4587
4647
|
}
|
|
4588
4648
|
}
|
|
@@ -4593,36 +4653,36 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4593
4653
|
config: null
|
|
4594
4654
|
};
|
|
4595
4655
|
}
|
|
4596
|
-
},
|
|
4656
|
+
}, Jc = /Mac|iPhone|iPad|iPod/, Yc = (e, t) => (typeof navigator < "u" && Jc.test(navigator.platform) ? e.metaKey && !e.ctrlKey : e.ctrlKey && !e.metaKey) ? t === "modAlt" ? e.altKey && !e.shiftKey : e.shiftKey && !e.altKey : !1, Xc = (e, t, n, r) => (Ui({
|
|
4597
4657
|
portalContainer: t,
|
|
4598
4658
|
view: e,
|
|
4599
4659
|
messages: n,
|
|
4600
4660
|
imageUpload: r
|
|
4601
|
-
}), !0),
|
|
4602
|
-
let i =
|
|
4661
|
+
}), !0), Zc = (e, t, n, r) => {
|
|
4662
|
+
let i = qs(n), a = Object.fromEntries(Object.entries(i).map(([e, t]) => [t.code, e]));
|
|
4603
4663
|
return (i, o) => {
|
|
4604
|
-
if (o.isComposing || !
|
|
4664
|
+
if (o.isComposing || !Yc(o, n) || !Mc(i)) return !1;
|
|
4605
4665
|
let s = a[o.code];
|
|
4606
4666
|
if (!s) return !1;
|
|
4607
|
-
let c = s === "image" ?
|
|
4667
|
+
let c = s === "image" ? Xc(i, e, t, r) : jc(i, s);
|
|
4608
4668
|
return c && o.preventDefault(), c;
|
|
4609
4669
|
};
|
|
4610
|
-
},
|
|
4670
|
+
}, Qc = "table", $c = "ArrowUp", el = (e) => e.key !== $c || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey, tl = (e, t) => {
|
|
4611
4671
|
let n = t.nodeBefore;
|
|
4612
|
-
return !n || n.type.name !==
|
|
4672
|
+
return !n || n.type.name !== Qc ? null : {
|
|
4613
4673
|
tableNode: n,
|
|
4614
4674
|
tableStart: e - n.nodeSize
|
|
4615
4675
|
};
|
|
4616
|
-
},
|
|
4676
|
+
}, nl = (e) => {
|
|
4617
4677
|
if (e.parent.type.name !== "paragraph" || e.parentOffset !== 0 || e.parent.childCount > 0 || e.depth < 1) return null;
|
|
4618
4678
|
let t = e.index(e.depth - 1);
|
|
4619
4679
|
if (t <= 0) return null;
|
|
4620
4680
|
let n = e.node(e.depth - 1).child(t - 1);
|
|
4621
|
-
return n.type.name ===
|
|
4681
|
+
return n.type.name === Qc ? {
|
|
4622
4682
|
tableNode: n,
|
|
4623
4683
|
tableStart: e.before(e.depth) - n.nodeSize
|
|
4624
4684
|
} : null;
|
|
4625
|
-
},
|
|
4685
|
+
}, rl = (e, t) => {
|
|
4626
4686
|
if (e.childCount === 0) return null;
|
|
4627
4687
|
let n = e.childCount - 1, r = e.child(n);
|
|
4628
4688
|
if (r.childCount === 0) return null;
|
|
@@ -4631,21 +4691,21 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4631
4691
|
let a = r.childCount - 1, o = r.child(a), s = 0;
|
|
4632
4692
|
for (let e = 0; e < a; e += 1) s += r.child(e).nodeSize;
|
|
4633
4693
|
return t + 1 + i + 1 + s + o.nodeSize - 1;
|
|
4634
|
-
},
|
|
4694
|
+
}, il = (e) => {
|
|
4635
4695
|
let { selection: t } = e.state, n = t.$from, r = null;
|
|
4636
|
-
if (t instanceof _t ? r =
|
|
4637
|
-
let i =
|
|
4696
|
+
if (t instanceof _t ? r = tl(t.from, n) : t.empty && (r = nl(n)), !r) return !1;
|
|
4697
|
+
let i = rl(r.tableNode, r.tableStart);
|
|
4638
4698
|
if (i === null) return !1;
|
|
4639
4699
|
let a = e.state.tr.setSelection(z.near(e.state.doc.resolve(i), -1)).scrollIntoView();
|
|
4640
4700
|
return e.dispatch(a), e.focus(), !0;
|
|
4641
|
-
},
|
|
4701
|
+
}, al = V(() => new L({
|
|
4642
4702
|
key: new R("zt-md-table-arrow-entry"),
|
|
4643
|
-
props: { handleKeyDown: (e, t) =>
|
|
4644
|
-
})),
|
|
4703
|
+
props: { handleKeyDown: (e, t) => el(t) ? !1 : il(e) }
|
|
4704
|
+
})), ol = "table", sl = "table_header_row", cl = "table_row", ll = "table_header", ul = "table_cell", dl = (e) => {
|
|
4645
4705
|
let t = e.selection.$from, n = -1, r = -1;
|
|
4646
4706
|
for (let e = t.depth; e >= 0; --e) {
|
|
4647
4707
|
let i = t.node(e);
|
|
4648
|
-
if (r < 0 && (i.type.name ===
|
|
4708
|
+
if (r < 0 && (i.type.name === ul || i.type.name === ll) && (r = t.index(e - 1)), n < 0 && (i.type.name === cl || i.type.name === sl) && (n = t.index(e - 1)), i.type.name === ol) return {
|
|
4649
4709
|
tableNode: i,
|
|
4650
4710
|
tableStart: e === 0 ? 0 : t.before(e),
|
|
4651
4711
|
tableNodeSize: i.nodeSize,
|
|
@@ -4654,7 +4714,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4654
4714
|
};
|
|
4655
4715
|
}
|
|
4656
4716
|
return null;
|
|
4657
|
-
},
|
|
4717
|
+
}, fl = (e, t, n, r) => {
|
|
4658
4718
|
if (n < 0 || n >= e.childCount) return null;
|
|
4659
4719
|
let i = 0;
|
|
4660
4720
|
for (let t = 0; t < n; t += 1) i += e.child(t).nodeSize;
|
|
@@ -4663,16 +4723,16 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4663
4723
|
let o = 0;
|
|
4664
4724
|
for (let e = 0; e < r; e += 1) o += a.child(e).nodeSize;
|
|
4665
4725
|
return t + 1 + i + 1 + o + 1 + 1;
|
|
4666
|
-
},
|
|
4726
|
+
}, pl = (e) => {
|
|
4667
4727
|
if (e.columnIndex < 0 || e.tableNode.childCount === 0) return !1;
|
|
4668
4728
|
let t = e.tableNode.child(0);
|
|
4669
4729
|
return e.columnIndex < t.childCount;
|
|
4670
|
-
},
|
|
4671
|
-
let i =
|
|
4730
|
+
}, ml = (e, t, n, r) => {
|
|
4731
|
+
let i = fl(t.tableNode, t.tableStart, n, r);
|
|
4672
4732
|
if (i === null) return !1;
|
|
4673
4733
|
let a = e.state.tr.setSelection(z.near(e.state.tr.doc.resolve(i), 1));
|
|
4674
4734
|
return e.dispatch(a), !0;
|
|
4675
|
-
},
|
|
4735
|
+
}, hl = (e, t) => t(e.state, e.dispatch, e) ? (e.dispatch(e.state.tr.scrollIntoView()), e.focus(), !0) : !1, gl = (e, t, n) => t.rowIndex < 0 || t.columnIndex < 0 || !ml(e, t, t.rowIndex, t.columnIndex) ? !1 : hl(e, n === "above" ? Rt : Lt), _l = (e, t) => t.rowIndex <= 0 || t.columnIndex < 0 || !ml(e, t, t.rowIndex, t.columnIndex) ? !1 : hl(e, Bt), vl = (e, t, n) => t.rowIndex < 0 || t.columnIndex < 0 || !ml(e, t, t.rowIndex, t.columnIndex) ? !1 : hl(e, n === "left" ? It : Ft), yl = (e, t) => t.rowIndex < 0 || t.columnIndex < 0 || (t.tableNode.childCount > 0 ? t.tableNode.child(0).childCount : 0) <= 1 || !ml(e, t, t.rowIndex, t.columnIndex) ? !1 : hl(e, zt), bl = (e, t, n) => {
|
|
4676
4736
|
if (t.columnIndex < 0) return !1;
|
|
4677
4737
|
let r = Pt.get(t.tableNode), i = t.tableStart + 1, a = t.columnIndex, o = e.state.tr;
|
|
4678
4738
|
for (let e = 0; e < r.height; e += 1) {
|
|
@@ -4687,14 +4747,14 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4687
4747
|
o.setNodeMarkup(c, l.type, u, l.marks);
|
|
4688
4748
|
}
|
|
4689
4749
|
return o.docChanged ? (o.scrollIntoView(), e.dispatch(o), e.focus(), !0) : !1;
|
|
4690
|
-
}, yl = (e) => {
|
|
4691
|
-
let t = ll(e.state);
|
|
4692
|
-
!t || t.rowIndex <= 0 || hl(e, t);
|
|
4693
|
-
}, bl = (e) => {
|
|
4694
|
-
let t = ll(e.state);
|
|
4695
|
-
!t || t.rowIndex < 0 || t.columnIndex < 0 || _l(e, t);
|
|
4696
4750
|
}, xl = (e) => {
|
|
4697
|
-
let
|
|
4751
|
+
let t = dl(e.state);
|
|
4752
|
+
!t || t.rowIndex <= 0 || _l(e, t);
|
|
4753
|
+
}, Sl = (e) => {
|
|
4754
|
+
let t = dl(e.state);
|
|
4755
|
+
!t || t.rowIndex < 0 || t.columnIndex < 0 || yl(e, t);
|
|
4756
|
+
}, Cl = (e) => {
|
|
4757
|
+
let [r, i] = c(!1), a = $o({
|
|
4698
4758
|
open: r,
|
|
4699
4759
|
portalContainer: e.portalContainer,
|
|
4700
4760
|
editorWrapper: e.collisionBoundary,
|
|
@@ -4782,7 +4842,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4782
4842
|
size: 15,
|
|
4783
4843
|
strokeWidth: 2,
|
|
4784
4844
|
"aria-hidden": "true"
|
|
4785
|
-
})), n(
|
|
4845
|
+
})), n(es, {
|
|
4786
4846
|
panel: a,
|
|
4787
4847
|
portalContainer: e.portalContainer,
|
|
4788
4848
|
className: "zt-md-table-action-popover",
|
|
@@ -4791,27 +4851,27 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4791
4851
|
className: "zt-md-table-action-menu-divider",
|
|
4792
4852
|
"aria-hidden": "true"
|
|
4793
4853
|
}), n("div", { className: "zt-md-table-action-menu-group" }, ...d.map(f))));
|
|
4794
|
-
},
|
|
4854
|
+
}, wl = "zt-md-table-focus-actions", Tl = 8, El = 8, Dl = "left", Ol = q("Trash2", {
|
|
4795
4855
|
size: 15,
|
|
4796
4856
|
strokeWidth: 2
|
|
4797
|
-
}),
|
|
4857
|
+
}), kl = q("AlignLeft", {
|
|
4798
4858
|
size: 15,
|
|
4799
4859
|
strokeWidth: 2
|
|
4800
|
-
}),
|
|
4860
|
+
}), Al = q("AlignCenter", {
|
|
4801
4861
|
size: 15,
|
|
4802
4862
|
strokeWidth: 2
|
|
4803
|
-
}),
|
|
4863
|
+
}), jl = q("AlignRight", {
|
|
4804
4864
|
size: 15,
|
|
4805
4865
|
strokeWidth: 2
|
|
4806
|
-
}),
|
|
4866
|
+
}), Ml = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, Nl = (e) => {
|
|
4807
4867
|
let { selection: t, doc: n } = e.state;
|
|
4808
4868
|
return t.empty || !(t instanceof z) ? !1 : n.textBetween(t.from, t.to).trim().length > 0;
|
|
4809
|
-
},
|
|
4869
|
+
}, Pl = () => {
|
|
4810
4870
|
let e = document.createElement("span");
|
|
4811
4871
|
return e.className = "zt-md-table-actions-divider", e.setAttribute("aria-hidden", "true"), e;
|
|
4812
|
-
},
|
|
4872
|
+
}, Fl = (e, t, n) => t < 0 || n < 0 ? null : e.rows.item(t)?.cells.item(n) ?? null, Il = class {
|
|
4813
4873
|
constructor(e, t, n) {
|
|
4814
|
-
this.isAttached = !1, this.messageVersion = 0, this.lastMoreActionsKey = "", this.currentTableStart = null, this.currentTableNodeSize = null, this.currentColumnIndex = null, this.currentColumnAlignment =
|
|
4874
|
+
this.isAttached = !1, this.messageVersion = 0, this.lastMoreActionsKey = "", this.currentTableStart = null, this.currentTableNodeSize = null, this.currentColumnIndex = null, this.currentColumnAlignment = Dl, this.currentAnchorElement = null, this.currentTableWrapper = null, this.hasPositionContext = !1, this.repositionScheduler = Zo(() => {
|
|
4815
4875
|
this.hasPositionContext && this.updateOverlayPosition();
|
|
4816
4876
|
}), this.handleActionsMouseDown = (e) => {
|
|
4817
4877
|
e.preventDefault();
|
|
@@ -4828,20 +4888,20 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4828
4888
|
}, this.handleAlignRightClick = () => {
|
|
4829
4889
|
this.applyColumnAlignment("right");
|
|
4830
4890
|
}, this.handleInsertRowBelow = () => {
|
|
4831
|
-
let e =
|
|
4832
|
-
!e || e.rowIndex < 0 ||
|
|
4891
|
+
let e = dl(this.view.state);
|
|
4892
|
+
!e || e.rowIndex < 0 || gl(this.view, e, "below");
|
|
4833
4893
|
}, this.handleInsertRowAbove = () => {
|
|
4834
|
-
let e =
|
|
4835
|
-
!e || e.rowIndex <= 0 ||
|
|
4894
|
+
let e = dl(this.view.state);
|
|
4895
|
+
!e || e.rowIndex <= 0 || gl(this.view, e, "above");
|
|
4836
4896
|
}, this.handleInsertColumnLeft = () => {
|
|
4837
4897
|
this.insertColumn("left");
|
|
4838
4898
|
}, this.handleInsertColumnRight = () => {
|
|
4839
4899
|
this.insertColumn("right");
|
|
4840
4900
|
}, this.handleDeleteRow = () => {
|
|
4841
|
-
|
|
4901
|
+
xl(this.view);
|
|
4842
4902
|
}, this.handleDeleteColumn = () => {
|
|
4843
|
-
|
|
4844
|
-
}, this.view = e, this.messages = t, this.portalContainer = n, this.editorWrapper =
|
|
4903
|
+
Sl(this.view);
|
|
4904
|
+
}, this.view = e, this.messages = t, this.portalContainer = n, this.editorWrapper = Go(e.dom), this.actionsContainer = document.createElement("div"), this.actionsContainer.className = "zt-md-table-actions-overlay", this.deleteButton = document.createElement("button"), this.deleteButton.type = "button", this.deleteButton.className = "zt-md-table-action-button zt-md-table-action-button-danger", this.deleteButton.style.display = "inline-flex", this.deleteButton.setAttribute("aria-label", t.tableDeleteAriaLabel), this.deleteButton.innerHTML = Ol, this.alignLeftButton = this.createColumnAlignmentButton(t.tableAlignLeftAriaLabel, kl), this.alignCenterButton = this.createColumnAlignmentButton(t.tableAlignCenterAriaLabel, Al), this.alignRightButton = this.createColumnAlignmentButton(t.tableAlignRightAriaLabel, jl), this.moreActionsMount = document.createElement("span"), this.moreActionsMount.className = "zt-md-table-more-actions-mount", this.moreActionsRoot = yt(this.moreActionsMount), this.actionsContainer.append(this.moreActionsMount, Pl(), this.alignLeftButton, this.alignCenterButton, this.alignRightButton, Pl(), this.deleteButton), this.actionsContainer.addEventListener("mousedown", this.handleActionsMouseDown), this.deleteButton.addEventListener("click", this.handleDeleteClick), this.alignLeftButton.addEventListener("click", this.handleAlignLeftClick), this.alignCenterButton.addEventListener("click", this.handleAlignCenterClick), this.alignRightButton.addEventListener("click", this.handleAlignRightClick), this.update(e), this.stopObservingMessages = G(t, () => {
|
|
4845
4905
|
this.messageVersion += 1, this.deleteButton.setAttribute("aria-label", t.tableDeleteAriaLabel), this.alignLeftButton.setAttribute("aria-label", t.tableAlignLeftAriaLabel), this.alignCenterButton.setAttribute("aria-label", t.tableAlignCenterAriaLabel), this.alignRightButton.setAttribute("aria-label", t.tableAlignRightAriaLabel), this.isAttached && this.update(this.view);
|
|
4846
4906
|
});
|
|
4847
4907
|
}
|
|
@@ -4857,22 +4917,22 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4857
4917
|
return n.type = "button", n.className = "zt-md-table-action-button", n.style.display = "inline-flex", n.setAttribute("aria-label", e), n.innerHTML = t, n;
|
|
4858
4918
|
}
|
|
4859
4919
|
resolveColumnAlignment(e) {
|
|
4860
|
-
return e === "center" || e === "right" ? e :
|
|
4920
|
+
return e === "center" || e === "right" ? e : Dl;
|
|
4861
4921
|
}
|
|
4862
4922
|
updateAlignmentButtonsState(e) {
|
|
4863
4923
|
this.alignLeftButton.disabled = !e, this.alignCenterButton.disabled = !e, this.alignRightButton.disabled = !e, this.alignLeftButton.classList.toggle("zt-md-table-action-button-active", e && this.currentColumnAlignment === "left"), this.alignCenterButton.classList.toggle("zt-md-table-action-button-active", e && this.currentColumnAlignment === "center"), this.alignRightButton.classList.toggle("zt-md-table-action-button-active", e && this.currentColumnAlignment === "right");
|
|
4864
4924
|
}
|
|
4865
4925
|
applyColumnAlignment(e) {
|
|
4866
|
-
let t =
|
|
4867
|
-
!t || t.rowIndex < 0 || t.columnIndex < 0 ||
|
|
4926
|
+
let t = dl(this.view.state);
|
|
4927
|
+
!t || t.rowIndex < 0 || t.columnIndex < 0 || bl(this.view, t, e);
|
|
4868
4928
|
}
|
|
4869
4929
|
insertColumn(e) {
|
|
4870
|
-
let t =
|
|
4871
|
-
!t || t.rowIndex < 0 || t.columnIndex < 0 ||
|
|
4930
|
+
let t = dl(this.view.state);
|
|
4931
|
+
!t || t.rowIndex < 0 || t.columnIndex < 0 || vl(this.view, t, e);
|
|
4872
4932
|
}
|
|
4873
4933
|
renderMoreActions(e, t, r, i) {
|
|
4874
4934
|
let a = `${this.messageVersion}:${e}:${t}:${r}:${i}`;
|
|
4875
|
-
this.lastMoreActionsKey !== a && (this.lastMoreActionsKey = a, this.moreActionsRoot.render(n(
|
|
4935
|
+
this.lastMoreActionsKey !== a && (this.lastMoreActionsKey = a, this.moreActionsRoot.render(n(Cl, {
|
|
4876
4936
|
messages: this.messages,
|
|
4877
4937
|
portalContainer: this.portalContainer,
|
|
4878
4938
|
collisionBoundary: this.editorWrapper,
|
|
@@ -4904,24 +4964,24 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4904
4964
|
if (!this.editorWrapper || !this.currentAnchorElement || this.actionsContainer.parentElement !== this.portalContainer) return;
|
|
4905
4965
|
let e = this.resolveActionsContainerSize();
|
|
4906
4966
|
if (!e) return;
|
|
4907
|
-
let t = this.currentAnchorElement.getBoundingClientRect(), n = this.editorWrapper.getBoundingClientRect(), r = t.top - n.top, i = n.bottom - t.bottom, a = r >= e.height +
|
|
4967
|
+
let t = this.currentAnchorElement.getBoundingClientRect(), n = this.editorWrapper.getBoundingClientRect(), r = t.top - n.top, i = n.bottom - t.bottom, a = r >= e.height + Tl + El || r >= i ? "top" : "bottom", o = qo(t, this.editorWrapper, n), s = Xo({
|
|
4908
4968
|
wrapper: this.editorWrapper,
|
|
4909
4969
|
anchor: o,
|
|
4910
4970
|
overlaySize: e,
|
|
4911
4971
|
placement: a,
|
|
4912
4972
|
horizontalAlign: "center",
|
|
4913
|
-
offsetY:
|
|
4914
|
-
boundaryInset:
|
|
4973
|
+
offsetY: Tl,
|
|
4974
|
+
boundaryInset: El
|
|
4915
4975
|
}, this.portalContainer, n);
|
|
4916
4976
|
this.actionsContainer.style.left = `${s.left}px`, this.actionsContainer.style.top = `${s.top}px`;
|
|
4917
4977
|
}
|
|
4918
4978
|
update(e) {
|
|
4919
4979
|
if (this.view = e, e.composing) return;
|
|
4920
|
-
if (!this.editorWrapper || !
|
|
4980
|
+
if (!this.editorWrapper || !Ml(e) || Nl(e)) {
|
|
4921
4981
|
this.detach();
|
|
4922
4982
|
return;
|
|
4923
4983
|
}
|
|
4924
|
-
let t =
|
|
4984
|
+
let t = dl(e.state);
|
|
4925
4985
|
if (!t) {
|
|
4926
4986
|
this.detach();
|
|
4927
4987
|
return;
|
|
@@ -4938,50 +4998,59 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4938
4998
|
}
|
|
4939
4999
|
let i = this.isAttached;
|
|
4940
5000
|
this.isAttached || (this.isAttached = !0, this.repositionScheduler.bindGlobal(), this.repositionScheduler.bindWrapper(this.editorWrapper)), this.actionsContainer.parentElement !== this.portalContainer && this.portalContainer.append(this.actionsContainer);
|
|
4941
|
-
let a =
|
|
4942
|
-
this.currentColumnIndex = a ? t.columnIndex : null, this.currentColumnAlignment = this.resolveColumnAlignment(this.currentColumnIndex === null ? null : l?.maybeChild(this.currentColumnIndex)?.attrs?.alignment), this.updateAlignmentButtonsState(a), this.renderMoreActions(s, a, c, o), this.bindTableWrapperScroll(r), this.currentAnchorElement =
|
|
5001
|
+
let a = pl(t), o = a && t.tableNode.child(0).childCount > 1, s = t.rowIndex > 0, c = t.rowIndex > 0, l = t.tableNode.childCount > 0 ? t.tableNode.child(0) : null;
|
|
5002
|
+
this.currentColumnIndex = a ? t.columnIndex : null, this.currentColumnAlignment = this.resolveColumnAlignment(this.currentColumnIndex === null ? null : l?.maybeChild(this.currentColumnIndex)?.attrs?.alignment), this.updateAlignmentButtonsState(a), this.renderMoreActions(s, a, c, o), this.bindTableWrapperScroll(r), this.currentAnchorElement = Fl(r, t.rowIndex, t.columnIndex) ?? r, this.currentTableStart = t.tableStart, this.currentTableNodeSize = t.tableNodeSize, this.hasPositionContext = !0, i ? this.repositionScheduler.schedule() : this.updateOverlayPosition();
|
|
4943
5003
|
}
|
|
4944
5004
|
detach() {
|
|
4945
|
-
this.isAttached && (this.isAttached = !1, this.repositionScheduler.unbindGlobal(), this.repositionScheduler.bindWrapper(null), this.unbindTableWrapperScroll(), this.lastMoreActionsKey = "", this.moreActionsRoot.render(null), this.actionsContainer.remove(), this.currentAnchorElement = null, this.currentTableStart = null, this.currentTableNodeSize = null, this.currentColumnIndex = null, this.currentColumnAlignment =
|
|
5005
|
+
this.isAttached && (this.isAttached = !1, this.repositionScheduler.unbindGlobal(), this.repositionScheduler.bindWrapper(null), this.unbindTableWrapperScroll(), this.lastMoreActionsKey = "", this.moreActionsRoot.render(null), this.actionsContainer.remove(), this.currentAnchorElement = null, this.currentTableStart = null, this.currentTableNodeSize = null, this.currentColumnIndex = null, this.currentColumnAlignment = Dl, this.updateAlignmentButtonsState(!1), this.hasPositionContext = !1);
|
|
4946
5006
|
}
|
|
4947
5007
|
destroy() {
|
|
4948
5008
|
this.stopObservingMessages(), this.detach(), this.repositionScheduler.destroy(), this.moreActionsRoot.unmount(), this.actionsContainer.removeEventListener("mousedown", this.handleActionsMouseDown), this.deleteButton.removeEventListener("click", this.handleDeleteClick), this.alignLeftButton.removeEventListener("click", this.handleAlignLeftClick), this.alignCenterButton.removeEventListener("click", this.handleAlignCenterClick), this.alignRightButton.removeEventListener("click", this.handleAlignRightClick);
|
|
4949
5009
|
}
|
|
4950
|
-
},
|
|
5010
|
+
}, Ll = (e, t) => {
|
|
4951
5011
|
let n = t ?? W();
|
|
4952
5012
|
return V(() => new L({
|
|
4953
|
-
key: new R(
|
|
4954
|
-
view: (t) => new
|
|
5013
|
+
key: new R(wl),
|
|
5014
|
+
view: (t) => new Il(t, n, e)
|
|
4955
5015
|
}));
|
|
4956
|
-
},
|
|
5016
|
+
}, Rl = class {
|
|
5017
|
+
constructor(e) {
|
|
5018
|
+
this.node = e, this.dom = document.createElement("div"), this.dom.className = "tableWrapper";
|
|
5019
|
+
let t = document.createElement("table");
|
|
5020
|
+
this.contentDOM = document.createElement("tbody"), t.append(this.contentDOM), this.dom.append(t);
|
|
5021
|
+
}
|
|
5022
|
+
update(e) {
|
|
5023
|
+
return e.type === this.node.type ? (this.node = e, !0) : !1;
|
|
5024
|
+
}
|
|
5025
|
+
}, zl = () => (e) => new Rl(e), Bl = "list_item", Vl = "li[data-item-type=\"task\"]", Hl = 24, Ul = (e, t) => {
|
|
4957
5026
|
let n = t.getBoundingClientRect();
|
|
4958
|
-
return e.clientX >= n.left && e.clientX <= n.left +
|
|
4959
|
-
},
|
|
5027
|
+
return e.clientX >= n.left && e.clientX <= n.left + Hl && e.clientY >= n.top && e.clientY <= n.top + Hl;
|
|
5028
|
+
}, Wl = (e) => {
|
|
4960
5029
|
if (!(e instanceof Element)) return null;
|
|
4961
|
-
let t = e.closest(
|
|
5030
|
+
let t = e.closest(Vl);
|
|
4962
5031
|
return t instanceof HTMLElement ? t : null;
|
|
4963
|
-
},
|
|
5032
|
+
}, Gl = (e, t) => {
|
|
4964
5033
|
if (!e.editable) return !1;
|
|
4965
|
-
let n =
|
|
4966
|
-
return !n || !
|
|
4967
|
-
},
|
|
5034
|
+
let n = Wl(t.target);
|
|
5035
|
+
return !n || !Ul(t, n) ? !1 : (t.preventDefault(), !0);
|
|
5036
|
+
}, Kl = (e, t) => {
|
|
4968
5037
|
let n = e.posAtDOM(t, 0) - 1, r = e.state.doc.nodeAt(n);
|
|
4969
|
-
return !r || r.type.name !==
|
|
5038
|
+
return !r || r.type.name !== Bl || r.attrs.checked == null ? !1 : (e.dispatch(e.state.tr.setNodeMarkup(n, void 0, {
|
|
4970
5039
|
...r.attrs,
|
|
4971
5040
|
checked: !r.attrs.checked
|
|
4972
5041
|
})), !0);
|
|
4973
|
-
},
|
|
4974
|
-
mousedown: (e, t) =>
|
|
4975
|
-
dblclick: (e, t) =>
|
|
5042
|
+
}, ql = V(() => new L({ props: { handleDOMEvents: {
|
|
5043
|
+
mousedown: (e, t) => Gl(e, t),
|
|
5044
|
+
dblclick: (e, t) => Gl(e, t),
|
|
4976
5045
|
click: (e, t) => {
|
|
4977
5046
|
if (!e.editable) return !1;
|
|
4978
|
-
let n =
|
|
4979
|
-
return !n || !
|
|
5047
|
+
let n = Wl(t.target);
|
|
5048
|
+
return !n || !Ul(t, n) || !Kl(e, n) ? !1 : (t.preventDefault(), !0);
|
|
4980
5049
|
}
|
|
4981
|
-
} } })),
|
|
5050
|
+
} } })), Jl = "MILKDOWN_KEEP_LIST_ORDER", Yl = "table", Xl = (e, t, n = 1) => {
|
|
4982
5051
|
let r = `${t + n}.`;
|
|
4983
5052
|
return e.label === r ? !1 : (e.label = r, !0);
|
|
4984
|
-
},
|
|
5053
|
+
}, Zl = (e, t, n, r, i) => {
|
|
4985
5054
|
let a = Math.max(0, Math.min(e.content.size, t)), o = e.resolve(a);
|
|
4986
5055
|
for (let e = 1; e <= o.depth; e += 1) {
|
|
4987
5056
|
let t = o.node(e);
|
|
@@ -4990,14 +5059,14 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
4990
5059
|
return;
|
|
4991
5060
|
}
|
|
4992
5061
|
}
|
|
4993
|
-
},
|
|
5062
|
+
}, Ql = (e, t, n, r) => {
|
|
4994
5063
|
let i = /* @__PURE__ */ new Map(), a = e.content.findDiffStart(t.content);
|
|
4995
5064
|
if (a == null) return i;
|
|
4996
5065
|
let o = e.content.findDiffEnd(t.content);
|
|
4997
5066
|
if (!o) return i;
|
|
4998
5067
|
let s = Math.max(o.b, a);
|
|
4999
|
-
return
|
|
5000
|
-
},
|
|
5068
|
+
return Zl(t, a, n, r, i), s > a && (Zl(t, s, n, r, i), t.nodesBetween(a, s, (e, t) => e.type === n || e.type === r ? (i.set(t, e), !1) : !(e.isTextblock || e.type.name === Yl))), i;
|
|
5069
|
+
}, $l = V((e) => {
|
|
5001
5070
|
let t = He.type(e), n = je.type(e), r = Be.type(e), i = (e, a, o, s, c) => {
|
|
5002
5071
|
if (e.type === n) {
|
|
5003
5072
|
let n = e.maybeChild(0);
|
|
@@ -5007,7 +5076,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5007
5076
|
let l = a + 1 + o;
|
|
5008
5077
|
if (t.type === r) {
|
|
5009
5078
|
let e = { ...t.attrs };
|
|
5010
|
-
|
|
5079
|
+
Xl(e, s) && n.setNodeMarkup(l, void 0, e), t.forEach((e, n, r) => {
|
|
5011
5080
|
i(e, l + 1 + n, t, r, c);
|
|
5012
5081
|
});
|
|
5013
5082
|
return;
|
|
@@ -5018,17 +5087,17 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5018
5087
|
}
|
|
5019
5088
|
} else if (e.type === r && o?.type === t) {
|
|
5020
5089
|
let t = { ...e.attrs }, n = !1;
|
|
5021
|
-
t.listType !== "ordered" && (t.listType = "ordered", n = !0), o.maybeChild(0) &&
|
|
5090
|
+
t.listType !== "ordered" && (t.listType = "ordered", n = !0), o.maybeChild(0) && Xl(t, s, typeof o.attrs.order == "number" ? o.attrs.order : 1) && (n = !0), n && c().setNodeMarkup(a, void 0, t);
|
|
5022
5091
|
}
|
|
5023
|
-
e.isTextblock || e.type.name ===
|
|
5092
|
+
e.isTextblock || e.type.name === Yl || e.forEach((t, n, r) => {
|
|
5024
5093
|
i(t, a + 1 + n, e, r, c);
|
|
5025
5094
|
});
|
|
5026
5095
|
};
|
|
5027
5096
|
return new L({
|
|
5028
|
-
key: new R(
|
|
5097
|
+
key: new R(Jl),
|
|
5029
5098
|
appendTransaction: (e, r, a) => {
|
|
5030
5099
|
if (!a.selection || !e.some((e) => e.docChanged) || e.some((e) => e.getMeta("addToHistory") === !1 || !e.isGeneric)) return null;
|
|
5031
|
-
let o =
|
|
5100
|
+
let o = Ql(r.doc, a.doc, t, n);
|
|
5032
5101
|
if (o.size === 0) return null;
|
|
5033
5102
|
let s = null, c = () => (s ||= a.tr, s);
|
|
5034
5103
|
return o.forEach((e, t) => {
|
|
@@ -5037,62 +5106,62 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5037
5106
|
}), s ? s.setMeta("addToHistory", !1) : null;
|
|
5038
5107
|
}
|
|
5039
5108
|
});
|
|
5040
|
-
}),
|
|
5109
|
+
}), eu = "Tab", tu = 4, nu = /^ */, ru = "list_item", iu = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, au = (e) => {
|
|
5041
5110
|
let { $from: t } = e.selection;
|
|
5042
5111
|
for (let e = t.depth; e >= 0; --e) {
|
|
5043
5112
|
let n = t.node(e);
|
|
5044
|
-
if (n.type.name ===
|
|
5113
|
+
if (n.type.name === ru) return n.type;
|
|
5045
5114
|
}
|
|
5046
5115
|
return null;
|
|
5047
|
-
},
|
|
5116
|
+
}, ou = (e) => {
|
|
5048
5117
|
let { selection: t, doc: n } = e;
|
|
5049
5118
|
if (t.empty) return [t.$from.start()];
|
|
5050
5119
|
let r = /* @__PURE__ */ new Set();
|
|
5051
5120
|
return n.nodesBetween(t.from, t.to, (e, t) => {
|
|
5052
5121
|
e.isTextblock && r.add(t + 1);
|
|
5053
5122
|
}), Array.from(r);
|
|
5054
|
-
},
|
|
5055
|
-
let { state: n } = e, r = " ".repeat(
|
|
5123
|
+
}, su = (e, t) => {
|
|
5124
|
+
let { state: n } = e, r = " ".repeat(tu), i = ou(n).sort((e, t) => t - e), a = n.tr;
|
|
5056
5125
|
return n.selection.empty ? a.insertText(r, n.selection.to) : i.forEach((e) => {
|
|
5057
5126
|
a.insertText(r, e);
|
|
5058
5127
|
}), a.docChanged ? (t.preventDefault(), e.dispatch(a), !0) : !1;
|
|
5059
|
-
},
|
|
5128
|
+
}, cu = (e, t) => {
|
|
5060
5129
|
let { state: n } = e, { selection: r } = n;
|
|
5061
5130
|
if (!(r instanceof z)) return !1;
|
|
5062
|
-
let i =
|
|
5131
|
+
let i = ou(n).sort((e, t) => t - e), a = n.tr;
|
|
5063
5132
|
return i.forEach((e) => {
|
|
5064
|
-
let t = n.doc.resolve(e).parent.textContent.match(
|
|
5133
|
+
let t = n.doc.resolve(e).parent.textContent.match(nu)?.[0].length ?? 0, r = Math.min(t, tu);
|
|
5065
5134
|
r <= 0 || a.delete(e, e + r);
|
|
5066
5135
|
}), a.docChanged ? (t.preventDefault(), e.dispatch(a), !0) : !1;
|
|
5067
|
-
},
|
|
5136
|
+
}, lu = V(() => new L({
|
|
5068
5137
|
key: new R("zt-md-tab-space-indent"),
|
|
5069
5138
|
props: { handleKeyDown: (e, t) => {
|
|
5070
5139
|
let n = e;
|
|
5071
|
-
if (!
|
|
5072
|
-
let r =
|
|
5140
|
+
if (!iu(n) || t.defaultPrevented || t.key !== eu || t.altKey || t.ctrlKey || t.metaKey) return !1;
|
|
5141
|
+
let r = au(n.state);
|
|
5073
5142
|
if (r) {
|
|
5074
5143
|
let e = (t.shiftKey ? At(r) : jt(r))(n.state, n.dispatch);
|
|
5075
5144
|
return t.preventDefault(), e || !0;
|
|
5076
5145
|
}
|
|
5077
|
-
return t.shiftKey ?
|
|
5146
|
+
return t.shiftKey ? cu(n, t) : su(n, t);
|
|
5078
5147
|
} }
|
|
5079
|
-
})),
|
|
5148
|
+
})), uu = (e) => {
|
|
5080
5149
|
let t = (e instanceof Element ? e : e.parentElement)?.closest("code");
|
|
5081
5150
|
return t instanceof HTMLElement && !t.closest("pre") ? t : null;
|
|
5082
|
-
},
|
|
5151
|
+
}, du = (e, t, n) => uu(e.domAtPos(t, n).node), fu = (e) => {
|
|
5083
5152
|
let t = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), n = t.nextNode(), r = null;
|
|
5084
5153
|
for (; n;) n.data.length > 0 && (r = n), n = t.nextNode();
|
|
5085
5154
|
return r;
|
|
5086
|
-
},
|
|
5155
|
+
}, pu = (e, t, n) => {
|
|
5087
5156
|
let r = e.domAtPos(t, n);
|
|
5088
5157
|
e.dom.ownerDocument.getSelection()?.collapse(r.node, r.offset);
|
|
5089
|
-
},
|
|
5090
|
-
let n = e.domAtPos(t, -1), r =
|
|
5158
|
+
}, mu = (e, t) => {
|
|
5159
|
+
let n = e.domAtPos(t, -1), r = uu(n.node), i = e.dom.ownerDocument.getSelection();
|
|
5091
5160
|
if (!r) {
|
|
5092
5161
|
i?.collapse(n.node, n.offset);
|
|
5093
5162
|
return;
|
|
5094
5163
|
}
|
|
5095
|
-
let a =
|
|
5164
|
+
let a = fu(r);
|
|
5096
5165
|
if (!a) {
|
|
5097
5166
|
let e = r.childNodes.length;
|
|
5098
5167
|
i?.collapse(r, e);
|
|
@@ -5100,7 +5169,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5100
5169
|
}
|
|
5101
5170
|
let o = a.data.length;
|
|
5102
5171
|
i?.collapse(a, o);
|
|
5103
|
-
},
|
|
5172
|
+
}, hu = {
|
|
5104
5173
|
left: {
|
|
5105
5174
|
inwardKey: "ArrowRight",
|
|
5106
5175
|
outwardKey: "ArrowLeft"
|
|
@@ -5109,13 +5178,13 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5109
5178
|
inwardKey: "ArrowLeft",
|
|
5110
5179
|
outwardKey: "ArrowRight"
|
|
5111
5180
|
}
|
|
5112
|
-
},
|
|
5181
|
+
}, gu = {
|
|
5113
5182
|
left: "nodeAfter",
|
|
5114
5183
|
right: "nodeBefore"
|
|
5115
|
-
},
|
|
5184
|
+
}, _u = (e, t) => {
|
|
5116
5185
|
e.dispatch(e.state.tr.setMeta(t, null));
|
|
5117
|
-
},
|
|
5118
|
-
if (t.key === "ArrowRight") return
|
|
5186
|
+
}, vu = (e, t, n, r, i) => {
|
|
5187
|
+
if (t.key === "ArrowRight") return _u(e, i), !1;
|
|
5119
5188
|
if (t.key !== "ArrowLeft") return !1;
|
|
5120
5189
|
t.preventDefault();
|
|
5121
5190
|
let a = (e.state.storedMarks ?? e.state.selection.$from.marks()).filter((e) => e.type !== n);
|
|
@@ -5123,35 +5192,35 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5123
5192
|
...r,
|
|
5124
5193
|
placement: "outside"
|
|
5125
5194
|
})), !0;
|
|
5126
|
-
},
|
|
5127
|
-
if (r.placement === "inside") return
|
|
5128
|
-
let a =
|
|
5129
|
-
if (t.key === a.outwardKey) return
|
|
5195
|
+
}, yu = (e, t, n, r, i) => {
|
|
5196
|
+
if (r.placement === "inside") return vu(e, t, n, r, i);
|
|
5197
|
+
let a = hu[r.side];
|
|
5198
|
+
if (t.key === a.outwardKey) return _u(e, i), !1;
|
|
5130
5199
|
if (t.key !== a.inwardKey) return !1;
|
|
5131
|
-
let o =
|
|
5132
|
-
if (!c) return
|
|
5200
|
+
let o = gu[r.side], s = e.state.selection.$from[o], c = s ? n.isInSet(s.marks) : null;
|
|
5201
|
+
if (!c) return _u(e, i), !1;
|
|
5133
5202
|
t.preventDefault();
|
|
5134
5203
|
let l = e.state.storedMarks ?? e.state.selection.$from.marks(), u = c.addToSet(l);
|
|
5135
5204
|
return e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, r.position)).setStoredMarks(u).setMeta(i, r.side === "left" ? {
|
|
5136
5205
|
...r,
|
|
5137
5206
|
placement: "inside"
|
|
5138
|
-
} : null)), r.side === "right" &&
|
|
5139
|
-
}, Q = (e, t) => !!t.isInSet(e),
|
|
5207
|
+
} : null)), r.side === "right" && mu(e, r.position), !0;
|
|
5208
|
+
}, Q = (e, t) => !!t.isInSet(e), bu = (e, t, n) => {
|
|
5140
5209
|
let r = e.state.doc.resolve(t), i = r.nodeBefore, a = r.nodeAfter;
|
|
5141
5210
|
return !a || Q(i?.marks ?? [], n) || !Q(a.marks, n) ? null : n.isInSet(a.marks);
|
|
5142
|
-
},
|
|
5211
|
+
}, xu = (e, t, n) => {
|
|
5143
5212
|
let r = e.state.doc.resolve(t), i = r.nodeBefore, a = r.nodeAfter;
|
|
5144
5213
|
return !i || !Q(i.marks, n) || Q(a?.marks ?? [], n) ? null : n.isInSet(i.marks);
|
|
5145
|
-
}, $ = new R("zt-md-inline-code-boundary-navigation"),
|
|
5214
|
+
}, $ = new R("zt-md-inline-code-boundary-navigation"), Su = "inlineCode", Cu = 2, wu = (e, t, n, r) => {
|
|
5146
5215
|
let i = t > 0 ? [t, t - 1] : [t];
|
|
5147
5216
|
for (let [t, a] of i.entries()) {
|
|
5148
|
-
let i =
|
|
5217
|
+
let i = xu(e, a, r);
|
|
5149
5218
|
if (!i) continue;
|
|
5150
5219
|
let o = e.state.doc.resolve(a).nodeAfter;
|
|
5151
5220
|
if (o !== null && !o.isText) continue;
|
|
5152
|
-
let s =
|
|
5221
|
+
let s = du(e, a, -1);
|
|
5153
5222
|
if (!s) continue;
|
|
5154
|
-
let c = n <= s.getBoundingClientRect().right +
|
|
5223
|
+
let c = n <= s.getBoundingClientRect().right + Cu;
|
|
5155
5224
|
if (!(t > 0 && !c)) return {
|
|
5156
5225
|
boundaryPosition: a,
|
|
5157
5226
|
inlineCodeMark: i,
|
|
@@ -5160,76 +5229,76 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5160
5229
|
};
|
|
5161
5230
|
}
|
|
5162
5231
|
return null;
|
|
5163
|
-
},
|
|
5232
|
+
}, Tu = (e, t) => {
|
|
5164
5233
|
if (t.button !== 0 || t.altKey || t.ctrlKey || t.metaKey || t.shiftKey || !e.editable) return !1;
|
|
5165
5234
|
let n = e.posAtCoords({
|
|
5166
5235
|
left: t.clientX,
|
|
5167
5236
|
top: t.clientY
|
|
5168
|
-
}), r = e.state.schema.marks[
|
|
5237
|
+
}), r = e.state.schema.marks[Su];
|
|
5169
5238
|
if (!n || !r) return !1;
|
|
5170
|
-
let i = n.pos, a = e.state.doc.resolve(i), o =
|
|
5239
|
+
let i = n.pos, a = e.state.doc.resolve(i), o = bu(e, i, r), s = a.nodeBefore;
|
|
5171
5240
|
if (o && (!s || s.isText)) {
|
|
5172
|
-
let n =
|
|
5241
|
+
let n = du(e, i, 1);
|
|
5173
5242
|
if (!n) return !1;
|
|
5174
5243
|
let c = n.getBoundingClientRect(), l = t.clientX >= c.left, u = (s?.marks ?? a.marks()).filter((e) => e.type !== r), d = l ? o.addToSet(a.marks()) : u, f = l ? {
|
|
5175
5244
|
position: i,
|
|
5176
5245
|
side: "left",
|
|
5177
5246
|
placement: "inside"
|
|
5178
5247
|
} : null;
|
|
5179
|
-
return t.preventDefault(), e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, i)).setStoredMarks(d).setMeta($, f)), e.focus(), l ||
|
|
5248
|
+
return t.preventDefault(), e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, i)).setStoredMarks(d).setMeta($, f)), e.focus(), l || pu(e, i, -1), !0;
|
|
5180
5249
|
}
|
|
5181
|
-
let c =
|
|
5250
|
+
let c = wu(e, i, t.clientX, r);
|
|
5182
5251
|
if (!c) return !1;
|
|
5183
5252
|
let l = c.boundaryPosition, u = e.state.doc.resolve(l), d = c.codeElement.getBoundingClientRect(), f = t.clientX >= d.right, p = (c.rightPlainTextNode?.marks ?? u.marks()).filter((e) => e.type !== r), m = f ? p : c.inlineCodeMark.addToSet(u.marks()), h = f ? {
|
|
5184
5253
|
position: l,
|
|
5185
5254
|
side: "right",
|
|
5186
5255
|
placement: "outside"
|
|
5187
5256
|
} : null;
|
|
5188
|
-
return t.preventDefault(), e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, l)).setStoredMarks(m).setMeta($, h)), e.focus(), f ||
|
|
5189
|
-
},
|
|
5257
|
+
return t.preventDefault(), e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, l)).setStoredMarks(m).setMeta($, h)), e.focus(), f || mu(e, l), !0;
|
|
5258
|
+
}, Eu = "inlineCode", Du = "zt-md-inline-code-boundary-indicator", Ou = "zt-md-inline-code-boundary-indicator-widget", ku = "zt-md-inline-code-boundary-active", Au = {
|
|
5190
5259
|
left: -1,
|
|
5191
5260
|
right: 1
|
|
5192
|
-
},
|
|
5261
|
+
}, ju = {
|
|
5193
5262
|
left: 1,
|
|
5194
5263
|
right: -1
|
|
5195
|
-
},
|
|
5264
|
+
}, Mu = (e) => {
|
|
5196
5265
|
let t = document.createElement("span");
|
|
5197
|
-
return t.className =
|
|
5198
|
-
},
|
|
5266
|
+
return t.className = Du, t.dataset.side = e.side, t.dataset.placement = e.placement, t.contentEditable = "false", t.setAttribute("aria-hidden", "true"), t;
|
|
5267
|
+
}, Nu = (e, t) => {
|
|
5199
5268
|
if (t.placement === "outside") return [];
|
|
5200
|
-
let n = e.schema.marks[
|
|
5269
|
+
let n = e.schema.marks[Eu], r = e.doc.resolve(t.position).nodeAfter, i = r && n ? n.isInSet(r.marks) : null;
|
|
5201
5270
|
return i ? [i] : null;
|
|
5202
|
-
},
|
|
5271
|
+
}, Pu = (e) => {
|
|
5203
5272
|
let t = $.getState(e);
|
|
5204
5273
|
if (!t) return B.empty;
|
|
5205
|
-
let n =
|
|
5274
|
+
let n = Nu(e, t);
|
|
5206
5275
|
if (!n) return B.empty;
|
|
5207
|
-
let r = t.placement === "inside" ? 1 :
|
|
5276
|
+
let r = t.placement === "inside" ? 1 : Au[t.side], i = Mu(t), a = lt.widget(t.position, i, {
|
|
5208
5277
|
side: r,
|
|
5209
5278
|
marks: n,
|
|
5210
|
-
key: `${
|
|
5279
|
+
key: `${Ou}-${t.side}-${t.placement}`,
|
|
5211
5280
|
ignoreSelection: !0,
|
|
5212
5281
|
relaxedSide: !0
|
|
5213
5282
|
});
|
|
5214
5283
|
return B.create(e.doc, [a]);
|
|
5215
|
-
},
|
|
5284
|
+
}, Fu = (e, t) => {
|
|
5216
5285
|
if (t?.placement !== "outside") return;
|
|
5217
|
-
let n = e.dom.querySelector(`.${
|
|
5286
|
+
let n = e.dom.querySelector(`.${Du}[data-side='${t.side}'][data-placement='outside']`), r = ju[t.side], i = du(e, t.position, r);
|
|
5218
5287
|
if (!n || !i) return;
|
|
5219
5288
|
let a = n.getBoundingClientRect().left, o = i.getBoundingClientRect(), s = t.side === "left" ? o.left - 1 : o.right + 1, c = Math.round(s - a);
|
|
5220
5289
|
n.style.setProperty("--zt-md-inline-code-boundary-offset-x", `${c}px`);
|
|
5221
|
-
},
|
|
5290
|
+
}, Iu = "inlineCode", Lu = (e, t) => {
|
|
5222
5291
|
let { selection: n } = e.state;
|
|
5223
5292
|
if (!n.empty) return !1;
|
|
5224
5293
|
let r = n.$from.nodeBefore, i = n.$from.nodeAfter;
|
|
5225
5294
|
return !!(r && Q(r.marks, t) && (!i || !Q(i.marks, t)));
|
|
5226
|
-
},
|
|
5295
|
+
}, Ru = (e, t) => {
|
|
5227
5296
|
let { selection: n } = e.state;
|
|
5228
5297
|
if (!n.empty) return !1;
|
|
5229
5298
|
let r = n.$from.nodeBefore, i = n.$from.nodeAfter;
|
|
5230
5299
|
return !!(i && Q(i.marks, t) && (!r || !Q(r.marks, t)));
|
|
5231
|
-
},
|
|
5232
|
-
let r =
|
|
5300
|
+
}, zu = (e, t, n) => {
|
|
5301
|
+
let r = bu(e, t, n);
|
|
5233
5302
|
if (!r) return !1;
|
|
5234
5303
|
let i = e.state.storedMarks ?? e.state.doc.resolve(t).marks(), a = r.addToSet(i);
|
|
5235
5304
|
return e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, t)).setStoredMarks(a).setMeta($, {
|
|
@@ -5237,14 +5306,14 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5237
5306
|
side: "left",
|
|
5238
5307
|
placement: "inside"
|
|
5239
5308
|
})), !0;
|
|
5240
|
-
},
|
|
5309
|
+
}, Bu = (e, t) => t.defaultPrevented || t.altKey || t.ctrlKey || t.metaKey || t.shiftKey || !e.editable, Vu = (e, t) => {
|
|
5241
5310
|
let { selection: n } = e.state;
|
|
5242
5311
|
if (!n.empty) return null;
|
|
5243
5312
|
let r = n.$from.nodeBefore;
|
|
5244
5313
|
return !r || !Q(r.marks, t) ? null : Array.from(r.textContent).length === 1 ? n.from - r.nodeSize : null;
|
|
5245
|
-
},
|
|
5314
|
+
}, Hu = (e, t, n) => {
|
|
5246
5315
|
if (t.key !== "ArrowLeft") return !1;
|
|
5247
|
-
let r =
|
|
5316
|
+
let r = Vu(e, n);
|
|
5248
5317
|
if (r === null) return !1;
|
|
5249
5318
|
let i = e.state.storedMarks ?? e.state.selection.$from.marks();
|
|
5250
5319
|
return Q(i, n) ? (t.preventDefault(), e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, r)).setStoredMarks(i).setMeta($, {
|
|
@@ -5252,121 +5321,121 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5252
5321
|
side: "left",
|
|
5253
5322
|
placement: "inside"
|
|
5254
5323
|
})), !0) : !1;
|
|
5255
|
-
},
|
|
5256
|
-
if (!
|
|
5324
|
+
}, Uu = (e, t, n) => {
|
|
5325
|
+
if (!Ru(e, n)) return !1;
|
|
5257
5326
|
let r = e.state.storedMarks ?? e.state.selection.$from.marks();
|
|
5258
|
-
if (!Q(r, n)) return
|
|
5327
|
+
if (!Q(r, n)) return Xu(e), !1;
|
|
5259
5328
|
t.preventDefault();
|
|
5260
5329
|
let i = r.filter((e) => e.type !== n);
|
|
5261
5330
|
return e.dispatch(e.state.tr.setStoredMarks(i).setMeta($, {
|
|
5262
5331
|
position: e.state.selection.from,
|
|
5263
5332
|
side: "left",
|
|
5264
5333
|
placement: "outside"
|
|
5265
|
-
})),
|
|
5266
|
-
},
|
|
5267
|
-
if (t.key !== "ArrowLeft" || !
|
|
5334
|
+
})), pu(e, e.state.selection.from, -1), !0;
|
|
5335
|
+
}, Wu = (e, t, n) => {
|
|
5336
|
+
if (t.key !== "ArrowLeft" || !Lu(e, n)) return !1;
|
|
5268
5337
|
let r = e.state.storedMarks ?? e.state.selection.$from.marks();
|
|
5269
5338
|
return Q(r, n) ? !1 : (t.preventDefault(), e.dispatch(e.state.tr.setStoredMarks(r).setMeta($, {
|
|
5270
5339
|
position: e.state.selection.from,
|
|
5271
5340
|
side: "right",
|
|
5272
5341
|
placement: "outside"
|
|
5273
|
-
})),
|
|
5274
|
-
},
|
|
5342
|
+
})), pu(e, e.state.selection.from, 1), !0);
|
|
5343
|
+
}, Gu = (e, t) => {
|
|
5275
5344
|
let { selection: n } = e.state;
|
|
5276
5345
|
if (!n.empty) return null;
|
|
5277
5346
|
let r = n.$from.nodeBefore;
|
|
5278
5347
|
if (!r?.isText || Q(r.marks, t) || Array.from(r.textContent).length !== 1) return null;
|
|
5279
5348
|
let i = n.from - r.nodeSize;
|
|
5280
|
-
return
|
|
5281
|
-
},
|
|
5349
|
+
return xu(e, i, t) ? i : null;
|
|
5350
|
+
}, Ku = (e, t, n) => {
|
|
5282
5351
|
if (t.key !== "ArrowLeft") return !1;
|
|
5283
|
-
let r =
|
|
5352
|
+
let r = Gu(e, n);
|
|
5284
5353
|
if (r === null) return !1;
|
|
5285
5354
|
let i = (e.state.selection.$from.nodeBefore?.marks ?? []).filter((e) => e.type !== n);
|
|
5286
5355
|
return t.preventDefault(), e.dispatch(e.state.tr.setSelection(z.create(e.state.doc, r)).setStoredMarks(i).setMeta($, {
|
|
5287
5356
|
position: r,
|
|
5288
5357
|
side: "right",
|
|
5289
5358
|
placement: "outside"
|
|
5290
|
-
})),
|
|
5291
|
-
},
|
|
5359
|
+
})), pu(e, r, 1), !0;
|
|
5360
|
+
}, qu = (e, t, n) => Ku(e, t, n) || Wu(e, t, n) || Hu(e, t, n) || Uu(e, t, n), Ju = () => null, Yu = (e, t) => {
|
|
5292
5361
|
let n = e.getMeta($);
|
|
5293
5362
|
return n === void 0 ? e.docChanged || e.selectionSet || e.storedMarksSet ? null : t : n;
|
|
5294
|
-
},
|
|
5363
|
+
}, Xu = (e) => {
|
|
5295
5364
|
$.getState(e.state) != null && e.dispatch(e.state.tr.setMeta($, null));
|
|
5296
|
-
},
|
|
5365
|
+
}, Zu = (e) => (Xu(e), !1), Qu = class {
|
|
5297
5366
|
constructor(e) {
|
|
5298
5367
|
this.isBoundaryActive = !1, this.editorDom = e.dom, this.update(e);
|
|
5299
5368
|
}
|
|
5300
5369
|
update(e) {
|
|
5301
5370
|
if (e.composing) return;
|
|
5302
5371
|
let t = $.getState(e.state), n = t != null;
|
|
5303
|
-
n !== this.isBoundaryActive && (this.isBoundaryActive = n, this.editorDom.classList.toggle(
|
|
5372
|
+
n !== this.isBoundaryActive && (this.isBoundaryActive = n, this.editorDom.classList.toggle(ku, n)), Fu(e, t);
|
|
5304
5373
|
}
|
|
5305
5374
|
destroy() {
|
|
5306
|
-
this.editorDom.classList.remove(
|
|
5375
|
+
this.editorDom.classList.remove(ku);
|
|
5307
5376
|
}
|
|
5308
|
-
},
|
|
5377
|
+
}, $u = (e) => new Qu(e), ed = (e) => {
|
|
5309
5378
|
if (!(e instanceof Element)) return !1;
|
|
5310
5379
|
let t = e.closest("code");
|
|
5311
5380
|
return !!(t && !t.closest("pre"));
|
|
5312
|
-
},
|
|
5381
|
+
}, td = (e, t, n) => {
|
|
5313
5382
|
if (!e.state.selection.empty) return !1;
|
|
5314
|
-
if (
|
|
5315
|
-
let r =
|
|
5316
|
-
if (i && r &&
|
|
5383
|
+
if (Tu(e, n)) return !0;
|
|
5384
|
+
let r = ed(n.target), i = e.state.schema.marks[Iu];
|
|
5385
|
+
if (i && r && zu(e, t, i)) return n.preventDefault(), !0;
|
|
5317
5386
|
let a = $.getState(e.state);
|
|
5318
5387
|
if (!r || !a) return !1;
|
|
5319
5388
|
let o = e.state.storedMarks, s = e.state.tr.setMeta($, null);
|
|
5320
5389
|
return o !== null && i && !Q(o, i) && s.setStoredMarks(null), e.dispatch(s), !1;
|
|
5321
|
-
},
|
|
5322
|
-
ArrowLeft:
|
|
5390
|
+
}, nd = (e, t, n) => t.key !== "ArrowRight" || !Ru(e, n) || Q(e.state.storedMarks ?? e.state.selection.$from.marks(), n) || !zu(e, e.state.selection.from, n) ? !1 : (t.preventDefault(), !0), rd = {
|
|
5391
|
+
ArrowLeft: qu,
|
|
5323
5392
|
ArrowRight: (e, t, n) => {
|
|
5324
5393
|
if (t.key !== "ArrowRight") return !1;
|
|
5325
|
-
if (
|
|
5326
|
-
if (!
|
|
5394
|
+
if (nd(e, t, n)) return !0;
|
|
5395
|
+
if (!Lu(e, n)) return !1;
|
|
5327
5396
|
let r = e.state.storedMarks ?? e.state.selection.$from.marks();
|
|
5328
|
-
if (!Q(r, n)) return
|
|
5397
|
+
if (!Q(r, n)) return Xu(e), !1;
|
|
5329
5398
|
t.preventDefault();
|
|
5330
5399
|
let i = r.filter((e) => e.type !== n);
|
|
5331
5400
|
return e.dispatch(e.state.tr.setStoredMarks(i).setMeta($, {
|
|
5332
5401
|
position: e.state.selection.from,
|
|
5333
5402
|
side: "right",
|
|
5334
5403
|
placement: "outside"
|
|
5335
|
-
})),
|
|
5404
|
+
})), pu(e, e.state.selection.from, 1), !0;
|
|
5336
5405
|
}
|
|
5337
|
-
},
|
|
5338
|
-
if (
|
|
5339
|
-
let n =
|
|
5406
|
+
}, id = (e, t) => {
|
|
5407
|
+
if (Bu(e, t)) return !1;
|
|
5408
|
+
let n = rd[t.key];
|
|
5340
5409
|
if (!n) return !1;
|
|
5341
|
-
let r = e.state.schema.marks[
|
|
5410
|
+
let r = e.state.schema.marks[Iu];
|
|
5342
5411
|
if (!r) return !1;
|
|
5343
5412
|
let i = $.getState(e.state);
|
|
5344
|
-
return i ?
|
|
5345
|
-
},
|
|
5413
|
+
return i ? yu(e, t, r, i, $) : n(e, t, r);
|
|
5414
|
+
}, ad = V(() => new L({
|
|
5346
5415
|
key: $,
|
|
5347
|
-
view:
|
|
5416
|
+
view: $u,
|
|
5348
5417
|
state: {
|
|
5349
|
-
init:
|
|
5350
|
-
apply:
|
|
5418
|
+
init: Ju,
|
|
5419
|
+
apply: Yu
|
|
5351
5420
|
},
|
|
5352
5421
|
props: {
|
|
5353
|
-
handleKeyDown:
|
|
5354
|
-
handleClick:
|
|
5355
|
-
decorations:
|
|
5356
|
-
handleDOMEvents: { blur:
|
|
5422
|
+
handleKeyDown: id,
|
|
5423
|
+
handleClick: td,
|
|
5424
|
+
decorations: Pu,
|
|
5425
|
+
handleDOMEvents: { blur: Zu }
|
|
5357
5426
|
}
|
|
5358
|
-
})),
|
|
5427
|
+
})), od = ".zt-md-code-block-action-button[data-active='true']", sd = ".zt-md-search-panel", cd = 8, ld = {
|
|
5359
5428
|
current: 0,
|
|
5360
5429
|
total: 0,
|
|
5361
5430
|
isInvalidExpression: !1
|
|
5362
|
-
},
|
|
5431
|
+
}, ud = (e) => typeof e.props.editable == "function" ? e.props.editable(e.state) : e.editable, dd = (e) => new Vt({
|
|
5363
5432
|
search: e.search,
|
|
5364
5433
|
replace: e.replace,
|
|
5365
5434
|
caseSensitive: e.caseSensitive,
|
|
5366
5435
|
wholeWord: e.wholeWord,
|
|
5367
5436
|
regexp: e.regexp,
|
|
5368
5437
|
literal: !0
|
|
5369
|
-
}),
|
|
5438
|
+
}), fd = (e, t) => {
|
|
5370
5439
|
if (!t.valid) return [];
|
|
5371
5440
|
let n = [], r = 0, i = e.doc.content.size;
|
|
5372
5441
|
for (; r < i;) {
|
|
@@ -5375,7 +5444,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5375
5444
|
n.push(a), r = Math.max(a.to, r + 1);
|
|
5376
5445
|
}
|
|
5377
5446
|
return n;
|
|
5378
|
-
},
|
|
5447
|
+
}, pd = (e, t, n) => {
|
|
5379
5448
|
let r = 0, i = e.length - 1;
|
|
5380
5449
|
for (; r <= i;) {
|
|
5381
5450
|
let a = r + i >> 1, o = e[a];
|
|
@@ -5383,71 +5452,71 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5383
5452
|
o.from < t ? r = a + 1 : i = a - 1;
|
|
5384
5453
|
}
|
|
5385
5454
|
return -1;
|
|
5386
|
-
},
|
|
5387
|
-
let r = n.regexp && n.search.length > 0 && !n.valid, i =
|
|
5455
|
+
}, md = (e, t, n) => {
|
|
5456
|
+
let r = n.regexp && n.search.length > 0 && !n.valid, i = pd(t, e.selection.from, e.selection.to);
|
|
5388
5457
|
return {
|
|
5389
5458
|
current: i < 0 ? 0 : i + 1,
|
|
5390
5459
|
total: t.length,
|
|
5391
5460
|
isInvalidExpression: r
|
|
5392
5461
|
};
|
|
5393
|
-
},
|
|
5462
|
+
}, hd = (e, t) => e.current === t.current && e.total === t.total && e.isInvalidExpression === t.isInvalidExpression, gd = (e) => {
|
|
5394
5463
|
if (e.state.selection.empty) return;
|
|
5395
|
-
let t =
|
|
5464
|
+
let t = Go(e.dom);
|
|
5396
5465
|
if (!t) return;
|
|
5397
|
-
let n = e.coordsAtPos(e.state.selection.from), r = e.coordsAtPos(e.state.selection.to), i = Math.min(n.top, r.top), a = Math.max(n.bottom, r.bottom), o = t.getBoundingClientRect(), s = (t.closest(".zt-md")?.querySelector(
|
|
5466
|
+
let n = e.coordsAtPos(e.state.selection.from), r = e.coordsAtPos(e.state.selection.to), i = Math.min(n.top, r.top), a = Math.max(n.bottom, r.bottom), o = t.getBoundingClientRect(), s = (t.closest(".zt-md")?.querySelector(sd))?.getBoundingClientRect(), c = Math.max(o.top + cd, (s?.bottom ?? o.top) + cd), l = o.bottom - cd;
|
|
5398
5467
|
if (i < c) {
|
|
5399
5468
|
t.scrollTop += i - c;
|
|
5400
5469
|
return;
|
|
5401
5470
|
}
|
|
5402
5471
|
a > l && (t.scrollTop += a - l);
|
|
5403
|
-
},
|
|
5472
|
+
}, _d = (e) => {
|
|
5404
5473
|
if (e.state.selection.empty) return;
|
|
5405
5474
|
let t = e.domAtPos(e.state.selection.from), n = (t.node instanceof Element ? t.node : t.node.parentElement)?.closest(".zt-md-code-block");
|
|
5406
5475
|
if (n?.dataset.viewMode !== "preview") {
|
|
5407
|
-
|
|
5476
|
+
gd(e);
|
|
5408
5477
|
return;
|
|
5409
5478
|
}
|
|
5410
|
-
n.querySelector(
|
|
5411
|
-
|
|
5479
|
+
n.querySelector(od)?.click(), window.requestAnimationFrame(() => {
|
|
5480
|
+
gd(e);
|
|
5412
5481
|
});
|
|
5413
|
-
},
|
|
5482
|
+
}, vd = class {
|
|
5414
5483
|
constructor(e, t) {
|
|
5415
|
-
this.onSnapshotChange = t, this.snapshot =
|
|
5484
|
+
this.onSnapshotChange = t, this.snapshot = ld, this.cachedDoc = null, this.cachedQuery = null, this.cachedResults = [], this.emitSnapshot(e.state);
|
|
5416
5485
|
}
|
|
5417
5486
|
update(e) {
|
|
5418
5487
|
e.composing || this.emitSnapshot(e.state);
|
|
5419
5488
|
}
|
|
5420
5489
|
destroy() {
|
|
5421
|
-
this.cachedDoc = null, this.cachedQuery = null, this.cachedResults = [], this.onSnapshotChange(
|
|
5490
|
+
this.cachedDoc = null, this.cachedQuery = null, this.cachedResults = [], this.onSnapshotChange(ld);
|
|
5422
5491
|
}
|
|
5423
5492
|
resolveSearchResults(e, t) {
|
|
5424
5493
|
if (this.cachedDoc === e.doc && this.cachedQuery && this.cachedQuery.eq(t)) return this.cachedResults;
|
|
5425
|
-
let n =
|
|
5494
|
+
let n = fd(e, t);
|
|
5426
5495
|
return this.cachedDoc = e.doc, this.cachedQuery = t, this.cachedResults = n, n;
|
|
5427
5496
|
}
|
|
5428
5497
|
emitSnapshot(e) {
|
|
5429
5498
|
let t = Wt(e);
|
|
5430
5499
|
if (!t) {
|
|
5431
|
-
this.cachedDoc = null, this.cachedQuery = null, this.cachedResults = [],
|
|
5500
|
+
this.cachedDoc = null, this.cachedQuery = null, this.cachedResults = [], hd(this.snapshot, ld) || (this.snapshot = ld, this.onSnapshotChange(ld));
|
|
5432
5501
|
return;
|
|
5433
5502
|
}
|
|
5434
|
-
let n =
|
|
5435
|
-
|
|
5503
|
+
let n = md(e, this.resolveSearchResults(e, t.query), t.query);
|
|
5504
|
+
hd(this.snapshot, n) || (this.snapshot = n, this.onSnapshotChange(n));
|
|
5436
5505
|
}
|
|
5437
|
-
},
|
|
5506
|
+
}, yd = (e) => [V(() => qt()), V(() => new L({ view: (t) => new vd(t, e) }))], bd = (e) => {
|
|
5438
5507
|
let t = (t) => {
|
|
5439
5508
|
e((e) => {
|
|
5440
|
-
let n =
|
|
5509
|
+
let n = dd(t), r = Jt(e.state.tr, n);
|
|
5441
5510
|
if (n.valid) {
|
|
5442
5511
|
let t = n.findNext(e.state, e.state.selection.from) ?? n.findNext(e.state, 0, e.state.selection.from);
|
|
5443
5512
|
t && r.setSelection(z.create(r.doc, t.from, t.to)).scrollIntoView();
|
|
5444
5513
|
}
|
|
5445
|
-
e.dispatch(r),
|
|
5514
|
+
e.dispatch(r), _d(e);
|
|
5446
5515
|
});
|
|
5447
5516
|
}, n = (e, t) => {
|
|
5448
5517
|
e(t.state, (e) => {
|
|
5449
5518
|
t.dispatch(e.scrollIntoView());
|
|
5450
|
-
}) &&
|
|
5519
|
+
}) && _d(t);
|
|
5451
5520
|
};
|
|
5452
5521
|
return {
|
|
5453
5522
|
updateQuery: t,
|
|
@@ -5463,14 +5532,14 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5463
5532
|
},
|
|
5464
5533
|
replaceCurrent: () => {
|
|
5465
5534
|
e((e) => {
|
|
5466
|
-
|
|
5535
|
+
ud(e) && n(Kt, e);
|
|
5467
5536
|
});
|
|
5468
5537
|
},
|
|
5469
5538
|
replaceAll: () => {
|
|
5470
5539
|
e((e) => {
|
|
5471
|
-
if (!
|
|
5540
|
+
if (!ud(e)) return;
|
|
5472
5541
|
let t = Wt(e.state);
|
|
5473
|
-
!t ||
|
|
5542
|
+
!t || fd(e.state, t.query).length === 0 || Gt(e.state, (t) => {
|
|
5474
5543
|
e.dispatch(t);
|
|
5475
5544
|
});
|
|
5476
5545
|
});
|
|
@@ -5486,11 +5555,11 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5486
5555
|
},
|
|
5487
5556
|
focusCurrent: () => {
|
|
5488
5557
|
e((e) => {
|
|
5489
|
-
e.dispatch(e.state.tr.scrollIntoView()),
|
|
5558
|
+
e.dispatch(e.state.tr.scrollIntoView()), gd(e), e.focus();
|
|
5490
5559
|
});
|
|
5491
5560
|
}
|
|
5492
5561
|
};
|
|
5493
|
-
},
|
|
5562
|
+
}, xd = /^[ \t]+/, Sd = /[ \t]+$/, Cd = [pt("remarkCjkFriendly", () => Yt), pt("remarkCjkFriendlyGfmStrikethrough", () => Xt)].flat(), wd = (e) => {
|
|
5494
5563
|
let t = ((t, n, r, i) => {
|
|
5495
5564
|
let { delimiter: a, after: o } = e.resolveDelimiters(t, r), s = r.enter(e.constructName), c = r.createTracker(i), l = r.createTracker(i);
|
|
5496
5565
|
l.move(a);
|
|
@@ -5500,14 +5569,14 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5500
5569
|
...l.current()
|
|
5501
5570
|
});
|
|
5502
5571
|
s();
|
|
5503
|
-
let d =
|
|
5572
|
+
let d = xd.exec(u)?.[0] ?? "", f = Sd.exec(u)?.[0] ?? "", p = u.slice(d.length, u.length - f.length);
|
|
5504
5573
|
if (!p) return c.move(u);
|
|
5505
5574
|
let m = "";
|
|
5506
5575
|
return d && (m += c.move(d)), m += c.move(a), m += c.move(p), m += c.move(a), f && (m += c.move(f)), m;
|
|
5507
5576
|
});
|
|
5508
5577
|
return t.peek = e.peek, t;
|
|
5509
|
-
},
|
|
5510
|
-
let t = e.get(Se) ?? {}, n =
|
|
5578
|
+
}, Td = (e) => {
|
|
5579
|
+
let t = e.get(Se) ?? {}, n = wd({
|
|
5511
5580
|
constructName: "strong",
|
|
5512
5581
|
resolveDelimiters: (e, t) => {
|
|
5513
5582
|
let n = e.marker || t.options.strong || "*";
|
|
@@ -5517,7 +5586,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5517
5586
|
};
|
|
5518
5587
|
},
|
|
5519
5588
|
peek: (e, t, n) => n.options.strong || "*"
|
|
5520
|
-
}), r =
|
|
5589
|
+
}), r = wd({
|
|
5521
5590
|
constructName: "emphasis",
|
|
5522
5591
|
resolveDelimiters: (e, t) => {
|
|
5523
5592
|
let n = e.marker || t.options.emphasis || "*";
|
|
@@ -5527,7 +5596,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5527
5596
|
};
|
|
5528
5597
|
},
|
|
5529
5598
|
peek: (e, t, n) => n.options.emphasis || "*"
|
|
5530
|
-
}), i =
|
|
5599
|
+
}), i = wd({
|
|
5531
5600
|
constructName: "strikethrough",
|
|
5532
5601
|
resolveDelimiters: () => ({
|
|
5533
5602
|
delimiter: "~~",
|
|
@@ -5544,19 +5613,19 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5544
5613
|
delete: i
|
|
5545
5614
|
}
|
|
5546
5615
|
});
|
|
5547
|
-
},
|
|
5616
|
+
}, Ed = "ZT_MD_READONLY_CHANGE", Dd = "[data-type=\"code_block\"], [data-type=\"image\"], [data-type=\"math_block\"], [data-type=\"math_inline\"], [data-type=\"frontmatter\"]", Od = (e) => {
|
|
5548
5617
|
let t = e.target;
|
|
5549
5618
|
if (!(t instanceof Element)) return null;
|
|
5550
5619
|
let n = t.closest("a[href]");
|
|
5551
5620
|
return n instanceof HTMLAnchorElement ? n : null;
|
|
5552
|
-
},
|
|
5553
|
-
let n =
|
|
5621
|
+
}, kd = (e) => e?.type.name === "image", Ad = (e, t) => {
|
|
5622
|
+
let n = Od(e);
|
|
5554
5623
|
if (!n) return !1;
|
|
5555
|
-
let r =
|
|
5624
|
+
let r = Tr(n.getAttribute("href"));
|
|
5556
5625
|
return !r || t || !e.ctrlKey ? !1 : (e.preventDefault(), e.stopPropagation(), window.open(r, "_blank", "noopener,noreferrer"), !0);
|
|
5557
|
-
},
|
|
5626
|
+
}, jd = (e, t) => !t || !Od(e) ? !1 : (e.preventDefault(), e.stopPropagation(), !0), Md = (e, t) => {
|
|
5558
5627
|
let n = t ? "false" : "true";
|
|
5559
|
-
e.dom.querySelectorAll(
|
|
5628
|
+
e.dom.querySelectorAll(Dd).forEach((e) => {
|
|
5560
5629
|
if (e.dataset.editable = n, e.dataset.type === "code_block") {
|
|
5561
5630
|
let n = e.querySelector(":scope > .zt-md-code-block-actions");
|
|
5562
5631
|
if (n) {
|
|
@@ -5571,74 +5640,75 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5571
5640
|
t && (t.hidden = !0);
|
|
5572
5641
|
}
|
|
5573
5642
|
});
|
|
5574
|
-
},
|
|
5575
|
-
let t = e.readOnly, n =
|
|
5643
|
+
}, Nd = (e) => {
|
|
5644
|
+
let t = e.readOnly, n = Kn({
|
|
5576
5645
|
debounceMs: e.debounceMs ?? 0,
|
|
5577
5646
|
getSerializer: () => _.action((e) => e.get(we)),
|
|
5578
5647
|
onChange: e.onChange
|
|
5579
|
-
}), r = { ...e.messages ?? W(e.locale) }, i =
|
|
5648
|
+
}), r = { ...e.messages ?? W(e.locale) }, i = Ll(e.contentPortalContainer, r), a = xc(e.contentPortalContainer, r, e.shortcutMode), o = hs(r, e.contentPortalContainer), s = fa(r, e.contentPortalContainer), c = Ai(e.imageUpload, r), l = yd(e.onSearchSnapshotChange), u = [
|
|
5580
5649
|
...Pe.filter((e) => e !== Ge && e !== Ke),
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
], d =
|
|
5650
|
+
go,
|
|
5651
|
+
$l
|
|
5652
|
+
], d = qc(e.portalContainer, e.slashMenu, r, e.imageUpload, e.locale, e.shortcutMode), f = d.plugins, p = Zc(e.portalContainer, r, e.shortcutMode, e.imageUpload), m = {
|
|
5584
5653
|
commonmark: u,
|
|
5585
|
-
frontmatter:
|
|
5586
|
-
taskListTransformKeymap:
|
|
5587
|
-
inlineCodeBoundaryNavigation:
|
|
5654
|
+
frontmatter: Es,
|
|
5655
|
+
taskListTransformKeymap: nc(e.shortcutMode),
|
|
5656
|
+
inlineCodeBoundaryNavigation: ad,
|
|
5588
5657
|
gfm: qe,
|
|
5589
|
-
cjkFriendly:
|
|
5658
|
+
cjkFriendly: Cd,
|
|
5590
5659
|
history: Ee,
|
|
5591
5660
|
editorSearch: l,
|
|
5592
5661
|
codeBlockPrism: [Cn, Je],
|
|
5593
5662
|
codeBlockLanguagePicker: o,
|
|
5594
5663
|
clipboard: Te,
|
|
5595
5664
|
indent: De,
|
|
5596
|
-
imageDeleteSelection:
|
|
5665
|
+
imageDeleteSelection: si,
|
|
5597
5666
|
imagePaste: c,
|
|
5598
|
-
tableArrowEntry:
|
|
5599
|
-
blockBoundaryNavigation:
|
|
5600
|
-
headingBackspaceEmptyParagraph:
|
|
5601
|
-
headingFocusIndicator:
|
|
5602
|
-
mathBackspaceEntry:
|
|
5603
|
-
blockquoteBackspaceLift:
|
|
5667
|
+
tableArrowEntry: al,
|
|
5668
|
+
blockBoundaryNavigation: pr,
|
|
5669
|
+
headingBackspaceEmptyParagraph: ao,
|
|
5670
|
+
headingFocusIndicator: uo,
|
|
5671
|
+
mathBackspaceEntry: Yi,
|
|
5672
|
+
blockquoteBackspaceLift: Za,
|
|
5604
5673
|
tableFocusActions: i,
|
|
5605
5674
|
selectionTooltip: a,
|
|
5606
|
-
gapCursor:
|
|
5607
|
-
dropCursor:
|
|
5608
|
-
math:
|
|
5675
|
+
gapCursor: Zn,
|
|
5676
|
+
dropCursor: Xn,
|
|
5677
|
+
math: Wa,
|
|
5609
5678
|
mathInlineEdit: s,
|
|
5610
|
-
mathInlineArrowNavigation:
|
|
5611
|
-
taskListToggle:
|
|
5612
|
-
tabSpaceIndent:
|
|
5613
|
-
codeBlockModASelect:
|
|
5679
|
+
mathInlineArrowNavigation: Pa,
|
|
5680
|
+
taskListToggle: ql,
|
|
5681
|
+
tabSpaceIndent: lu,
|
|
5682
|
+
codeBlockModASelect: Ss,
|
|
5614
5683
|
slash: f.length > 0 ? f : null
|
|
5615
|
-
}, h =
|
|
5684
|
+
}, h = qn(m, { includeRuntime: !1 }), g = qn(m, { includeRuntime: !0 }).filter((e) => e.name === "clipboard" || e.name === "indent"), _ = _e.make();
|
|
5616
5685
|
_.config((n) => {
|
|
5617
|
-
|
|
5686
|
+
tc(n, e.shortcutMode), xo(n), n.set(Je.key, { configureRefractor: pn }), Rr(n, e.imageUpload?.allowedProtocols), Td(n), n.set(Ce, e.root), n.set(ve, e.markdown), n.set(be, {
|
|
5618
5687
|
editable: () => !t,
|
|
5619
5688
|
attributes: { spellcheck: "false" },
|
|
5620
5689
|
handleScrollToSelection: (e) => e.composing,
|
|
5621
5690
|
handleKeyDown: p,
|
|
5622
5691
|
handleDOMEvents: {
|
|
5623
|
-
mousedown: (e, n) => n instanceof MouseEvent ?
|
|
5624
|
-
click: (e, n) => n instanceof MouseEvent ?
|
|
5692
|
+
mousedown: (e, n) => n instanceof MouseEvent ? jd(n, t) : !1,
|
|
5693
|
+
click: (e, n) => n instanceof MouseEvent ? jd(n, t) : !1
|
|
5625
5694
|
},
|
|
5626
|
-
handleClick: (e, n, r) =>
|
|
5627
|
-
handleClickOn: (e, n, r, i, a, o) =>
|
|
5695
|
+
handleClick: (e, n, r) => Ad(r, t),
|
|
5696
|
+
handleClickOn: (e, n, r, i, a, o) => Ad(a, t) ? !0 : t && o && kd(r) ? (a.preventDefault(), !0) : !1
|
|
5628
5697
|
});
|
|
5629
5698
|
let i = n.get(xe) ?? [];
|
|
5630
5699
|
n.set(xe, [
|
|
5631
5700
|
...i,
|
|
5632
|
-
["image",
|
|
5633
|
-
["math_block",
|
|
5634
|
-
["math_inline",
|
|
5635
|
-
["code_block",
|
|
5636
|
-
[
|
|
5701
|
+
["image", Jr(r)],
|
|
5702
|
+
["math_block", aa(r)],
|
|
5703
|
+
["math_inline", va(r)],
|
|
5704
|
+
["code_block", Lo(r)],
|
|
5705
|
+
["table", zl()],
|
|
5706
|
+
[Cs, Is(r)]
|
|
5637
5707
|
]), d.config && d.config(n);
|
|
5638
5708
|
}), h.forEach((e) => {
|
|
5639
5709
|
_.use(e.plugin);
|
|
5640
|
-
}), _.use(n.plugin), _.use(
|
|
5641
|
-
let v =
|
|
5710
|
+
}), _.use(n.plugin), _.use(Rn);
|
|
5711
|
+
let v = bd((e) => {
|
|
5642
5712
|
_.action((t) => {
|
|
5643
5713
|
e(t.get(ye));
|
|
5644
5714
|
});
|
|
@@ -5664,7 +5734,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5664
5734
|
setReadOnly: (e) => {
|
|
5665
5735
|
t !== e && (t = e, _.action((e) => {
|
|
5666
5736
|
let n = e.get(ye);
|
|
5667
|
-
n.setProps({ editable: () => !t }),
|
|
5737
|
+
n.setProps({ editable: () => !t }), Md(n, t), n.dispatch(n.state.tr.setMeta(Ed, t));
|
|
5668
5738
|
}));
|
|
5669
5739
|
},
|
|
5670
5740
|
setDebounceMs: n.setDebounceMs,
|
|
@@ -5691,7 +5761,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5691
5761
|
});
|
|
5692
5762
|
}
|
|
5693
5763
|
};
|
|
5694
|
-
},
|
|
5764
|
+
}, Pd = (e, t, n, r) => {
|
|
5695
5765
|
let i = e, a = i.create.bind(e);
|
|
5696
5766
|
return i.create = async () => {
|
|
5697
5767
|
try {
|
|
@@ -5701,12 +5771,12 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5701
5771
|
throw console.error("Milkdown init failed:", e), r(e), e;
|
|
5702
5772
|
}
|
|
5703
5773
|
}, i;
|
|
5704
|
-
},
|
|
5774
|
+
}, Fd = (e) => {
|
|
5705
5775
|
let t = s(null), n = s(e.markdown), r = s(e.readOnly), a = s(e.debounceMs), o = s(e.onMarkdownChange), c = s(e.onInitError), l = s(e.onInitReady), u = s(e.onSearchSnapshotChange);
|
|
5706
5776
|
r.current = e.readOnly, a.current = e.debounceMs;
|
|
5707
5777
|
let f = d((i) => {
|
|
5708
5778
|
t.current = null, e.focusEditorRef && (e.focusEditorRef.current = null), e.searchControllerRef && (e.searchControllerRef.current = null), n.current = e.markdown;
|
|
5709
|
-
let s =
|
|
5779
|
+
let s = Nd({
|
|
5710
5780
|
root: i,
|
|
5711
5781
|
portalContainer: e.portalContainer,
|
|
5712
5782
|
contentPortalContainer: e.contentPortalContainer,
|
|
@@ -5725,7 +5795,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5725
5795
|
u.current?.(e);
|
|
5726
5796
|
}
|
|
5727
5797
|
});
|
|
5728
|
-
return
|
|
5798
|
+
return Pd(s.editor, s.installRuntimePlugins, () => {
|
|
5729
5799
|
t.current = s, e.focusEditorRef && (e.focusEditorRef.current = s.focusEditor), e.searchControllerRef && (e.searchControllerRef.current = s.searchController), l.current?.();
|
|
5730
5800
|
}, (e) => {
|
|
5731
5801
|
c.current?.(e);
|
|
@@ -5767,20 +5837,20 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5767
5837
|
let r = t.current;
|
|
5768
5838
|
!r || f.loading || e.markdown !== n.current && (n.current = e.markdown, r.setMarkdown(e.markdown));
|
|
5769
5839
|
}, [f.loading, e.markdown]);
|
|
5770
|
-
},
|
|
5840
|
+
}, Id = 160, Ld = 120, Rd = {
|
|
5771
5841
|
search: "",
|
|
5772
5842
|
replace: "",
|
|
5773
5843
|
caseSensitive: !1,
|
|
5774
5844
|
wholeWord: !1,
|
|
5775
5845
|
regexp: !1
|
|
5776
|
-
},
|
|
5846
|
+
}, zd = {
|
|
5777
5847
|
current: 0,
|
|
5778
5848
|
total: 0,
|
|
5779
5849
|
isInvalidExpression: !1
|
|
5780
|
-
},
|
|
5850
|
+
}, Bd = {
|
|
5781
5851
|
"zh-CN": "只读",
|
|
5782
5852
|
"en-US": "Read only"
|
|
5783
|
-
},
|
|
5853
|
+
}, Vd = (e) => e.length === 0 ? "\"\"" : `"${e.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\r\n|\r|\n/g, "\\A ")}"`, Hd = (e) => (Fd({
|
|
5784
5854
|
markdown: e.markdown,
|
|
5785
5855
|
portalContainer: e.portalContainer,
|
|
5786
5856
|
contentPortalContainer: e.contentPortalContainer,
|
|
@@ -5797,21 +5867,21 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5797
5867
|
onInitReady: e.onInitReady,
|
|
5798
5868
|
onInitError: e.onInitError,
|
|
5799
5869
|
onSearchSnapshotChange: e.onSearchSnapshotChange
|
|
5800
|
-
}), /* @__PURE__ */ P(l, {})),
|
|
5801
|
-
let [t, n] = c(""), [a, l] = c(null), [d, p] = c(null), [h, g] = c(!1), [_, v] = c(!1), [y, b] = c(
|
|
5870
|
+
}), /* @__PURE__ */ P(l, {})), Ud = (e) => {
|
|
5871
|
+
let [t, n] = c(""), [a, l] = c(null), [d, p] = c(null), [h, g] = c(!1), [_, v] = c(!1), [y, b] = c(Rd), [x, S] = c(zd), C = s(null), w = s(null), T = s(null), E = s(h), D = s(y);
|
|
5802
5872
|
E.current = h, D.current = y;
|
|
5803
5873
|
let O = o(() => m((e) => {
|
|
5804
5874
|
w.current?.updateQuery(e);
|
|
5805
|
-
},
|
|
5875
|
+
}, Ld), []);
|
|
5806
5876
|
i(() => () => {
|
|
5807
5877
|
O.cancel();
|
|
5808
5878
|
}, [O]);
|
|
5809
|
-
let k = e.theme ?? "light", A = e.readOnly ?? !1, ee =
|
|
5879
|
+
let k = e.theme ?? "light", A = e.readOnly ?? !1, ee = Bd[e.locale ?? "zh-CN"], te = e.debounceMs ?? Id, ne = e.shortcutMode ?? "modShift", { markdown: re, setMarkdown: j } = en(e.value, e.defaultValue, e.onChange), M = o(() => W(e.locale, e.messages, e.placeholder), [
|
|
5810
5880
|
e.locale,
|
|
5811
5881
|
e.messages,
|
|
5812
5882
|
e.placeholder
|
|
5813
5883
|
]), ie = o(() => ({
|
|
5814
|
-
"--zt-gap-placeholder-content":
|
|
5884
|
+
"--zt-gap-placeholder-content": Vd(M.placeholder),
|
|
5815
5885
|
...e.maxHeight === void 0 ? {} : {
|
|
5816
5886
|
maxHeight: e.maxHeight,
|
|
5817
5887
|
overflowY: "auto"
|
|
@@ -5842,7 +5912,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5842
5912
|
}, N = () => {
|
|
5843
5913
|
O.cancel();
|
|
5844
5914
|
let e = w.current;
|
|
5845
|
-
e?.clear(), S(
|
|
5915
|
+
e?.clear(), S(zd), g(!1), v(!1), e && requestAnimationFrame(e.focusCurrent);
|
|
5846
5916
|
}, pe = (e) => {
|
|
5847
5917
|
O.cancel(), b(e), w.current?.updateQuery(e);
|
|
5848
5918
|
}, me = (e) => {
|
|
@@ -5933,7 +6003,7 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5933
6003
|
"aria-readonly": A,
|
|
5934
6004
|
onMouseDown: ce,
|
|
5935
6005
|
style: ie,
|
|
5936
|
-
children: [a && d ? /* @__PURE__ */ P(u, { children: /* @__PURE__ */ P(
|
|
6006
|
+
children: [a && d ? /* @__PURE__ */ P(u, { children: /* @__PURE__ */ P(Hd, {
|
|
5937
6007
|
markdown: re,
|
|
5938
6008
|
locale: e.locale,
|
|
5939
6009
|
portalContainer: a,
|
|
@@ -5964,4 +6034,4 @@ var Fi = e.forwardRef(function({ className: e, ...t }, n) {
|
|
|
5964
6034
|
});
|
|
5965
6035
|
};
|
|
5966
6036
|
//#endregion
|
|
5967
|
-
export {
|
|
6037
|
+
export { Ud as MilkdownEditor };
|