md-editor-v3 5.3.0-0 → 5.3.0-2
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/MdEditor.cjs +37 -31
- package/lib/cjs/chunks/config.cjs +1 -1
- package/lib/cjs/chunks/index.cjs +53 -3
- package/lib/cjs/chunks/index3.cjs +1 -1
- package/lib/es/MdEditor.mjs +37 -31
- package/lib/es/chunks/config.mjs +1 -1
- package/lib/es/chunks/index.mjs +53 -3
- package/lib/es/chunks/index3.mjs +1 -1
- package/lib/preview.css +10 -6
- package/lib/style.css +16 -7
- package/lib/types/MdEditor/Editor.d.ts +8 -1
- package/lib/types/MdEditor/config.d.ts +2 -1
- package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +2 -0
- package/lib/types/MdEditor/layouts/Content/composition/index.d.ts +1 -0
- package/lib/types/MdEditor/layouts/Content/composition/useRemount.d.ts +3 -0
- package/lib/types/MdEditor/layouts/Content/composition/useResize.d.ts +0 -1
- package/lib/types/MdEditor/layouts/Content/index.d.ts +4 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/code/index.d.ts +1 -0
- package/lib/types/MdEditor/layouts/Content/props.d.ts +9 -0
- package/lib/types/MdEditor/props.d.ts +32 -0
- package/lib/types/MdEditor/type.d.ts +1 -1
- package/lib/types/MdPreview/MdPreview.d.ts +5 -1
- package/lib/umd/index.js +31 -29
- package/package.json +2 -2
package/lib/cjs/MdEditor.cjs
CHANGED
|
@@ -1772,7 +1772,7 @@ const oneDark = [
|
|
|
1772
1772
|
oneDarkTheme,
|
|
1773
1773
|
language.syntaxHighlighting(oneDarkHighlightStyle)
|
|
1774
1774
|
];
|
|
1775
|
-
const chalky = "#e5c07b", coral = "
|
|
1775
|
+
const chalky = "#e5c07b", coral = "var(--md-color)", cyan = "#56b6c2", invalid = "#fff", ivory = "#3f4a54", stone = "#2d8cf0", malibu = "#2d8cf0", sage = "#3f4a54", whiskey = "#d19a66", violet = "#c678dd", darkBackground = "#f6f6f6", highlightBackground = "#ceedfa33", background = "var(--md-bk-color)", tooltipBackground = "var(--md-bk-color)", selection = "#bad5fa", cursor = "#3f4a54";
|
|
1776
1776
|
const oneLightTheme = view.EditorView.theme(
|
|
1777
1777
|
{
|
|
1778
1778
|
"&": {
|
|
@@ -2745,28 +2745,30 @@ const useCodeMirror = (props2) => {
|
|
|
2745
2745
|
};
|
|
2746
2746
|
};
|
|
2747
2747
|
const useResize = (props2, contentRef, resizeRef) => {
|
|
2748
|
+
const compatibledInputBoxWidth = vue.computed(() => {
|
|
2749
|
+
return /px$/.test(`${props2.inputBoxWidth}`) ? "50%" : props2.inputBoxWidth;
|
|
2750
|
+
});
|
|
2748
2751
|
const state2 = vue.reactive({
|
|
2749
|
-
resizedWidth:
|
|
2752
|
+
resizedWidth: compatibledInputBoxWidth.value
|
|
2750
2753
|
});
|
|
2751
2754
|
const inputWrapperStyle = vue.reactive({
|
|
2752
|
-
width:
|
|
2755
|
+
width: compatibledInputBoxWidth.value
|
|
2753
2756
|
});
|
|
2754
2757
|
const resizeOperateStyle = vue.reactive({
|
|
2755
|
-
left:
|
|
2758
|
+
left: compatibledInputBoxWidth.value,
|
|
2756
2759
|
display: "initial"
|
|
2757
2760
|
});
|
|
2758
|
-
const showPreviewWrapper = vue.ref(props2.setting.preview || props2.setting.htmlPreview);
|
|
2759
2761
|
const resizeMousemove = (e) => {
|
|
2760
2762
|
var _a, _b, _c;
|
|
2761
2763
|
const maxWidth = ((_a = contentRef.value) == null ? void 0 : _a.offsetWidth) || 0;
|
|
2762
2764
|
const contentX = ((_b = contentRef.value) == null ? void 0 : _b.getBoundingClientRect().x) || 0;
|
|
2763
2765
|
let nextWidth = e.x - contentX;
|
|
2764
|
-
if (nextWidth < config.MinInputBoxWidth) {
|
|
2765
|
-
nextWidth = config.MinInputBoxWidth;
|
|
2766
|
-
} else if (nextWidth > maxWidth - config.MinInputBoxWidth) {
|
|
2767
|
-
nextWidth = maxWidth - config.MinInputBoxWidth;
|
|
2766
|
+
if (nextWidth / maxWidth < config.MinInputBoxWidth) {
|
|
2767
|
+
nextWidth = maxWidth * config.MinInputBoxWidth;
|
|
2768
|
+
} else if (nextWidth > maxWidth - maxWidth * config.MinInputBoxWidth) {
|
|
2769
|
+
nextWidth = maxWidth - maxWidth * config.MinInputBoxWidth;
|
|
2768
2770
|
}
|
|
2769
|
-
const ibw = `${nextWidth}
|
|
2771
|
+
const ibw = `${nextWidth / maxWidth * 100}%`;
|
|
2770
2772
|
inputWrapperStyle.width = ibw;
|
|
2771
2773
|
resizeOperateStyle.left = ibw;
|
|
2772
2774
|
state2.resizedWidth = ibw;
|
|
@@ -2794,16 +2796,11 @@ const useResize = (props2, contentRef, resizeRef) => {
|
|
|
2794
2796
|
document.removeEventListener("mousedown", resizeMousedown);
|
|
2795
2797
|
document.removeEventListener("mouseup", resizeMouseup);
|
|
2796
2798
|
});
|
|
2797
|
-
vue.watch(
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
inputWrapperStyle.width = nVal;
|
|
2803
|
-
resizeOperateStyle.left = nVal;
|
|
2804
|
-
}
|
|
2805
|
-
}
|
|
2806
|
-
);
|
|
2799
|
+
vue.watch([compatibledInputBoxWidth], ([nVal]) => {
|
|
2800
|
+
state2.resizedWidth = nVal;
|
|
2801
|
+
inputWrapperStyle.width = nVal;
|
|
2802
|
+
resizeOperateStyle.left = nVal;
|
|
2803
|
+
});
|
|
2807
2804
|
vue.watch(
|
|
2808
2805
|
[
|
|
2809
2806
|
vue.toRef(props2.setting, "htmlPreview"),
|
|
@@ -2814,22 +2811,22 @@ const useResize = (props2, contentRef, resizeRef) => {
|
|
|
2814
2811
|
if (props2.setting.previewOnly) {
|
|
2815
2812
|
inputWrapperStyle.width = "0%";
|
|
2816
2813
|
resizeOperateStyle.display = "none";
|
|
2817
|
-
showPreviewWrapper.value = true;
|
|
2818
2814
|
} else if (!props2.setting.htmlPreview && !props2.setting.preview) {
|
|
2819
2815
|
inputWrapperStyle.width = "100%";
|
|
2820
2816
|
resizeOperateStyle.display = "none";
|
|
2821
|
-
showPreviewWrapper.value = false;
|
|
2822
2817
|
} else {
|
|
2823
2818
|
inputWrapperStyle.width = state2.resizedWidth;
|
|
2824
2819
|
resizeOperateStyle.display = "initial";
|
|
2825
|
-
showPreviewWrapper.value = true;
|
|
2826
2820
|
}
|
|
2827
2821
|
},
|
|
2828
2822
|
{
|
|
2829
2823
|
immediate: true
|
|
2830
2824
|
}
|
|
2831
2825
|
);
|
|
2832
|
-
return {
|
|
2826
|
+
return {
|
|
2827
|
+
inputWrapperStyle,
|
|
2828
|
+
resizeOperateStyle
|
|
2829
|
+
};
|
|
2833
2830
|
};
|
|
2834
2831
|
const smoothScroll = util.createSmoothScroll();
|
|
2835
2832
|
const Content = /* @__PURE__ */ vue.defineComponent({
|
|
@@ -2847,8 +2844,7 @@ const Content = /* @__PURE__ */ vue.defineComponent({
|
|
|
2847
2844
|
} = useCodeMirror(props2);
|
|
2848
2845
|
const {
|
|
2849
2846
|
inputWrapperStyle,
|
|
2850
|
-
resizeOperateStyle
|
|
2851
|
-
showPreviewWrapper
|
|
2847
|
+
resizeOperateStyle
|
|
2852
2848
|
} = useResize(props2, contentRef, resizeRef);
|
|
2853
2849
|
useAutoScroll(props2, html, codeMirrorUt);
|
|
2854
2850
|
ctx.expose({
|
|
@@ -2868,7 +2864,9 @@ const Content = /* @__PURE__ */ vue.defineComponent({
|
|
|
2868
2864
|
});
|
|
2869
2865
|
return () => {
|
|
2870
2866
|
return vue.createVNode("div", {
|
|
2871
|
-
"class": `${config.prefix}-content
|
|
2867
|
+
"class": `${config.prefix}-content`
|
|
2868
|
+
}, [vue.createVNode("div", {
|
|
2869
|
+
"class": `${config.prefix}-content-wrapper`,
|
|
2872
2870
|
"ref": contentRef
|
|
2873
2871
|
}, [vue.createVNode("div", {
|
|
2874
2872
|
"class": `${config.prefix}-input-wrapper`,
|
|
@@ -2896,10 +2894,11 @@ const Content = /* @__PURE__ */ vue.defineComponent({
|
|
|
2896
2894
|
"noImgZoomIn": props2.noImgZoomIn,
|
|
2897
2895
|
"sanitizeMermaid": props2.sanitizeMermaid,
|
|
2898
2896
|
"codeFoldable": props2.codeFoldable,
|
|
2899
|
-
"autoFoldThreshold": props2.autoFoldThreshold
|
|
2900
|
-
|
|
2897
|
+
"autoFoldThreshold": props2.autoFoldThreshold,
|
|
2898
|
+
"onRemount": props2.onRemount
|
|
2899
|
+
}, null)]), props2.catalogVisible && vue.createVNode(MdCatalog.MdCatalog, {
|
|
2901
2900
|
"theme": props2.theme,
|
|
2902
|
-
"class": `${config.prefix}-catalog-editor`,
|
|
2901
|
+
"class": `${config.prefix}-catalog-editor ${config.prefix}-catalog-${props2.catalogLayout}`,
|
|
2903
2902
|
"editorId": editorId,
|
|
2904
2903
|
"mdHeadingId": props2.mdHeadingId,
|
|
2905
2904
|
"key": "internal-catalog",
|
|
@@ -3242,7 +3241,14 @@ const Editor = /* @__PURE__ */ vue.defineComponent({
|
|
|
3242
3241
|
"sanitizeMermaid": props2.sanitizeMermaid,
|
|
3243
3242
|
"transformImgUrl": props2.transformImgUrl,
|
|
3244
3243
|
"codeFoldable": props2.codeFoldable,
|
|
3245
|
-
"autoFoldThreshold": props2.autoFoldThreshold
|
|
3244
|
+
"autoFoldThreshold": props2.autoFoldThreshold,
|
|
3245
|
+
"onRemount": () => {
|
|
3246
|
+
if (props2.onRemount) {
|
|
3247
|
+
props2.onRemount();
|
|
3248
|
+
}
|
|
3249
|
+
ctx.emit("onRemount");
|
|
3250
|
+
},
|
|
3251
|
+
"catalogLayout": props2.catalogLayout
|
|
3246
3252
|
}, null), props2.footers.length > 0 && vue.createVNode(Footer, {
|
|
3247
3253
|
"modelValue": props2.modelValue,
|
|
3248
3254
|
"footers": props2.footers,
|
package/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -95,7 +95,6 @@ const useCopyCode = (props, html, key) => {
|
|
|
95
95
|
vue.watch([html, key], htmlChanged);
|
|
96
96
|
vue.watch(() => props.setting.preview, settingPreviewChanged);
|
|
97
97
|
vue.watch(() => props.setting.htmlPreview, settingPreviewChanged);
|
|
98
|
-
vue.watch(() => ult.value, initCopyEntry);
|
|
99
98
|
vue.onMounted(initCopyEntry);
|
|
100
99
|
};
|
|
101
100
|
const useHighlight = (props) => {
|
|
@@ -656,6 +655,7 @@ const codetabs = (md, _opts) => {
|
|
|
656
655
|
<div class="${config.prefix}-code-action">
|
|
657
656
|
<span class="${config.prefix}-code-lang">${tokens[idx].info.trim()}</span>
|
|
658
657
|
<span class="${config.prefix}-copy-button" data-tips="${codeCodeText}"${isIcon ? " data-is-icon=true" : ""}>${copyBtnHtml}</span>
|
|
658
|
+
${_opts.extraTools || ""}
|
|
659
659
|
${tagContainer2 === "details" ? collapseTips : ""}
|
|
660
660
|
</div>
|
|
661
661
|
</${tagHeader2}>
|
|
@@ -724,6 +724,7 @@ const codetabs = (md, _opts) => {
|
|
|
724
724
|
<div class="${config.prefix}-code-action">
|
|
725
725
|
<span class="${config.prefix}-codetab-lang">${langs}</span>
|
|
726
726
|
<span class="${config.prefix}-copy-button" data-tips="${codeCodeText}"${isIcon ? " data-is-icon=true" : ""}>${copyBtnHtml}</span>
|
|
727
|
+
${_opts.extraTools || ""}
|
|
727
728
|
${tagContainer === "details" ? collapseTips : ""}
|
|
728
729
|
</div>
|
|
729
730
|
</${tagHeader}>
|
|
@@ -1089,6 +1090,23 @@ const useTaskState = (props, html) => {
|
|
|
1089
1090
|
}
|
|
1090
1091
|
);
|
|
1091
1092
|
};
|
|
1093
|
+
const useRemount = (props, html, key) => {
|
|
1094
|
+
const handler = () => {
|
|
1095
|
+
vue.nextTick(() => {
|
|
1096
|
+
var _a;
|
|
1097
|
+
(_a = props.onRemount) == null ? void 0 : _a.call(props);
|
|
1098
|
+
});
|
|
1099
|
+
};
|
|
1100
|
+
const settingPreviewChanged = (nVal) => {
|
|
1101
|
+
if (nVal) {
|
|
1102
|
+
handler();
|
|
1103
|
+
}
|
|
1104
|
+
};
|
|
1105
|
+
vue.watch([html, key], handler);
|
|
1106
|
+
vue.watch(() => props.setting.preview, settingPreviewChanged);
|
|
1107
|
+
vue.watch(() => props.setting.htmlPreview, settingPreviewChanged);
|
|
1108
|
+
vue.onMounted(handler);
|
|
1109
|
+
};
|
|
1092
1110
|
const contentPreviewProps = {
|
|
1093
1111
|
modelValue: {
|
|
1094
1112
|
type: String,
|
|
@@ -1153,6 +1171,9 @@ const contentPreviewProps = {
|
|
|
1153
1171
|
},
|
|
1154
1172
|
autoFoldThreshold: {
|
|
1155
1173
|
type: Number
|
|
1174
|
+
},
|
|
1175
|
+
onRemount: {
|
|
1176
|
+
type: Function
|
|
1156
1177
|
}
|
|
1157
1178
|
};
|
|
1158
1179
|
const contentProps = {
|
|
@@ -1230,6 +1251,9 @@ const contentProps = {
|
|
|
1230
1251
|
transformImgUrl: {
|
|
1231
1252
|
type: Function,
|
|
1232
1253
|
default: (t) => t
|
|
1254
|
+
},
|
|
1255
|
+
catalogLayout: {
|
|
1256
|
+
type: String
|
|
1233
1257
|
}
|
|
1234
1258
|
};
|
|
1235
1259
|
const ContentPreview = /* @__PURE__ */ vue.defineComponent({
|
|
@@ -1246,6 +1270,7 @@ const ContentPreview = /* @__PURE__ */ vue.defineComponent({
|
|
|
1246
1270
|
useCopyCode(props, html, key);
|
|
1247
1271
|
userZoom(props, html);
|
|
1248
1272
|
useTaskState(props, html);
|
|
1273
|
+
useRemount(props, html, key);
|
|
1249
1274
|
return () => {
|
|
1250
1275
|
return vue.createVNode(vue.Fragment, null, [props.setting.preview && vue.createVNode("div", {
|
|
1251
1276
|
"id": `${editorId}-preview-wrapper`,
|
|
@@ -1895,6 +1920,15 @@ const mdPreviewProps = {
|
|
|
1895
1920
|
autoFoldThreshold: {
|
|
1896
1921
|
type: Number,
|
|
1897
1922
|
default: 30
|
|
1923
|
+
},
|
|
1924
|
+
/**
|
|
1925
|
+
* 内容重新挂载事件
|
|
1926
|
+
*
|
|
1927
|
+
* 相比起onHtmlChanged,onRemount会在重新挂载后触发
|
|
1928
|
+
*/
|
|
1929
|
+
onRemount: {
|
|
1930
|
+
type: Function,
|
|
1931
|
+
default: void 0
|
|
1898
1932
|
}
|
|
1899
1933
|
};
|
|
1900
1934
|
const editorProps = {
|
|
@@ -2171,6 +2205,20 @@ const editorProps = {
|
|
|
2171
2205
|
transformImgUrl: {
|
|
2172
2206
|
type: Function,
|
|
2173
2207
|
default: (t) => t
|
|
2208
|
+
},
|
|
2209
|
+
/**
|
|
2210
|
+
* 内置的目录显示的状态
|
|
2211
|
+
*
|
|
2212
|
+
* 'fixed': 悬浮在内容上方
|
|
2213
|
+
* 'flat': 展示在右侧
|
|
2214
|
+
*
|
|
2215
|
+
* \>=5.3.0
|
|
2216
|
+
*
|
|
2217
|
+
* @default 'fixed'
|
|
2218
|
+
*/
|
|
2219
|
+
catalogLayout: {
|
|
2220
|
+
type: String,
|
|
2221
|
+
default: "fixed"
|
|
2174
2222
|
}
|
|
2175
2223
|
};
|
|
2176
2224
|
const mdPreviewEmits = [
|
|
@@ -2188,7 +2236,8 @@ const editorEmits = [
|
|
|
2188
2236
|
"onFocus",
|
|
2189
2237
|
"onInput",
|
|
2190
2238
|
"onDrop",
|
|
2191
|
-
"oninputBoxWidthChange"
|
|
2239
|
+
"oninputBoxWidthChange",
|
|
2240
|
+
"onRemount"
|
|
2192
2241
|
];
|
|
2193
2242
|
const useExpose = (props, ctx, options) => {
|
|
2194
2243
|
const { editorId } = options;
|
|
@@ -2258,7 +2307,8 @@ const MdPreview = /* @__PURE__ */ vue.defineComponent({
|
|
|
2258
2307
|
"previewOnly": true,
|
|
2259
2308
|
"sanitizeMermaid": props.sanitizeMermaid,
|
|
2260
2309
|
"codeFoldable": props.codeFoldable,
|
|
2261
|
-
"autoFoldThreshold": props.autoFoldThreshold
|
|
2310
|
+
"autoFoldThreshold": props.autoFoldThreshold,
|
|
2311
|
+
"onRemount": props.onRemount
|
|
2262
2312
|
}, null)]);
|
|
2263
2313
|
};
|
|
2264
2314
|
}
|
|
@@ -586,7 +586,7 @@ const MdCatalog = /* @__PURE__ */ vue.defineComponent({
|
|
|
586
586
|
const getEditorView = (view) => {
|
|
587
587
|
editorViewRef.value = view;
|
|
588
588
|
};
|
|
589
|
-
vue.watch(() => props2.syncWith, () => {
|
|
589
|
+
vue.watch([() => props2.syncWith, editorViewRef], () => {
|
|
590
590
|
catalogChangedHandler(state.list);
|
|
591
591
|
});
|
|
592
592
|
vue.onMounted(() => {
|
package/lib/es/MdEditor.mjs
CHANGED
|
@@ -1771,7 +1771,7 @@ const oneDark = [
|
|
|
1771
1771
|
oneDarkTheme,
|
|
1772
1772
|
syntaxHighlighting(oneDarkHighlightStyle)
|
|
1773
1773
|
];
|
|
1774
|
-
const chalky = "#e5c07b", coral = "
|
|
1774
|
+
const chalky = "#e5c07b", coral = "var(--md-color)", cyan = "#56b6c2", invalid = "#fff", ivory = "#3f4a54", stone = "#2d8cf0", malibu = "#2d8cf0", sage = "#3f4a54", whiskey = "#d19a66", violet = "#c678dd", darkBackground = "#f6f6f6", highlightBackground = "#ceedfa33", background = "var(--md-bk-color)", tooltipBackground = "var(--md-bk-color)", selection = "#bad5fa", cursor = "#3f4a54";
|
|
1775
1775
|
const oneLightTheme = EditorView.theme(
|
|
1776
1776
|
{
|
|
1777
1777
|
"&": {
|
|
@@ -2744,28 +2744,30 @@ const useCodeMirror = (props2) => {
|
|
|
2744
2744
|
};
|
|
2745
2745
|
};
|
|
2746
2746
|
const useResize = (props2, contentRef, resizeRef) => {
|
|
2747
|
+
const compatibledInputBoxWidth = computed(() => {
|
|
2748
|
+
return /px$/.test(`${props2.inputBoxWidth}`) ? "50%" : props2.inputBoxWidth;
|
|
2749
|
+
});
|
|
2747
2750
|
const state = reactive({
|
|
2748
|
-
resizedWidth:
|
|
2751
|
+
resizedWidth: compatibledInputBoxWidth.value
|
|
2749
2752
|
});
|
|
2750
2753
|
const inputWrapperStyle = reactive({
|
|
2751
|
-
width:
|
|
2754
|
+
width: compatibledInputBoxWidth.value
|
|
2752
2755
|
});
|
|
2753
2756
|
const resizeOperateStyle = reactive({
|
|
2754
|
-
left:
|
|
2757
|
+
left: compatibledInputBoxWidth.value,
|
|
2755
2758
|
display: "initial"
|
|
2756
2759
|
});
|
|
2757
|
-
const showPreviewWrapper = ref(props2.setting.preview || props2.setting.htmlPreview);
|
|
2758
2760
|
const resizeMousemove = (e) => {
|
|
2759
2761
|
var _a, _b, _c;
|
|
2760
2762
|
const maxWidth = ((_a = contentRef.value) == null ? void 0 : _a.offsetWidth) || 0;
|
|
2761
2763
|
const contentX = ((_b = contentRef.value) == null ? void 0 : _b.getBoundingClientRect().x) || 0;
|
|
2762
2764
|
let nextWidth = e.x - contentX;
|
|
2763
|
-
if (nextWidth < MinInputBoxWidth) {
|
|
2764
|
-
nextWidth = MinInputBoxWidth;
|
|
2765
|
-
} else if (nextWidth > maxWidth - MinInputBoxWidth) {
|
|
2766
|
-
nextWidth = maxWidth - MinInputBoxWidth;
|
|
2765
|
+
if (nextWidth / maxWidth < MinInputBoxWidth) {
|
|
2766
|
+
nextWidth = maxWidth * MinInputBoxWidth;
|
|
2767
|
+
} else if (nextWidth > maxWidth - maxWidth * MinInputBoxWidth) {
|
|
2768
|
+
nextWidth = maxWidth - maxWidth * MinInputBoxWidth;
|
|
2767
2769
|
}
|
|
2768
|
-
const ibw = `${nextWidth}
|
|
2770
|
+
const ibw = `${nextWidth / maxWidth * 100}%`;
|
|
2769
2771
|
inputWrapperStyle.width = ibw;
|
|
2770
2772
|
resizeOperateStyle.left = ibw;
|
|
2771
2773
|
state.resizedWidth = ibw;
|
|
@@ -2793,16 +2795,11 @@ const useResize = (props2, contentRef, resizeRef) => {
|
|
|
2793
2795
|
document.removeEventListener("mousedown", resizeMousedown);
|
|
2794
2796
|
document.removeEventListener("mouseup", resizeMouseup);
|
|
2795
2797
|
});
|
|
2796
|
-
watch(
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
inputWrapperStyle.width = nVal;
|
|
2802
|
-
resizeOperateStyle.left = nVal;
|
|
2803
|
-
}
|
|
2804
|
-
}
|
|
2805
|
-
);
|
|
2798
|
+
watch([compatibledInputBoxWidth], ([nVal]) => {
|
|
2799
|
+
state.resizedWidth = nVal;
|
|
2800
|
+
inputWrapperStyle.width = nVal;
|
|
2801
|
+
resizeOperateStyle.left = nVal;
|
|
2802
|
+
});
|
|
2806
2803
|
watch(
|
|
2807
2804
|
[
|
|
2808
2805
|
toRef(props2.setting, "htmlPreview"),
|
|
@@ -2813,22 +2810,22 @@ const useResize = (props2, contentRef, resizeRef) => {
|
|
|
2813
2810
|
if (props2.setting.previewOnly) {
|
|
2814
2811
|
inputWrapperStyle.width = "0%";
|
|
2815
2812
|
resizeOperateStyle.display = "none";
|
|
2816
|
-
showPreviewWrapper.value = true;
|
|
2817
2813
|
} else if (!props2.setting.htmlPreview && !props2.setting.preview) {
|
|
2818
2814
|
inputWrapperStyle.width = "100%";
|
|
2819
2815
|
resizeOperateStyle.display = "none";
|
|
2820
|
-
showPreviewWrapper.value = false;
|
|
2821
2816
|
} else {
|
|
2822
2817
|
inputWrapperStyle.width = state.resizedWidth;
|
|
2823
2818
|
resizeOperateStyle.display = "initial";
|
|
2824
|
-
showPreviewWrapper.value = true;
|
|
2825
2819
|
}
|
|
2826
2820
|
},
|
|
2827
2821
|
{
|
|
2828
2822
|
immediate: true
|
|
2829
2823
|
}
|
|
2830
2824
|
);
|
|
2831
|
-
return {
|
|
2825
|
+
return {
|
|
2826
|
+
inputWrapperStyle,
|
|
2827
|
+
resizeOperateStyle
|
|
2828
|
+
};
|
|
2832
2829
|
};
|
|
2833
2830
|
const smoothScroll = createSmoothScroll();
|
|
2834
2831
|
const Content = /* @__PURE__ */ defineComponent({
|
|
@@ -2846,8 +2843,7 @@ const Content = /* @__PURE__ */ defineComponent({
|
|
|
2846
2843
|
} = useCodeMirror(props2);
|
|
2847
2844
|
const {
|
|
2848
2845
|
inputWrapperStyle,
|
|
2849
|
-
resizeOperateStyle
|
|
2850
|
-
showPreviewWrapper
|
|
2846
|
+
resizeOperateStyle
|
|
2851
2847
|
} = useResize(props2, contentRef, resizeRef);
|
|
2852
2848
|
useAutoScroll(props2, html, codeMirrorUt);
|
|
2853
2849
|
ctx.expose({
|
|
@@ -2867,7 +2863,9 @@ const Content = /* @__PURE__ */ defineComponent({
|
|
|
2867
2863
|
});
|
|
2868
2864
|
return () => {
|
|
2869
2865
|
return createVNode("div", {
|
|
2870
|
-
"class": `${prefix}-content
|
|
2866
|
+
"class": `${prefix}-content`
|
|
2867
|
+
}, [createVNode("div", {
|
|
2868
|
+
"class": `${prefix}-content-wrapper`,
|
|
2871
2869
|
"ref": contentRef
|
|
2872
2870
|
}, [createVNode("div", {
|
|
2873
2871
|
"class": `${prefix}-input-wrapper`,
|
|
@@ -2895,10 +2893,11 @@ const Content = /* @__PURE__ */ defineComponent({
|
|
|
2895
2893
|
"noImgZoomIn": props2.noImgZoomIn,
|
|
2896
2894
|
"sanitizeMermaid": props2.sanitizeMermaid,
|
|
2897
2895
|
"codeFoldable": props2.codeFoldable,
|
|
2898
|
-
"autoFoldThreshold": props2.autoFoldThreshold
|
|
2899
|
-
|
|
2896
|
+
"autoFoldThreshold": props2.autoFoldThreshold,
|
|
2897
|
+
"onRemount": props2.onRemount
|
|
2898
|
+
}, null)]), props2.catalogVisible && createVNode(MdCatalog, {
|
|
2900
2899
|
"theme": props2.theme,
|
|
2901
|
-
"class": `${prefix}-catalog-editor`,
|
|
2900
|
+
"class": `${prefix}-catalog-editor ${prefix}-catalog-${props2.catalogLayout}`,
|
|
2902
2901
|
"editorId": editorId,
|
|
2903
2902
|
"mdHeadingId": props2.mdHeadingId,
|
|
2904
2903
|
"key": "internal-catalog",
|
|
@@ -3241,7 +3240,14 @@ const Editor = /* @__PURE__ */ defineComponent({
|
|
|
3241
3240
|
"sanitizeMermaid": props2.sanitizeMermaid,
|
|
3242
3241
|
"transformImgUrl": props2.transformImgUrl,
|
|
3243
3242
|
"codeFoldable": props2.codeFoldable,
|
|
3244
|
-
"autoFoldThreshold": props2.autoFoldThreshold
|
|
3243
|
+
"autoFoldThreshold": props2.autoFoldThreshold,
|
|
3244
|
+
"onRemount": () => {
|
|
3245
|
+
if (props2.onRemount) {
|
|
3246
|
+
props2.onRemount();
|
|
3247
|
+
}
|
|
3248
|
+
ctx.emit("onRemount");
|
|
3249
|
+
},
|
|
3250
|
+
"catalogLayout": props2.catalogLayout
|
|
3245
3251
|
}, null), props2.footers.length > 0 && createVNode(Footer, {
|
|
3246
3252
|
"modelValue": props2.modelValue,
|
|
3247
3253
|
"footers": props2.footers,
|
package/lib/es/chunks/config.mjs
CHANGED
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -94,7 +94,6 @@ const useCopyCode = (props, html, key) => {
|
|
|
94
94
|
watch([html, key], htmlChanged);
|
|
95
95
|
watch(() => props.setting.preview, settingPreviewChanged);
|
|
96
96
|
watch(() => props.setting.htmlPreview, settingPreviewChanged);
|
|
97
|
-
watch(() => ult.value, initCopyEntry);
|
|
98
97
|
onMounted(initCopyEntry);
|
|
99
98
|
};
|
|
100
99
|
const useHighlight = (props) => {
|
|
@@ -655,6 +654,7 @@ const codetabs = (md, _opts) => {
|
|
|
655
654
|
<div class="${prefix}-code-action">
|
|
656
655
|
<span class="${prefix}-code-lang">${tokens[idx].info.trim()}</span>
|
|
657
656
|
<span class="${prefix}-copy-button" data-tips="${codeCodeText}"${isIcon ? " data-is-icon=true" : ""}>${copyBtnHtml}</span>
|
|
657
|
+
${_opts.extraTools || ""}
|
|
658
658
|
${tagContainer2 === "details" ? collapseTips : ""}
|
|
659
659
|
</div>
|
|
660
660
|
</${tagHeader2}>
|
|
@@ -723,6 +723,7 @@ const codetabs = (md, _opts) => {
|
|
|
723
723
|
<div class="${prefix}-code-action">
|
|
724
724
|
<span class="${prefix}-codetab-lang">${langs}</span>
|
|
725
725
|
<span class="${prefix}-copy-button" data-tips="${codeCodeText}"${isIcon ? " data-is-icon=true" : ""}>${copyBtnHtml}</span>
|
|
726
|
+
${_opts.extraTools || ""}
|
|
726
727
|
${tagContainer === "details" ? collapseTips : ""}
|
|
727
728
|
</div>
|
|
728
729
|
</${tagHeader}>
|
|
@@ -1088,6 +1089,23 @@ const useTaskState = (props, html) => {
|
|
|
1088
1089
|
}
|
|
1089
1090
|
);
|
|
1090
1091
|
};
|
|
1092
|
+
const useRemount = (props, html, key) => {
|
|
1093
|
+
const handler = () => {
|
|
1094
|
+
nextTick(() => {
|
|
1095
|
+
var _a;
|
|
1096
|
+
(_a = props.onRemount) == null ? void 0 : _a.call(props);
|
|
1097
|
+
});
|
|
1098
|
+
};
|
|
1099
|
+
const settingPreviewChanged = (nVal) => {
|
|
1100
|
+
if (nVal) {
|
|
1101
|
+
handler();
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
watch([html, key], handler);
|
|
1105
|
+
watch(() => props.setting.preview, settingPreviewChanged);
|
|
1106
|
+
watch(() => props.setting.htmlPreview, settingPreviewChanged);
|
|
1107
|
+
onMounted(handler);
|
|
1108
|
+
};
|
|
1091
1109
|
const contentPreviewProps = {
|
|
1092
1110
|
modelValue: {
|
|
1093
1111
|
type: String,
|
|
@@ -1152,6 +1170,9 @@ const contentPreviewProps = {
|
|
|
1152
1170
|
},
|
|
1153
1171
|
autoFoldThreshold: {
|
|
1154
1172
|
type: Number
|
|
1173
|
+
},
|
|
1174
|
+
onRemount: {
|
|
1175
|
+
type: Function
|
|
1155
1176
|
}
|
|
1156
1177
|
};
|
|
1157
1178
|
const contentProps = {
|
|
@@ -1229,6 +1250,9 @@ const contentProps = {
|
|
|
1229
1250
|
transformImgUrl: {
|
|
1230
1251
|
type: Function,
|
|
1231
1252
|
default: (t) => t
|
|
1253
|
+
},
|
|
1254
|
+
catalogLayout: {
|
|
1255
|
+
type: String
|
|
1232
1256
|
}
|
|
1233
1257
|
};
|
|
1234
1258
|
const ContentPreview = /* @__PURE__ */ defineComponent({
|
|
@@ -1245,6 +1269,7 @@ const ContentPreview = /* @__PURE__ */ defineComponent({
|
|
|
1245
1269
|
useCopyCode(props, html, key);
|
|
1246
1270
|
userZoom(props, html);
|
|
1247
1271
|
useTaskState(props, html);
|
|
1272
|
+
useRemount(props, html, key);
|
|
1248
1273
|
return () => {
|
|
1249
1274
|
return createVNode(Fragment, null, [props.setting.preview && createVNode("div", {
|
|
1250
1275
|
"id": `${editorId}-preview-wrapper`,
|
|
@@ -1894,6 +1919,15 @@ const mdPreviewProps = {
|
|
|
1894
1919
|
autoFoldThreshold: {
|
|
1895
1920
|
type: Number,
|
|
1896
1921
|
default: 30
|
|
1922
|
+
},
|
|
1923
|
+
/**
|
|
1924
|
+
* 内容重新挂载事件
|
|
1925
|
+
*
|
|
1926
|
+
* 相比起onHtmlChanged,onRemount会在重新挂载后触发
|
|
1927
|
+
*/
|
|
1928
|
+
onRemount: {
|
|
1929
|
+
type: Function,
|
|
1930
|
+
default: void 0
|
|
1897
1931
|
}
|
|
1898
1932
|
};
|
|
1899
1933
|
const editorProps = {
|
|
@@ -2170,6 +2204,20 @@ const editorProps = {
|
|
|
2170
2204
|
transformImgUrl: {
|
|
2171
2205
|
type: Function,
|
|
2172
2206
|
default: (t) => t
|
|
2207
|
+
},
|
|
2208
|
+
/**
|
|
2209
|
+
* 内置的目录显示的状态
|
|
2210
|
+
*
|
|
2211
|
+
* 'fixed': 悬浮在内容上方
|
|
2212
|
+
* 'flat': 展示在右侧
|
|
2213
|
+
*
|
|
2214
|
+
* \>=5.3.0
|
|
2215
|
+
*
|
|
2216
|
+
* @default 'fixed'
|
|
2217
|
+
*/
|
|
2218
|
+
catalogLayout: {
|
|
2219
|
+
type: String,
|
|
2220
|
+
default: "fixed"
|
|
2173
2221
|
}
|
|
2174
2222
|
};
|
|
2175
2223
|
const mdPreviewEmits = [
|
|
@@ -2187,7 +2235,8 @@ const editorEmits = [
|
|
|
2187
2235
|
"onFocus",
|
|
2188
2236
|
"onInput",
|
|
2189
2237
|
"onDrop",
|
|
2190
|
-
"oninputBoxWidthChange"
|
|
2238
|
+
"oninputBoxWidthChange",
|
|
2239
|
+
"onRemount"
|
|
2191
2240
|
];
|
|
2192
2241
|
const useExpose = (props, ctx, options) => {
|
|
2193
2242
|
const { editorId } = options;
|
|
@@ -2257,7 +2306,8 @@ const MdPreview = /* @__PURE__ */ defineComponent({
|
|
|
2257
2306
|
"previewOnly": true,
|
|
2258
2307
|
"sanitizeMermaid": props.sanitizeMermaid,
|
|
2259
2308
|
"codeFoldable": props.codeFoldable,
|
|
2260
|
-
"autoFoldThreshold": props.autoFoldThreshold
|
|
2309
|
+
"autoFoldThreshold": props.autoFoldThreshold,
|
|
2310
|
+
"onRemount": props.onRemount
|
|
2261
2311
|
}, null)]);
|
|
2262
2312
|
};
|
|
2263
2313
|
}
|
package/lib/es/chunks/index3.mjs
CHANGED
|
@@ -585,7 +585,7 @@ const MdCatalog = /* @__PURE__ */ defineComponent({
|
|
|
585
585
|
const getEditorView = (view) => {
|
|
586
586
|
editorViewRef.value = view;
|
|
587
587
|
};
|
|
588
|
-
watch(() => props2.syncWith, () => {
|
|
588
|
+
watch([() => props2.syncWith, editorViewRef], () => {
|
|
589
589
|
catalogChangedHandler(state.list);
|
|
590
590
|
});
|
|
591
591
|
onMounted(() => {
|