md-editor-v3 6.0.0-1 → 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 +3 -3
- package/lib/cjs/chunks/index3.cjs +30 -14
- package/lib/cjs/chunks/index4.cjs +14 -2
- package/lib/es/MdEditor.mjs +3 -3
- 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 +25 -25
- 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) {
|
|
@@ -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) {
|
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
|
* 流程图
|