md-editor-v3 6.0.0-0 → 6.0.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 +39 -26
- package/lib/cjs/chunks/index3.cjs +30 -14
- package/lib/cjs/chunks/index4.cjs +14 -2
- package/lib/es/MdEditor.mjs +39 -26
- package/lib/es/chunks/index3.mjs +30 -14
- package/lib/es/chunks/index4.mjs +14 -2
- package/lib/types/MdEditor/type.d.ts +10 -2
- package/lib/umd/index.js +91 -91
- package/lib/umd/preview.js +18 -18
- package/package.json +1 -1
package/lib/cjs/MdEditor.cjs
CHANGED
|
@@ -35,13 +35,13 @@ const useAutoScroll = (props2, html, codeMirrorUt) => {
|
|
|
35
35
|
var _a;
|
|
36
36
|
clearScrollAuto();
|
|
37
37
|
const rootNode = (_a = codeMirrorUt.value) == null ? void 0 : _a.view.contentDOM.getRootNode();
|
|
38
|
-
const cmScroller = rootNode.querySelector(
|
|
38
|
+
const cmScroller = rootNode == null ? void 0 : rootNode.querySelector(
|
|
39
39
|
`#${editorId} .cm-scroller`
|
|
40
40
|
);
|
|
41
|
-
const previewEle = rootNode.querySelector(
|
|
41
|
+
const previewEle = rootNode == null ? void 0 : rootNode.querySelector(
|
|
42
42
|
`[id="${editorId}-preview-wrapper"]`
|
|
43
43
|
);
|
|
44
|
-
const htmlEle = rootNode.querySelector(
|
|
44
|
+
const htmlEle = rootNode == null ? void 0 : rootNode.querySelector(
|
|
45
45
|
`[id="${editorId}-html-wrapper"]`
|
|
46
46
|
);
|
|
47
47
|
if (previewEle || htmlEle) {
|
|
@@ -2826,10 +2826,11 @@ const useCodeMirror = (props2) => {
|
|
|
2826
2826
|
const catalogVisible = vue.inject("catalogVisible");
|
|
2827
2827
|
const defToolbars = vue.inject("defToolbars");
|
|
2828
2828
|
const floatingToolbars = vue.inject("floatingToolbars");
|
|
2829
|
+
const rootRef = vue.inject("rootRef");
|
|
2829
2830
|
const inputWrapperRef = vue.ref();
|
|
2830
2831
|
const codeMirrorUt = vue.shallowRef();
|
|
2831
2832
|
const spelling = vue.ref(false);
|
|
2832
|
-
const languageComp = new state.Compartment(), themeComp = new state.Compartment(), autocompletionComp = new state.Compartment(), historyComp = new state.Compartment(), eventComp = new state.Compartment();
|
|
2833
|
+
const languageComp = new state.Compartment(), themeComp = new state.Compartment(), autocompletionComp = new state.Compartment(), historyComp = new state.Compartment(), eventComp = new state.Compartment(), floatingToolbarComp = new state.Compartment();
|
|
2833
2834
|
const mdEditorCommands = createCommands(editorId, {
|
|
2834
2835
|
noPrettier
|
|
2835
2836
|
});
|
|
@@ -2866,6 +2867,29 @@ const useCodeMirror = (props2) => {
|
|
|
2866
2867
|
}
|
|
2867
2868
|
}
|
|
2868
2869
|
};
|
|
2870
|
+
const floatingToolbarPlugin = createFloatingToolbarPlugin({
|
|
2871
|
+
privide(app) {
|
|
2872
|
+
app.provide("editorId", editorId);
|
|
2873
|
+
app.provide("theme", theme);
|
|
2874
|
+
app.provide("previewTheme", previewTheme);
|
|
2875
|
+
app.provide("language", language2);
|
|
2876
|
+
app.provide("disabled", disabled);
|
|
2877
|
+
app.provide("noUploadImg", noUploadImg);
|
|
2878
|
+
app.provide("tableShape", tableShape);
|
|
2879
|
+
app.provide("noPrettier", noPrettier);
|
|
2880
|
+
app.provide("codeTheme", codeTheme);
|
|
2881
|
+
app.provide("showToolbarName", showToolbarName);
|
|
2882
|
+
app.provide("setting", setting);
|
|
2883
|
+
app.provide("updateSetting", updateSetting);
|
|
2884
|
+
app.provide("usedLanguageText", usedLanguageText);
|
|
2885
|
+
app.provide("catalogVisible", catalogVisible);
|
|
2886
|
+
app.provide("defToolbars", defToolbars);
|
|
2887
|
+
app.provide("tabWidth", tabWidth);
|
|
2888
|
+
app.provide("customIcon", customIcon);
|
|
2889
|
+
app.provide("floatingToolbars", floatingToolbars);
|
|
2890
|
+
app.provide("rootRef", rootRef);
|
|
2891
|
+
}
|
|
2892
|
+
});
|
|
2869
2893
|
const defaultExtensions = [
|
|
2870
2894
|
{
|
|
2871
2895
|
type: "keymap",
|
|
@@ -2915,28 +2939,8 @@ const useCodeMirror = (props2) => {
|
|
|
2915
2939
|
},
|
|
2916
2940
|
{
|
|
2917
2941
|
type: "floatingToolbar",
|
|
2918
|
-
extension:
|
|
2919
|
-
|
|
2920
|
-
app.provide("editorId", editorId);
|
|
2921
|
-
app.provide("theme", theme);
|
|
2922
|
-
app.provide("previewTheme", previewTheme);
|
|
2923
|
-
app.provide("language", language2);
|
|
2924
|
-
app.provide("disabled", disabled);
|
|
2925
|
-
app.provide("noUploadImg", noUploadImg);
|
|
2926
|
-
app.provide("tableShape", tableShape);
|
|
2927
|
-
app.provide("noPrettier", noPrettier);
|
|
2928
|
-
app.provide("codeTheme", codeTheme);
|
|
2929
|
-
app.provide("showToolbarName", showToolbarName);
|
|
2930
|
-
app.provide("setting", setting);
|
|
2931
|
-
app.provide("updateSetting", updateSetting);
|
|
2932
|
-
app.provide("usedLanguageText", usedLanguageText);
|
|
2933
|
-
app.provide("catalogVisible", catalogVisible);
|
|
2934
|
-
app.provide("defToolbars", defToolbars);
|
|
2935
|
-
app.provide("tabWidth", tabWidth);
|
|
2936
|
-
app.provide("customIcon", customIcon);
|
|
2937
|
-
app.provide("floatingToolbars", floatingToolbars);
|
|
2938
|
-
}
|
|
2939
|
-
})
|
|
2942
|
+
extension: floatingToolbars.value.length > 0 ? floatingToolbarPlugin : [],
|
|
2943
|
+
compartment: floatingToolbarComp
|
|
2940
2944
|
}
|
|
2941
2945
|
];
|
|
2942
2946
|
const getExtensions = () => {
|
|
@@ -3123,6 +3127,15 @@ const useCodeMirror = (props2) => {
|
|
|
3123
3127
|
}
|
|
3124
3128
|
}
|
|
3125
3129
|
);
|
|
3130
|
+
vue.watch([floatingToolbars], () => {
|
|
3131
|
+
var _a, _b;
|
|
3132
|
+
if (floatingToolbars.value.length > 0) {
|
|
3133
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.view.dispatch({
|
|
3134
|
+
effects: floatingToolbarComp.reconfigure(floatingToolbarPlugin)
|
|
3135
|
+
});
|
|
3136
|
+
} else
|
|
3137
|
+
(_b = codeMirrorUt.value) == null ? void 0 : _b.view.dispatch({ effects: floatingToolbarComp.reconfigure([]) });
|
|
3138
|
+
});
|
|
3126
3139
|
return {
|
|
3127
3140
|
inputWrapperRef,
|
|
3128
3141
|
codeMirrorUt,
|
|
@@ -553,7 +553,7 @@ const useEcharts = (props) => {
|
|
|
553
553
|
configEcharts();
|
|
554
554
|
}
|
|
555
555
|
},
|
|
556
|
-
"
|
|
556
|
+
"echarts"
|
|
557
557
|
);
|
|
558
558
|
});
|
|
559
559
|
let mermaidSourceEles;
|
|
@@ -582,16 +582,24 @@ const useEcharts = (props) => {
|
|
|
582
582
|
if (item.dataset.closed === "false") {
|
|
583
583
|
return false;
|
|
584
584
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
585
|
+
try {
|
|
586
|
+
const options = new Function(`return ${item.innerText}`)();
|
|
587
|
+
const ins = echarts.init(item, theme.value);
|
|
588
|
+
ins.setOption(options);
|
|
589
|
+
item.setAttribute("data-processed", "");
|
|
590
|
+
echartsInstances.push(ins);
|
|
591
|
+
const observer = new ResizeObserver(() => {
|
|
592
|
+
ins.resize();
|
|
593
|
+
});
|
|
594
|
+
observer.observe(item);
|
|
595
|
+
observers.push(observer);
|
|
596
|
+
} catch (error) {
|
|
597
|
+
eventBus.bus.emit(editorId, eventBus.ERROR_CATCHER, {
|
|
598
|
+
name: "echarts",
|
|
599
|
+
message: error == null ? void 0 : error.message,
|
|
600
|
+
error
|
|
601
|
+
});
|
|
602
|
+
}
|
|
595
603
|
});
|
|
596
604
|
}
|
|
597
605
|
};
|
|
@@ -1091,12 +1099,20 @@ const HeadingPlugin = (md, options) => {
|
|
|
1091
1099
|
options.headsRef.value.push({
|
|
1092
1100
|
text,
|
|
1093
1101
|
level,
|
|
1094
|
-
line: token.map[0]
|
|
1102
|
+
line: token.map[0],
|
|
1103
|
+
currentToken: token,
|
|
1104
|
+
nextToken: tokens[idx + 1]
|
|
1095
1105
|
});
|
|
1096
1106
|
if (token.map && token.level === 0) {
|
|
1097
1107
|
token.attrSet(
|
|
1098
1108
|
"id",
|
|
1099
|
-
options.mdHeadingId(
|
|
1109
|
+
options.mdHeadingId({
|
|
1110
|
+
text,
|
|
1111
|
+
level,
|
|
1112
|
+
index: options.headsRef.value.length,
|
|
1113
|
+
currentToken: token,
|
|
1114
|
+
nextToken: tokens[idx + 1]
|
|
1115
|
+
})
|
|
1100
1116
|
);
|
|
1101
1117
|
}
|
|
1102
1118
|
return md.renderer.renderToken(tokens, idx, options);
|
|
@@ -1985,7 +2001,7 @@ const ContentPreview = /* @__PURE__ */ vue.defineComponent({
|
|
|
1985
2001
|
};
|
|
1986
2002
|
}
|
|
1987
2003
|
});
|
|
1988
|
-
const mdHeadingId = (text) => text;
|
|
2004
|
+
const mdHeadingId = ({ text }) => text;
|
|
1989
2005
|
const mdPreviewProps = {
|
|
1990
2006
|
/**
|
|
1991
2007
|
* markdown content.
|
|
@@ -332,7 +332,13 @@ const CatalogLink = /* @__PURE__ */ vue.defineComponent({
|
|
|
332
332
|
if (e.defaultPrevented) {
|
|
333
333
|
return;
|
|
334
334
|
}
|
|
335
|
-
const id = mdHeadingId(
|
|
335
|
+
const id = mdHeadingId({
|
|
336
|
+
text: tocItem.text,
|
|
337
|
+
level: tocItem.level,
|
|
338
|
+
index: tocItem.index,
|
|
339
|
+
currentToken: tocItem.currentToken,
|
|
340
|
+
nextToken: tocItem.nextToken
|
|
341
|
+
});
|
|
336
342
|
const targetHeadEle = rootNodeRef.value.getElementById(id);
|
|
337
343
|
const scrollContainer = scrollElementRef.value;
|
|
338
344
|
if (targetHeadEle && scrollContainer) {
|
|
@@ -540,7 +546,13 @@ const MdCatalog = /* @__PURE__ */ vue.defineComponent({
|
|
|
540
546
|
var _a;
|
|
541
547
|
let relativeTop = 0;
|
|
542
548
|
if (props2.syncWith === "preview") {
|
|
543
|
-
const linkEle = (_a = rootNodeRef.value) == null ? void 0 : _a.getElementById(props2.mdHeadingId(
|
|
549
|
+
const linkEle = (_a = rootNodeRef.value) == null ? void 0 : _a.getElementById(props2.mdHeadingId({
|
|
550
|
+
text: link.text,
|
|
551
|
+
level: link.level,
|
|
552
|
+
index: index$1 + 1,
|
|
553
|
+
currentToken: link.currentToken,
|
|
554
|
+
nextToken: link.nextToken
|
|
555
|
+
}));
|
|
544
556
|
if (linkEle instanceof HTMLElement) {
|
|
545
557
|
relativeTop = index.getRelativeTop(linkEle, scrollElementRef.value);
|
|
546
558
|
}
|
package/lib/es/MdEditor.mjs
CHANGED
|
@@ -34,13 +34,13 @@ const useAutoScroll = (props2, html, codeMirrorUt) => {
|
|
|
34
34
|
var _a;
|
|
35
35
|
clearScrollAuto();
|
|
36
36
|
const rootNode = (_a = codeMirrorUt.value) == null ? void 0 : _a.view.contentDOM.getRootNode();
|
|
37
|
-
const cmScroller = rootNode.querySelector(
|
|
37
|
+
const cmScroller = rootNode == null ? void 0 : rootNode.querySelector(
|
|
38
38
|
`#${editorId} .cm-scroller`
|
|
39
39
|
);
|
|
40
|
-
const previewEle = rootNode.querySelector(
|
|
40
|
+
const previewEle = rootNode == null ? void 0 : rootNode.querySelector(
|
|
41
41
|
`[id="${editorId}-preview-wrapper"]`
|
|
42
42
|
);
|
|
43
|
-
const htmlEle = rootNode.querySelector(
|
|
43
|
+
const htmlEle = rootNode == null ? void 0 : rootNode.querySelector(
|
|
44
44
|
`[id="${editorId}-html-wrapper"]`
|
|
45
45
|
);
|
|
46
46
|
if (previewEle || htmlEle) {
|
|
@@ -2825,10 +2825,11 @@ const useCodeMirror = (props2) => {
|
|
|
2825
2825
|
const catalogVisible = inject("catalogVisible");
|
|
2826
2826
|
const defToolbars = inject("defToolbars");
|
|
2827
2827
|
const floatingToolbars = inject("floatingToolbars");
|
|
2828
|
+
const rootRef = inject("rootRef");
|
|
2828
2829
|
const inputWrapperRef = ref();
|
|
2829
2830
|
const codeMirrorUt = shallowRef();
|
|
2830
2831
|
const spelling = ref(false);
|
|
2831
|
-
const languageComp = new Compartment(), themeComp = new Compartment(), autocompletionComp = new Compartment(), historyComp = new Compartment(), eventComp = new Compartment();
|
|
2832
|
+
const languageComp = new Compartment(), themeComp = new Compartment(), autocompletionComp = new Compartment(), historyComp = new Compartment(), eventComp = new Compartment(), floatingToolbarComp = new Compartment();
|
|
2832
2833
|
const mdEditorCommands = createCommands(editorId, {
|
|
2833
2834
|
noPrettier
|
|
2834
2835
|
});
|
|
@@ -2865,6 +2866,29 @@ const useCodeMirror = (props2) => {
|
|
|
2865
2866
|
}
|
|
2866
2867
|
}
|
|
2867
2868
|
};
|
|
2869
|
+
const floatingToolbarPlugin = createFloatingToolbarPlugin({
|
|
2870
|
+
privide(app) {
|
|
2871
|
+
app.provide("editorId", editorId);
|
|
2872
|
+
app.provide("theme", theme);
|
|
2873
|
+
app.provide("previewTheme", previewTheme);
|
|
2874
|
+
app.provide("language", language);
|
|
2875
|
+
app.provide("disabled", disabled);
|
|
2876
|
+
app.provide("noUploadImg", noUploadImg);
|
|
2877
|
+
app.provide("tableShape", tableShape);
|
|
2878
|
+
app.provide("noPrettier", noPrettier);
|
|
2879
|
+
app.provide("codeTheme", codeTheme);
|
|
2880
|
+
app.provide("showToolbarName", showToolbarName);
|
|
2881
|
+
app.provide("setting", setting);
|
|
2882
|
+
app.provide("updateSetting", updateSetting);
|
|
2883
|
+
app.provide("usedLanguageText", usedLanguageText);
|
|
2884
|
+
app.provide("catalogVisible", catalogVisible);
|
|
2885
|
+
app.provide("defToolbars", defToolbars);
|
|
2886
|
+
app.provide("tabWidth", tabWidth);
|
|
2887
|
+
app.provide("customIcon", customIcon);
|
|
2888
|
+
app.provide("floatingToolbars", floatingToolbars);
|
|
2889
|
+
app.provide("rootRef", rootRef);
|
|
2890
|
+
}
|
|
2891
|
+
});
|
|
2868
2892
|
const defaultExtensions = [
|
|
2869
2893
|
{
|
|
2870
2894
|
type: "keymap",
|
|
@@ -2914,28 +2938,8 @@ const useCodeMirror = (props2) => {
|
|
|
2914
2938
|
},
|
|
2915
2939
|
{
|
|
2916
2940
|
type: "floatingToolbar",
|
|
2917
|
-
extension:
|
|
2918
|
-
|
|
2919
|
-
app.provide("editorId", editorId);
|
|
2920
|
-
app.provide("theme", theme);
|
|
2921
|
-
app.provide("previewTheme", previewTheme);
|
|
2922
|
-
app.provide("language", language);
|
|
2923
|
-
app.provide("disabled", disabled);
|
|
2924
|
-
app.provide("noUploadImg", noUploadImg);
|
|
2925
|
-
app.provide("tableShape", tableShape);
|
|
2926
|
-
app.provide("noPrettier", noPrettier);
|
|
2927
|
-
app.provide("codeTheme", codeTheme);
|
|
2928
|
-
app.provide("showToolbarName", showToolbarName);
|
|
2929
|
-
app.provide("setting", setting);
|
|
2930
|
-
app.provide("updateSetting", updateSetting);
|
|
2931
|
-
app.provide("usedLanguageText", usedLanguageText);
|
|
2932
|
-
app.provide("catalogVisible", catalogVisible);
|
|
2933
|
-
app.provide("defToolbars", defToolbars);
|
|
2934
|
-
app.provide("tabWidth", tabWidth);
|
|
2935
|
-
app.provide("customIcon", customIcon);
|
|
2936
|
-
app.provide("floatingToolbars", floatingToolbars);
|
|
2937
|
-
}
|
|
2938
|
-
})
|
|
2941
|
+
extension: floatingToolbars.value.length > 0 ? floatingToolbarPlugin : [],
|
|
2942
|
+
compartment: floatingToolbarComp
|
|
2939
2943
|
}
|
|
2940
2944
|
];
|
|
2941
2945
|
const getExtensions = () => {
|
|
@@ -3122,6 +3126,15 @@ const useCodeMirror = (props2) => {
|
|
|
3122
3126
|
}
|
|
3123
3127
|
}
|
|
3124
3128
|
);
|
|
3129
|
+
watch([floatingToolbars], () => {
|
|
3130
|
+
var _a, _b;
|
|
3131
|
+
if (floatingToolbars.value.length > 0) {
|
|
3132
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.view.dispatch({
|
|
3133
|
+
effects: floatingToolbarComp.reconfigure(floatingToolbarPlugin)
|
|
3134
|
+
});
|
|
3135
|
+
} else
|
|
3136
|
+
(_b = codeMirrorUt.value) == null ? void 0 : _b.view.dispatch({ effects: floatingToolbarComp.reconfigure([]) });
|
|
3137
|
+
});
|
|
3125
3138
|
return {
|
|
3126
3139
|
inputWrapperRef,
|
|
3127
3140
|
codeMirrorUt,
|
package/lib/es/chunks/index3.mjs
CHANGED
|
@@ -552,7 +552,7 @@ const useEcharts = (props) => {
|
|
|
552
552
|
configEcharts();
|
|
553
553
|
}
|
|
554
554
|
},
|
|
555
|
-
"
|
|
555
|
+
"echarts"
|
|
556
556
|
);
|
|
557
557
|
});
|
|
558
558
|
let mermaidSourceEles;
|
|
@@ -581,16 +581,24 @@ const useEcharts = (props) => {
|
|
|
581
581
|
if (item.dataset.closed === "false") {
|
|
582
582
|
return false;
|
|
583
583
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
584
|
+
try {
|
|
585
|
+
const options = new Function(`return ${item.innerText}`)();
|
|
586
|
+
const ins = echarts.init(item, theme.value);
|
|
587
|
+
ins.setOption(options);
|
|
588
|
+
item.setAttribute("data-processed", "");
|
|
589
|
+
echartsInstances.push(ins);
|
|
590
|
+
const observer = new ResizeObserver(() => {
|
|
591
|
+
ins.resize();
|
|
592
|
+
});
|
|
593
|
+
observer.observe(item);
|
|
594
|
+
observers.push(observer);
|
|
595
|
+
} catch (error) {
|
|
596
|
+
bus.emit(editorId, ERROR_CATCHER, {
|
|
597
|
+
name: "echarts",
|
|
598
|
+
message: error == null ? void 0 : error.message,
|
|
599
|
+
error
|
|
600
|
+
});
|
|
601
|
+
}
|
|
594
602
|
});
|
|
595
603
|
}
|
|
596
604
|
};
|
|
@@ -1090,12 +1098,20 @@ const HeadingPlugin = (md, options) => {
|
|
|
1090
1098
|
options.headsRef.value.push({
|
|
1091
1099
|
text,
|
|
1092
1100
|
level,
|
|
1093
|
-
line: token.map[0]
|
|
1101
|
+
line: token.map[0],
|
|
1102
|
+
currentToken: token,
|
|
1103
|
+
nextToken: tokens[idx + 1]
|
|
1094
1104
|
});
|
|
1095
1105
|
if (token.map && token.level === 0) {
|
|
1096
1106
|
token.attrSet(
|
|
1097
1107
|
"id",
|
|
1098
|
-
options.mdHeadingId(
|
|
1108
|
+
options.mdHeadingId({
|
|
1109
|
+
text,
|
|
1110
|
+
level,
|
|
1111
|
+
index: options.headsRef.value.length,
|
|
1112
|
+
currentToken: token,
|
|
1113
|
+
nextToken: tokens[idx + 1]
|
|
1114
|
+
})
|
|
1099
1115
|
);
|
|
1100
1116
|
}
|
|
1101
1117
|
return md.renderer.renderToken(tokens, idx, options);
|
|
@@ -1984,7 +2000,7 @@ const ContentPreview = /* @__PURE__ */ defineComponent({
|
|
|
1984
2000
|
};
|
|
1985
2001
|
}
|
|
1986
2002
|
});
|
|
1987
|
-
const mdHeadingId = (text) => text;
|
|
2003
|
+
const mdHeadingId = ({ text }) => text;
|
|
1988
2004
|
const mdPreviewProps = {
|
|
1989
2005
|
/**
|
|
1990
2006
|
* markdown content.
|
package/lib/es/chunks/index4.mjs
CHANGED
|
@@ -331,7 +331,13 @@ const CatalogLink = /* @__PURE__ */ defineComponent({
|
|
|
331
331
|
if (e.defaultPrevented) {
|
|
332
332
|
return;
|
|
333
333
|
}
|
|
334
|
-
const id = mdHeadingId(
|
|
334
|
+
const id = mdHeadingId({
|
|
335
|
+
text: tocItem.text,
|
|
336
|
+
level: tocItem.level,
|
|
337
|
+
index: tocItem.index,
|
|
338
|
+
currentToken: tocItem.currentToken,
|
|
339
|
+
nextToken: tocItem.nextToken
|
|
340
|
+
});
|
|
335
341
|
const targetHeadEle = rootNodeRef.value.getElementById(id);
|
|
336
342
|
const scrollContainer = scrollElementRef.value;
|
|
337
343
|
if (targetHeadEle && scrollContainer) {
|
|
@@ -539,7 +545,13 @@ const MdCatalog = /* @__PURE__ */ defineComponent({
|
|
|
539
545
|
var _a;
|
|
540
546
|
let relativeTop = 0;
|
|
541
547
|
if (props2.syncWith === "preview") {
|
|
542
|
-
const linkEle = (_a = rootNodeRef.value) == null ? void 0 : _a.getElementById(props2.mdHeadingId(
|
|
548
|
+
const linkEle = (_a = rootNodeRef.value) == null ? void 0 : _a.getElementById(props2.mdHeadingId({
|
|
549
|
+
text: link.text,
|
|
550
|
+
level: link.level,
|
|
551
|
+
index: index + 1,
|
|
552
|
+
currentToken: link.currentToken,
|
|
553
|
+
nextToken: link.nextToken
|
|
554
|
+
}));
|
|
543
555
|
if (linkEle instanceof HTMLElement) {
|
|
544
556
|
relativeTop = getRelativeTop(linkEle, scrollElementRef.value);
|
|
545
557
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Compartment, Extension } from '@codemirror/state';
|
|
2
2
|
import { KeyBinding, EditorView } from '@codemirror/view';
|
|
3
3
|
import { LooseRequired } from '@vue/shared';
|
|
4
|
-
import markdownit from 'markdown-it';
|
|
4
|
+
import markdownit, { Token } from 'markdown-it';
|
|
5
5
|
import { Component, SetupContext, ExtractPropTypes, VNode } from 'vue';
|
|
6
6
|
import { IconName } from './components/Icon/Icon';
|
|
7
7
|
import { editorProps, mdPreviewProps } from './props';
|
|
@@ -129,8 +129,16 @@ export interface HeadList {
|
|
|
129
129
|
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
130
130
|
active?: boolean;
|
|
131
131
|
line: number;
|
|
132
|
+
currentToken?: Token;
|
|
133
|
+
nextToken?: Token;
|
|
132
134
|
}
|
|
133
|
-
export type MdHeadingId = (
|
|
135
|
+
export type MdHeadingId = (options: {
|
|
136
|
+
text: string;
|
|
137
|
+
level: number;
|
|
138
|
+
index: number;
|
|
139
|
+
currentToken?: Token;
|
|
140
|
+
nextToken?: Token;
|
|
141
|
+
}) => string;
|
|
134
142
|
export interface MermaidTemplate {
|
|
135
143
|
/**
|
|
136
144
|
* 流程图
|