@jvs-milkdown/crepe 1.2.18 → 1.2.21
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/lib/cjs/feature/toolbar/index.js +47 -20
- package/lib/cjs/feature/toolbar/index.js.map +1 -1
- package/lib/cjs/index.js +166 -82
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/feature/toolbar/index.js +47 -20
- package/lib/esm/feature/toolbar/index.js.map +1 -1
- package/lib/esm/index.js +325 -241
- package/lib/esm/index.js.map +1 -1
- package/lib/theme/common/toolbar.css +3 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/core/crepe.d.ts +1 -0
- package/lib/types/core/crepe.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/component.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/menu-bar.d.ts.map +1 -1
- package/lib/types/feature/toolbar/component.d.ts.map +1 -1
- package/lib/types/utils/fixed-toolbar-popup-state.d.ts +1 -0
- package/lib/types/utils/fixed-toolbar-popup-state.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/core/crepe.ts +83 -21
- package/src/feature/fixed-toolbar/component.tsx +3 -6
- package/src/feature/fixed-toolbar/index.ts +1 -1
- package/src/feature/fixed-toolbar/menu-bar.tsx +0 -1
- package/src/feature/toolbar/component.tsx +55 -21
- package/src/theme/common/toolbar.css +3 -0
- package/src/utils/fixed-toolbar-popup-state.ts +5 -0
package/lib/cjs/index.js
CHANGED
|
@@ -4902,6 +4902,10 @@ function decrementPopupCount() {
|
|
|
4902
4902
|
listeners.forEach((fn) => fn());
|
|
4903
4903
|
}
|
|
4904
4904
|
}
|
|
4905
|
+
function resetPopupCount() {
|
|
4906
|
+
_popupCount = 0;
|
|
4907
|
+
listeners.forEach((fn) => fn());
|
|
4908
|
+
}
|
|
4905
4909
|
|
|
4906
4910
|
function getGroups(config, ctx) {
|
|
4907
4911
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
@@ -5757,7 +5761,8 @@ const Toolbar = vue.defineComponent({
|
|
|
5757
5761
|
const container = toolbarContainerRef.value;
|
|
5758
5762
|
if (!isFixed) {
|
|
5759
5763
|
const view = ctx.get(core.editorViewCtx);
|
|
5760
|
-
|
|
5764
|
+
const containerDOM = view.dom.closest(".milkdown-editor-container") || view.dom.closest(".milkdown") || view.dom;
|
|
5765
|
+
container.style.maxWidth = `${containerDOM.clientWidth - 32}px`;
|
|
5761
5766
|
}
|
|
5762
5767
|
let containerWidth;
|
|
5763
5768
|
if (isFixed) {
|
|
@@ -5777,16 +5782,13 @@ const Toolbar = vue.defineComponent({
|
|
|
5777
5782
|
}
|
|
5778
5783
|
} else {
|
|
5779
5784
|
const view = ctx.get(core.editorViewCtx);
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
if (containerWidth === lastContainerWidth) {
|
|
5783
|
-
return;
|
|
5785
|
+
const containerDOM = view.dom.closest(".milkdown-editor-container") || view.dom.closest(".milkdown") || view.dom;
|
|
5786
|
+
containerWidth = containerDOM.clientWidth - 32;
|
|
5784
5787
|
}
|
|
5785
|
-
lastContainerWidth = containerWidth;
|
|
5786
5788
|
if (showOverflowMenu.value) {
|
|
5787
5789
|
showOverflowMenu.value = false;
|
|
5788
5790
|
}
|
|
5789
|
-
const MORE_BUTTON_WIDTH =
|
|
5791
|
+
const MORE_BUTTON_WIDTH = 56;
|
|
5790
5792
|
const children = Array.from(container.children);
|
|
5791
5793
|
const toolbarChildren = children.filter(
|
|
5792
5794
|
(el) => el.style.position !== "fixed" && el.dataset.overflowButton !== "true"
|
|
@@ -5796,6 +5798,13 @@ const Toolbar = vue.defineComponent({
|
|
|
5796
5798
|
const child = toolbarChildren[i];
|
|
5797
5799
|
totalWidth += measureChild(child, i);
|
|
5798
5800
|
}
|
|
5801
|
+
if (totalWidth === 0) {
|
|
5802
|
+
return;
|
|
5803
|
+
}
|
|
5804
|
+
if (containerWidth === lastContainerWidth) {
|
|
5805
|
+
return;
|
|
5806
|
+
}
|
|
5807
|
+
lastContainerWidth = containerWidth;
|
|
5799
5808
|
if (totalWidth <= containerWidth) {
|
|
5800
5809
|
overflowVisibleCount.value = Infinity;
|
|
5801
5810
|
totalSectionCount.value = toolbarChildren.length;
|
|
@@ -5988,6 +5997,14 @@ const Toolbar = vue.defineComponent({
|
|
|
5988
5997
|
} else {
|
|
5989
5998
|
const view = ctx.get(core.editorViewCtx);
|
|
5990
5999
|
overflowResizeObserver.observe(view.dom);
|
|
6000
|
+
const containerDOM = view.dom.closest(".milkdown-editor-container");
|
|
6001
|
+
if (containerDOM) {
|
|
6002
|
+
overflowResizeObserver.observe(containerDOM);
|
|
6003
|
+
}
|
|
6004
|
+
const rootDOM = view.dom.closest(".milkdown");
|
|
6005
|
+
if (rootDOM) {
|
|
6006
|
+
overflowResizeObserver.observe(rootDOM);
|
|
6007
|
+
}
|
|
5991
6008
|
}
|
|
5992
6009
|
computeOverflow();
|
|
5993
6010
|
};
|
|
@@ -6016,6 +6033,20 @@ const Toolbar = vue.defineComponent({
|
|
|
6016
6033
|
lastContainerWidth = 0;
|
|
6017
6034
|
setTimeout(computeOverflow, 0);
|
|
6018
6035
|
});
|
|
6036
|
+
vue.watch(
|
|
6037
|
+
() => {
|
|
6038
|
+
var _a;
|
|
6039
|
+
return (_a = props.show) == null ? void 0 : _a.value;
|
|
6040
|
+
},
|
|
6041
|
+
(val) => {
|
|
6042
|
+
if (val) {
|
|
6043
|
+
cachedWidths.clear();
|
|
6044
|
+
overflowVisibleCount.value = Infinity;
|
|
6045
|
+
lastContainerWidth = 0;
|
|
6046
|
+
setTimeout(computeOverflow, 0);
|
|
6047
|
+
}
|
|
6048
|
+
}
|
|
6049
|
+
);
|
|
6019
6050
|
const onClick = (fn) => (e) => {
|
|
6020
6051
|
e.preventDefault();
|
|
6021
6052
|
if (ctx) fn(ctx);
|
|
@@ -6474,7 +6505,7 @@ const Toolbar = vue.defineComponent({
|
|
|
6474
6505
|
{
|
|
6475
6506
|
style: {
|
|
6476
6507
|
position: "relative",
|
|
6477
|
-
display: isSectionOverflowed(
|
|
6508
|
+
display: isSectionOverflowed(1) ? "none" : "flex",
|
|
6478
6509
|
flexShrink: 0
|
|
6479
6510
|
}
|
|
6480
6511
|
},
|
|
@@ -6519,7 +6550,7 @@ const Toolbar = vue.defineComponent({
|
|
|
6519
6550
|
style: {
|
|
6520
6551
|
margin: "0 4px",
|
|
6521
6552
|
alignSelf: "center",
|
|
6522
|
-
display: isSectionOverflowed(
|
|
6553
|
+
display: isSectionOverflowed(2) ? "none" : void 0,
|
|
6523
6554
|
flexShrink: 0
|
|
6524
6555
|
}
|
|
6525
6556
|
}
|
|
@@ -6532,7 +6563,7 @@ const Toolbar = vue.defineComponent({
|
|
|
6532
6563
|
onMouseleave: handleFontFamilyLeave,
|
|
6533
6564
|
style: {
|
|
6534
6565
|
position: "relative",
|
|
6535
|
-
display: isSectionOverflowed(
|
|
6566
|
+
display: isSectionOverflowed(3) ? "none" : "flex",
|
|
6536
6567
|
alignItems: "center",
|
|
6537
6568
|
padding: "0 6px",
|
|
6538
6569
|
minWidth: "50px",
|
|
@@ -6574,7 +6605,7 @@ const Toolbar = vue.defineComponent({
|
|
|
6574
6605
|
onMouseleave: handleFontSizeLeave,
|
|
6575
6606
|
style: {
|
|
6576
6607
|
position: "relative",
|
|
6577
|
-
display: isSectionOverflowed(
|
|
6608
|
+
display: isSectionOverflowed(4) ? "none" : "flex",
|
|
6578
6609
|
alignItems: "center",
|
|
6579
6610
|
padding: "0 6px",
|
|
6580
6611
|
minWidth: "40px",
|
|
@@ -6602,7 +6633,7 @@ const Toolbar = vue.defineComponent({
|
|
|
6602
6633
|
style: {
|
|
6603
6634
|
margin: "0 4px",
|
|
6604
6635
|
alignSelf: "center",
|
|
6605
|
-
display: isSectionOverflowed(
|
|
6636
|
+
display: isSectionOverflowed(5) ? "none" : void 0,
|
|
6606
6637
|
flexShrink: 0
|
|
6607
6638
|
}
|
|
6608
6639
|
}
|
|
@@ -6615,7 +6646,7 @@ const Toolbar = vue.defineComponent({
|
|
|
6615
6646
|
onMouseleave: handleAlignLeave,
|
|
6616
6647
|
style: {
|
|
6617
6648
|
position: "relative",
|
|
6618
|
-
display: isSectionOverflowed(
|
|
6649
|
+
display: isSectionOverflowed(6) ? "none" : "flex",
|
|
6619
6650
|
alignItems: "center",
|
|
6620
6651
|
padding: "0 6px",
|
|
6621
6652
|
flexShrink: 0
|
|
@@ -6644,7 +6675,7 @@ const Toolbar = vue.defineComponent({
|
|
|
6644
6675
|
onMouseleave: handleColorLeave,
|
|
6645
6676
|
style: {
|
|
6646
6677
|
position: "relative",
|
|
6647
|
-
display: isSectionOverflowed(
|
|
6678
|
+
display: isSectionOverflowed(7) ? "none" : "flex",
|
|
6648
6679
|
alignItems: "center",
|
|
6649
6680
|
padding: "0 4px",
|
|
6650
6681
|
flexShrink: 0
|
|
@@ -6672,7 +6703,7 @@ const Toolbar = vue.defineComponent({
|
|
|
6672
6703
|
)
|
|
6673
6704
|
),
|
|
6674
6705
|
(() => {
|
|
6675
|
-
let sectionIdx =
|
|
6706
|
+
let sectionIdx = 8;
|
|
6676
6707
|
return nonHeadingGroups.map((group, groupIndex) => {
|
|
6677
6708
|
const items = group.items.map((item) => {
|
|
6678
6709
|
const idx = sectionIdx;
|
|
@@ -7592,7 +7623,7 @@ const Toolbar = vue.defineComponent({
|
|
|
7592
7623
|
)
|
|
7593
7624
|
);
|
|
7594
7625
|
}
|
|
7595
|
-
if (
|
|
7626
|
+
if (3 >= cutoff) {
|
|
7596
7627
|
items.push(
|
|
7597
7628
|
renderIconButton(
|
|
7598
7629
|
textIcon,
|
|
@@ -7605,7 +7636,7 @@ const Toolbar = vue.defineComponent({
|
|
|
7605
7636
|
)
|
|
7606
7637
|
);
|
|
7607
7638
|
}
|
|
7608
|
-
if (
|
|
7639
|
+
if (4 >= cutoff) {
|
|
7609
7640
|
items.push(
|
|
7610
7641
|
renderIconButton(
|
|
7611
7642
|
textIcon,
|
|
@@ -7618,7 +7649,7 @@ const Toolbar = vue.defineComponent({
|
|
|
7618
7649
|
)
|
|
7619
7650
|
);
|
|
7620
7651
|
}
|
|
7621
|
-
if (
|
|
7652
|
+
if (6 >= cutoff) {
|
|
7622
7653
|
items.push(
|
|
7623
7654
|
renderIconButton(
|
|
7624
7655
|
currentAlignIndent.value.align === "center" ? alignCenterIcon : currentAlignIndent.value.align === "right" ? alignRightIcon : alignLeftIcon,
|
|
@@ -7631,7 +7662,7 @@ const Toolbar = vue.defineComponent({
|
|
|
7631
7662
|
)
|
|
7632
7663
|
);
|
|
7633
7664
|
}
|
|
7634
|
-
if (
|
|
7665
|
+
if (7 >= cutoff) {
|
|
7635
7666
|
items.push(
|
|
7636
7667
|
renderIconButton(
|
|
7637
7668
|
fontColorIcon,
|
|
@@ -7644,7 +7675,7 @@ const Toolbar = vue.defineComponent({
|
|
|
7644
7675
|
)
|
|
7645
7676
|
);
|
|
7646
7677
|
}
|
|
7647
|
-
let fmtIdx =
|
|
7678
|
+
let fmtIdx = 8;
|
|
7648
7679
|
for (const group of nonHeadingGroups) {
|
|
7649
7680
|
for (const item of group.items) {
|
|
7650
7681
|
const idx = fmtIdx;
|
|
@@ -7739,7 +7770,7 @@ const ToggleSwitch = vue.defineComponent({
|
|
|
7739
7770
|
},
|
|
7740
7771
|
emits: ["update:modelValue"],
|
|
7741
7772
|
setup(props, { emit }) {
|
|
7742
|
-
return () => /* @__PURE__ */
|
|
7773
|
+
return () => /* @__PURE__ */ h(
|
|
7743
7774
|
"div",
|
|
7744
7775
|
{
|
|
7745
7776
|
onClick: (e) => {
|
|
@@ -7756,7 +7787,7 @@ const ToggleSwitch = vue.defineComponent({
|
|
|
7756
7787
|
transition: "background-color 0.2s"
|
|
7757
7788
|
}
|
|
7758
7789
|
},
|
|
7759
|
-
/* @__PURE__ */
|
|
7790
|
+
/* @__PURE__ */ h(
|
|
7760
7791
|
"div",
|
|
7761
7792
|
{
|
|
7762
7793
|
style: {
|
|
@@ -7855,7 +7886,7 @@ const MenuBar = vue.defineComponent({
|
|
|
7855
7886
|
const hasSubmenu = (key) => key === "view";
|
|
7856
7887
|
return () => {
|
|
7857
7888
|
const state = viewState.value;
|
|
7858
|
-
return /* @__PURE__ */
|
|
7889
|
+
return /* @__PURE__ */ h(
|
|
7859
7890
|
"div",
|
|
7860
7891
|
{
|
|
7861
7892
|
class: "milkdown-menu-bar",
|
|
@@ -7867,7 +7898,7 @@ const MenuBar = vue.defineComponent({
|
|
|
7867
7898
|
position: "relative"
|
|
7868
7899
|
}
|
|
7869
7900
|
},
|
|
7870
|
-
/* @__PURE__ */
|
|
7901
|
+
/* @__PURE__ */ h(
|
|
7871
7902
|
"div",
|
|
7872
7903
|
{
|
|
7873
7904
|
ref: buttonRef,
|
|
@@ -7890,7 +7921,7 @@ const MenuBar = vue.defineComponent({
|
|
|
7890
7921
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
7891
7922
|
}
|
|
7892
7923
|
},
|
|
7893
|
-
/* @__PURE__ */
|
|
7924
|
+
/* @__PURE__ */ h(
|
|
7894
7925
|
"span",
|
|
7895
7926
|
{
|
|
7896
7927
|
style: {
|
|
@@ -7901,9 +7932,9 @@ const MenuBar = vue.defineComponent({
|
|
|
7901
7932
|
justifyContent: "center"
|
|
7902
7933
|
}
|
|
7903
7934
|
},
|
|
7904
|
-
/* @__PURE__ */
|
|
7935
|
+
/* @__PURE__ */ h(component.Icon, { icon: menuIcon })
|
|
7905
7936
|
),
|
|
7906
|
-
/* @__PURE__ */
|
|
7937
|
+
/* @__PURE__ */ h(
|
|
7907
7938
|
"span",
|
|
7908
7939
|
{
|
|
7909
7940
|
style: {
|
|
@@ -7916,7 +7947,7 @@ const MenuBar = vue.defineComponent({
|
|
|
7916
7947
|
"\u83DC\u5355"
|
|
7917
7948
|
)
|
|
7918
7949
|
),
|
|
7919
|
-
showMenu.value ? /* @__PURE__ */
|
|
7950
|
+
showMenu.value ? /* @__PURE__ */ h(
|
|
7920
7951
|
"div",
|
|
7921
7952
|
{
|
|
7922
7953
|
ref: mainRef,
|
|
@@ -7943,7 +7974,7 @@ const MenuBar = vue.defineComponent({
|
|
|
7943
7974
|
menuKeys.value.map((menuKey) => {
|
|
7944
7975
|
const isHovered = activeSubmenu.value === menuKey;
|
|
7945
7976
|
const label = i18n(props.ctx, `menuBar.${menuKey}`) || menuKey;
|
|
7946
|
-
return /* @__PURE__ */
|
|
7977
|
+
return /* @__PURE__ */ h(
|
|
7947
7978
|
"div",
|
|
7948
7979
|
{
|
|
7949
7980
|
key: menuKey,
|
|
@@ -7965,7 +7996,7 @@ const MenuBar = vue.defineComponent({
|
|
|
7965
7996
|
backgroundColor: isHovered ? "var(--crepe-color-hover, #f5f5f5)" : "transparent"
|
|
7966
7997
|
}
|
|
7967
7998
|
},
|
|
7968
|
-
/* @__PURE__ */
|
|
7999
|
+
/* @__PURE__ */ h(
|
|
7969
8000
|
"span",
|
|
7970
8001
|
{
|
|
7971
8002
|
style: {
|
|
@@ -7975,7 +8006,7 @@ const MenuBar = vue.defineComponent({
|
|
|
7975
8006
|
},
|
|
7976
8007
|
label
|
|
7977
8008
|
),
|
|
7978
|
-
hasSubmenu(menuKey) ? /* @__PURE__ */
|
|
8009
|
+
hasSubmenu(menuKey) ? /* @__PURE__ */ h(
|
|
7979
8010
|
"span",
|
|
7980
8011
|
{
|
|
7981
8012
|
style: {
|
|
@@ -7984,7 +8015,7 @@ const MenuBar = vue.defineComponent({
|
|
|
7984
8015
|
display: "flex"
|
|
7985
8016
|
}
|
|
7986
8017
|
},
|
|
7987
|
-
/* @__PURE__ */
|
|
8018
|
+
/* @__PURE__ */ h(
|
|
7988
8019
|
"svg",
|
|
7989
8020
|
{
|
|
7990
8021
|
width: "12",
|
|
@@ -7996,10 +8027,10 @@ const MenuBar = vue.defineComponent({
|
|
|
7996
8027
|
"stroke-linecap": "round",
|
|
7997
8028
|
"stroke-linejoin": "round"
|
|
7998
8029
|
},
|
|
7999
|
-
/* @__PURE__ */
|
|
8030
|
+
/* @__PURE__ */ h("polyline", { points: "9 18 15 12 9 6" })
|
|
8000
8031
|
)
|
|
8001
8032
|
) : null,
|
|
8002
|
-
menuKey === "view" && isHovered ? /* @__PURE__ */
|
|
8033
|
+
menuKey === "view" && isHovered ? /* @__PURE__ */ h(
|
|
8003
8034
|
"div",
|
|
8004
8035
|
{
|
|
8005
8036
|
style: {
|
|
@@ -8017,7 +8048,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8017
8048
|
cursor: "default"
|
|
8018
8049
|
}
|
|
8019
8050
|
},
|
|
8020
|
-
/* @__PURE__ */
|
|
8051
|
+
/* @__PURE__ */ h(
|
|
8021
8052
|
"div",
|
|
8022
8053
|
{
|
|
8023
8054
|
style: {
|
|
@@ -8027,7 +8058,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8027
8058
|
alignItems: "center"
|
|
8028
8059
|
}
|
|
8029
8060
|
},
|
|
8030
|
-
/* @__PURE__ */
|
|
8061
|
+
/* @__PURE__ */ h(
|
|
8031
8062
|
"span",
|
|
8032
8063
|
{
|
|
8033
8064
|
style: {
|
|
@@ -8037,7 +8068,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8037
8068
|
},
|
|
8038
8069
|
i18n(props.ctx, "view.title") || "\u6807\u9898"
|
|
8039
8070
|
),
|
|
8040
|
-
/* @__PURE__ */
|
|
8071
|
+
/* @__PURE__ */ h(
|
|
8041
8072
|
ToggleSwitch,
|
|
8042
8073
|
{
|
|
8043
8074
|
modelValue: state.showTitle,
|
|
@@ -8045,7 +8076,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8045
8076
|
}
|
|
8046
8077
|
)
|
|
8047
8078
|
),
|
|
8048
|
-
/* @__PURE__ */
|
|
8079
|
+
/* @__PURE__ */ h(
|
|
8049
8080
|
"div",
|
|
8050
8081
|
{
|
|
8051
8082
|
style: {
|
|
@@ -8055,7 +8086,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8055
8086
|
alignItems: "center"
|
|
8056
8087
|
}
|
|
8057
8088
|
},
|
|
8058
|
-
/* @__PURE__ */
|
|
8089
|
+
/* @__PURE__ */ h(
|
|
8059
8090
|
"span",
|
|
8060
8091
|
{
|
|
8061
8092
|
style: {
|
|
@@ -8065,7 +8096,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8065
8096
|
},
|
|
8066
8097
|
i18n(props.ctx, "view.outline") || "\u5927\u7EB2"
|
|
8067
8098
|
),
|
|
8068
|
-
/* @__PURE__ */
|
|
8099
|
+
/* @__PURE__ */ h(
|
|
8069
8100
|
ToggleSwitch,
|
|
8070
8101
|
{
|
|
8071
8102
|
modelValue: state.outlineVisible,
|
|
@@ -8073,7 +8104,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8073
8104
|
}
|
|
8074
8105
|
)
|
|
8075
8106
|
),
|
|
8076
|
-
/* @__PURE__ */
|
|
8107
|
+
/* @__PURE__ */ h(
|
|
8077
8108
|
"div",
|
|
8078
8109
|
{
|
|
8079
8110
|
style: {
|
|
@@ -8083,7 +8114,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8083
8114
|
alignItems: "center"
|
|
8084
8115
|
}
|
|
8085
8116
|
},
|
|
8086
|
-
/* @__PURE__ */
|
|
8117
|
+
/* @__PURE__ */ h(
|
|
8087
8118
|
"span",
|
|
8088
8119
|
{
|
|
8089
8120
|
style: {
|
|
@@ -8093,7 +8124,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8093
8124
|
},
|
|
8094
8125
|
i18n(props.ctx, "view.cover") || "\u5C01\u9762"
|
|
8095
8126
|
),
|
|
8096
|
-
/* @__PURE__ */
|
|
8127
|
+
/* @__PURE__ */ h(
|
|
8097
8128
|
ToggleSwitch,
|
|
8098
8129
|
{
|
|
8099
8130
|
modelValue: state.showCover,
|
|
@@ -8109,7 +8140,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8109
8140
|
}
|
|
8110
8141
|
)
|
|
8111
8142
|
),
|
|
8112
|
-
/* @__PURE__ */
|
|
8143
|
+
/* @__PURE__ */ h(
|
|
8113
8144
|
"div",
|
|
8114
8145
|
{
|
|
8115
8146
|
style: {
|
|
@@ -8119,7 +8150,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8119
8150
|
}
|
|
8120
8151
|
}
|
|
8121
8152
|
),
|
|
8122
|
-
/* @__PURE__ */
|
|
8153
|
+
/* @__PURE__ */ h(
|
|
8123
8154
|
"div",
|
|
8124
8155
|
{
|
|
8125
8156
|
style: {
|
|
@@ -8129,7 +8160,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8129
8160
|
alignItems: "center"
|
|
8130
8161
|
}
|
|
8131
8162
|
},
|
|
8132
|
-
/* @__PURE__ */
|
|
8163
|
+
/* @__PURE__ */ h(
|
|
8133
8164
|
"span",
|
|
8134
8165
|
{
|
|
8135
8166
|
style: {
|
|
@@ -8140,7 +8171,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8140
8171
|
i18n(props.ctx, "view.docBackground") || "\u6587\u6863\u80CC\u666F"
|
|
8141
8172
|
)
|
|
8142
8173
|
),
|
|
8143
|
-
/* @__PURE__ */
|
|
8174
|
+
/* @__PURE__ */ h(
|
|
8144
8175
|
"div",
|
|
8145
8176
|
{
|
|
8146
8177
|
style: {
|
|
@@ -8150,7 +8181,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8150
8181
|
gap: "6px"
|
|
8151
8182
|
}
|
|
8152
8183
|
},
|
|
8153
|
-
bgColors.map((bg) => /* @__PURE__ */
|
|
8184
|
+
bgColors.map((bg) => /* @__PURE__ */ h(
|
|
8154
8185
|
"div",
|
|
8155
8186
|
{
|
|
8156
8187
|
key: bg.value || "default",
|
|
@@ -8172,7 +8203,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8172
8203
|
justifyContent: "center"
|
|
8173
8204
|
}
|
|
8174
8205
|
},
|
|
8175
|
-
bg.value === null ? /* @__PURE__ */
|
|
8206
|
+
bg.value === null ? /* @__PURE__ */ h(
|
|
8176
8207
|
"div",
|
|
8177
8208
|
{
|
|
8178
8209
|
style: {
|
|
@@ -8185,7 +8216,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8185
8216
|
borderRadius: "3px"
|
|
8186
8217
|
}
|
|
8187
8218
|
},
|
|
8188
|
-
/* @__PURE__ */
|
|
8219
|
+
/* @__PURE__ */ h(
|
|
8189
8220
|
"div",
|
|
8190
8221
|
{
|
|
8191
8222
|
style: {
|
|
@@ -8203,7 +8234,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8203
8234
|
) : null
|
|
8204
8235
|
))
|
|
8205
8236
|
),
|
|
8206
|
-
/* @__PURE__ */
|
|
8237
|
+
/* @__PURE__ */ h(
|
|
8207
8238
|
"div",
|
|
8208
8239
|
{
|
|
8209
8240
|
style: {
|
|
@@ -8213,7 +8244,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8213
8244
|
}
|
|
8214
8245
|
}
|
|
8215
8246
|
),
|
|
8216
|
-
/* @__PURE__ */
|
|
8247
|
+
/* @__PURE__ */ h(
|
|
8217
8248
|
"div",
|
|
8218
8249
|
{
|
|
8219
8250
|
style: {
|
|
@@ -8223,7 +8254,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8223
8254
|
alignItems: "center"
|
|
8224
8255
|
}
|
|
8225
8256
|
},
|
|
8226
|
-
/* @__PURE__ */
|
|
8257
|
+
/* @__PURE__ */ h(
|
|
8227
8258
|
"span",
|
|
8228
8259
|
{
|
|
8229
8260
|
style: {
|
|
@@ -8234,7 +8265,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8234
8265
|
i18n(props.ctx, "view.editorWidth") || "\u5185\u5BB9\u5BBD\u5EA6"
|
|
8235
8266
|
)
|
|
8236
8267
|
),
|
|
8237
|
-
/* @__PURE__ */
|
|
8268
|
+
/* @__PURE__ */ h(
|
|
8238
8269
|
"div",
|
|
8239
8270
|
{
|
|
8240
8271
|
style: {
|
|
@@ -8256,7 +8287,7 @@ const MenuBar = vue.defineComponent({
|
|
|
8256
8287
|
key: "full",
|
|
8257
8288
|
labelKey: "view.widthFull"
|
|
8258
8289
|
}
|
|
8259
|
-
].map(({ key, labelKey }) => /* @__PURE__ */
|
|
8290
|
+
].map(({ key, labelKey }) => /* @__PURE__ */ h(
|
|
8260
8291
|
"button",
|
|
8261
8292
|
{
|
|
8262
8293
|
key,
|
|
@@ -8502,7 +8533,7 @@ const FixedToolbarComponent = vue.defineComponent({
|
|
|
8502
8533
|
props.selection.value;
|
|
8503
8534
|
const canUndo = (typeof props.canUndo === "boolean" ? props.canUndo : (_a = props.canUndo) == null ? void 0 : _a.value) || false;
|
|
8504
8535
|
const canRedo = (typeof props.canRedo === "boolean" ? props.canRedo : (_b = props.canRedo) == null ? void 0 : _b.value) || false;
|
|
8505
|
-
return /* @__PURE__ */
|
|
8536
|
+
return /* @__PURE__ */ h(
|
|
8506
8537
|
"div",
|
|
8507
8538
|
{
|
|
8508
8539
|
style: {
|
|
@@ -8510,12 +8541,14 @@ const FixedToolbarComponent = vue.defineComponent({
|
|
|
8510
8541
|
alignItems: "center",
|
|
8511
8542
|
justifyContent: "center",
|
|
8512
8543
|
width: "100%",
|
|
8513
|
-
gap: "0px"
|
|
8544
|
+
gap: "0px",
|
|
8545
|
+
minWidth: "0",
|
|
8546
|
+
overflow: "hidden"
|
|
8514
8547
|
}
|
|
8515
8548
|
},
|
|
8516
8549
|
((_c = props.config) == null ? void 0 : _c.showMenuBar) !== false && [
|
|
8517
|
-
/* @__PURE__ */
|
|
8518
|
-
/* @__PURE__ */
|
|
8550
|
+
/* @__PURE__ */ h(MenuBar, { ctx: props.ctx, config: props.config }),
|
|
8551
|
+
/* @__PURE__ */ h(
|
|
8519
8552
|
"div",
|
|
8520
8553
|
{
|
|
8521
8554
|
style: {
|
|
@@ -8528,7 +8561,7 @@ const FixedToolbarComponent = vue.defineComponent({
|
|
|
8528
8561
|
)
|
|
8529
8562
|
],
|
|
8530
8563
|
((_d = props.config) == null ? void 0 : _d.showHistory) !== false && [
|
|
8531
|
-
/* @__PURE__ */
|
|
8564
|
+
/* @__PURE__ */ h(
|
|
8532
8565
|
"button",
|
|
8533
8566
|
{
|
|
8534
8567
|
type: "button",
|
|
@@ -8559,7 +8592,7 @@ const FixedToolbarComponent = vue.defineComponent({
|
|
|
8559
8592
|
"--toolbar-icon-color": canUndo ? "#363b4c" : "#c0c4cc"
|
|
8560
8593
|
}
|
|
8561
8594
|
},
|
|
8562
|
-
/* @__PURE__ */
|
|
8595
|
+
/* @__PURE__ */ h(
|
|
8563
8596
|
"span",
|
|
8564
8597
|
{
|
|
8565
8598
|
style: { display: "inline-flex", alignItems: "center" },
|
|
@@ -8567,7 +8600,7 @@ const FixedToolbarComponent = vue.defineComponent({
|
|
|
8567
8600
|
}
|
|
8568
8601
|
)
|
|
8569
8602
|
),
|
|
8570
|
-
/* @__PURE__ */
|
|
8603
|
+
/* @__PURE__ */ h(
|
|
8571
8604
|
"button",
|
|
8572
8605
|
{
|
|
8573
8606
|
type: "button",
|
|
@@ -8598,7 +8631,7 @@ const FixedToolbarComponent = vue.defineComponent({
|
|
|
8598
8631
|
"--toolbar-icon-color": canRedo ? "#363b4c" : "#c0c4cc"
|
|
8599
8632
|
}
|
|
8600
8633
|
},
|
|
8601
|
-
/* @__PURE__ */
|
|
8634
|
+
/* @__PURE__ */ h(
|
|
8602
8635
|
"span",
|
|
8603
8636
|
{
|
|
8604
8637
|
style: { display: "inline-flex", alignItems: "center" },
|
|
@@ -8606,7 +8639,7 @@ const FixedToolbarComponent = vue.defineComponent({
|
|
|
8606
8639
|
}
|
|
8607
8640
|
)
|
|
8608
8641
|
),
|
|
8609
|
-
/* @__PURE__ */
|
|
8642
|
+
/* @__PURE__ */ h(
|
|
8610
8643
|
"div",
|
|
8611
8644
|
{
|
|
8612
8645
|
style: {
|
|
@@ -8618,7 +8651,7 @@ const FixedToolbarComponent = vue.defineComponent({
|
|
|
8618
8651
|
}
|
|
8619
8652
|
)
|
|
8620
8653
|
],
|
|
8621
|
-
/* @__PURE__ */
|
|
8654
|
+
/* @__PURE__ */ h(
|
|
8622
8655
|
Toolbar,
|
|
8623
8656
|
{
|
|
8624
8657
|
ctx: props.ctx,
|
|
@@ -8629,7 +8662,7 @@ const FixedToolbarComponent = vue.defineComponent({
|
|
|
8629
8662
|
isFixed: true
|
|
8630
8663
|
}
|
|
8631
8664
|
),
|
|
8632
|
-
showShortcuts.value && /* @__PURE__ */
|
|
8665
|
+
showShortcuts.value && /* @__PURE__ */ h(ShortcutHelpModal, { ctx: props.ctx, visible: showShortcuts })
|
|
8633
8666
|
);
|
|
8634
8667
|
};
|
|
8635
8668
|
}
|
|
@@ -12147,6 +12180,7 @@ class Crepe extends CrepeBuilder {
|
|
|
12147
12180
|
/// Calling the constructor will not create the editor, you need to call `create` to create the editor.
|
|
12148
12181
|
constructor(config = {}) {
|
|
12149
12182
|
var _a;
|
|
12183
|
+
resetPopupCount();
|
|
12150
12184
|
const { features = {}, featureConfigs = {}, ...crepeBuilderConfig } = config;
|
|
12151
12185
|
const finalConfigs = lodashEs.defaultsDeep(featureConfigs, defaultConfig);
|
|
12152
12186
|
const fixedToolbarConfig = finalConfigs[CrepeFeature.FixedToolbar];
|
|
@@ -12167,6 +12201,10 @@ class Crepe extends CrepeBuilder {
|
|
|
12167
12201
|
}
|
|
12168
12202
|
}
|
|
12169
12203
|
super(crepeBuilderConfig);
|
|
12204
|
+
this.destroy = () => {
|
|
12205
|
+
resetPopupCount();
|
|
12206
|
+
return this.editor.destroy();
|
|
12207
|
+
};
|
|
12170
12208
|
const enabledFeatures = Object.entries({
|
|
12171
12209
|
...defaultFeatures,
|
|
12172
12210
|
...features
|
|
@@ -12179,24 +12217,47 @@ class Crepe extends CrepeBuilder {
|
|
|
12179
12217
|
this.on((listener) => {
|
|
12180
12218
|
listener.markdownUpdated((_, markdown) => {
|
|
12181
12219
|
try {
|
|
12182
|
-
const stored = localStorage.getItem("jvs-milkdown-data");
|
|
12183
|
-
let parsed = {};
|
|
12184
|
-
if (stored) {
|
|
12185
|
-
parsed = JSON.parse(stored);
|
|
12186
|
-
}
|
|
12187
|
-
if (!parsed.content) {
|
|
12188
|
-
parsed.content = {};
|
|
12189
|
-
}
|
|
12190
12220
|
const html = this.editor.action(utils$1.getHTML());
|
|
12191
12221
|
const docId = fixedToolbarConfig.id || "default";
|
|
12192
|
-
const
|
|
12193
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
|
|
12222
|
+
const saveToLocalStorage = (mdVal, htmlVal) => {
|
|
12223
|
+
try {
|
|
12224
|
+
const stored = localStorage.getItem("jvs-milkdown-data");
|
|
12225
|
+
let parsed = {};
|
|
12226
|
+
if (stored) {
|
|
12227
|
+
parsed = JSON.parse(stored);
|
|
12228
|
+
}
|
|
12229
|
+
if (!parsed.content) {
|
|
12230
|
+
parsed.content = {};
|
|
12231
|
+
}
|
|
12232
|
+
const currentEntry = parsed.content[docId];
|
|
12233
|
+
const hasChanged = !currentEntry || typeof currentEntry === "string" && currentEntry !== mdVal || typeof currentEntry === "object" && (currentEntry.markdown !== mdVal || currentEntry.html !== htmlVal);
|
|
12234
|
+
if (hasChanged) {
|
|
12235
|
+
parsed.content[docId] = {
|
|
12236
|
+
markdown: mdVal,
|
|
12237
|
+
html: htmlVal
|
|
12238
|
+
};
|
|
12239
|
+
localStorage.setItem(
|
|
12240
|
+
"jvs-milkdown-data",
|
|
12241
|
+
JSON.stringify(parsed)
|
|
12242
|
+
);
|
|
12243
|
+
}
|
|
12244
|
+
} catch (e) {
|
|
12245
|
+
console.error("Error saving content to localStorage:", e);
|
|
12246
|
+
}
|
|
12247
|
+
};
|
|
12248
|
+
const hasBlobUrl = /blob:https?:\/\//.test(markdown) || /blob:https?:\/\//.test(html);
|
|
12249
|
+
if (hasBlobUrl) {
|
|
12250
|
+
Promise.all([
|
|
12251
|
+
replaceBlobUrlsWithBase64(markdown),
|
|
12252
|
+
replaceBlobUrlsWithBase64(html)
|
|
12253
|
+
]).then(([base64Markdown, base64Html]) => {
|
|
12254
|
+
saveToLocalStorage(base64Markdown, base64Html);
|
|
12255
|
+
}).catch((e) => {
|
|
12256
|
+
console.error("Error converting blob URLs:", e);
|
|
12257
|
+
saveToLocalStorage(markdown, html);
|
|
12258
|
+
});
|
|
12259
|
+
} else {
|
|
12260
|
+
saveToLocalStorage(markdown, html);
|
|
12200
12261
|
}
|
|
12201
12262
|
} catch (e) {
|
|
12202
12263
|
console.error("Error saving content to localStorage:", e);
|
|
@@ -12208,6 +12269,29 @@ class Crepe extends CrepeBuilder {
|
|
|
12208
12269
|
}
|
|
12209
12270
|
/// This is an alias for the `CrepeFeature` enum.
|
|
12210
12271
|
Crepe.Feature = CrepeFeature;
|
|
12272
|
+
async function replaceBlobUrlsWithBase64(content) {
|
|
12273
|
+
const blobRegex = /blob:https?:\/\/[^\s'")>]+/g;
|
|
12274
|
+
const matches = content.match(blobRegex);
|
|
12275
|
+
if (!matches) return content;
|
|
12276
|
+
let result = content;
|
|
12277
|
+
const uniqueBlobs = Array.from(new Set(matches));
|
|
12278
|
+
for (const blobUrl of uniqueBlobs) {
|
|
12279
|
+
try {
|
|
12280
|
+
const response = await fetch(blobUrl);
|
|
12281
|
+
const blob = await response.blob();
|
|
12282
|
+
const base64 = await new Promise((resolve, reject) => {
|
|
12283
|
+
const reader = new FileReader();
|
|
12284
|
+
reader.onloadend = () => resolve(reader.result);
|
|
12285
|
+
reader.onerror = reject;
|
|
12286
|
+
reader.readAsDataURL(blob);
|
|
12287
|
+
});
|
|
12288
|
+
result = result.replaceAll(blobUrl, base64);
|
|
12289
|
+
} catch (e) {
|
|
12290
|
+
console.error("Failed to convert blob URL to base64:", blobUrl, e);
|
|
12291
|
+
}
|
|
12292
|
+
}
|
|
12293
|
+
return result;
|
|
12294
|
+
}
|
|
12211
12295
|
|
|
12212
12296
|
exports.Crepe = Crepe;
|
|
12213
12297
|
exports.CrepeBuilder = CrepeBuilder;
|