md-editor-v3 4.18.0 → 4.18.1
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 -1
- package/lib/cjs/chunks/index.cjs +9 -5
- package/lib/es/MdEditor.mjs +4 -2
- package/lib/es/chunks/index.mjs +9 -5
- package/lib/types/MdEditor/layouts/Content/markdownIt/mermaid/index.d.ts +1 -1
- package/lib/types/MdEditor/utils/cache.d.ts +2 -0
- package/lib/umd/index.js +52 -52
- package/package.json +1 -1
package/lib/cjs/MdEditor.cjs
CHANGED
|
@@ -2678,7 +2678,9 @@ const useCodeMirror = (props2) => {
|
|
|
2678
2678
|
}
|
|
2679
2679
|
}
|
|
2680
2680
|
}),
|
|
2681
|
-
eventComp.of(codemirror.EditorView.domEventHandlers(domEventHandlers))
|
|
2681
|
+
eventComp.of(codemirror.EditorView.domEventHandlers(domEventHandlers)),
|
|
2682
|
+
// 解决多行placeholder时,光标异常的情况
|
|
2683
|
+
view.drawSelection()
|
|
2682
2684
|
];
|
|
2683
2685
|
const getExtensions = () => {
|
|
2684
2686
|
const extensions = [
|
package/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -140,16 +140,16 @@ const useHighlight = (props) => {
|
|
|
140
140
|
);
|
|
141
141
|
return hljsRef;
|
|
142
142
|
};
|
|
143
|
+
const mermaidCache = new lruCache.LRUCache({
|
|
144
|
+
max: 1e3,
|
|
145
|
+
// 缓存10分钟
|
|
146
|
+
ttl: 6e5
|
|
147
|
+
});
|
|
143
148
|
const useMermaid = (props) => {
|
|
144
149
|
const theme = vue.inject("theme");
|
|
145
150
|
const { editorExtensions, editorExtensionsAttrs, mermaidConfig } = config.configOption;
|
|
146
151
|
const mermaidRef = vue.shallowRef(editorExtensions.mermaid.instance);
|
|
147
152
|
const reRenderRef = vue.shallowRef(-1);
|
|
148
|
-
const mermaidCache = new lruCache.LRUCache({
|
|
149
|
-
max: 1e3,
|
|
150
|
-
// 缓存10分钟
|
|
151
|
-
ttl: 6e5
|
|
152
|
-
});
|
|
153
153
|
const configMermaid = () => {
|
|
154
154
|
const mermaid = mermaidRef.value;
|
|
155
155
|
if (!props.noMermaid && mermaid) {
|
|
@@ -291,6 +291,10 @@ const MermaidPlugin = (md, options) => {
|
|
|
291
291
|
line = tokens[idx].map[0];
|
|
292
292
|
tokens[idx].attrSet("data-line", String(line));
|
|
293
293
|
}
|
|
294
|
+
const mermaidHtml = mermaidCache.get(code);
|
|
295
|
+
if (mermaidHtml) {
|
|
296
|
+
return `<p class="${config.prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-processed>${mermaidHtml}</p>`;
|
|
297
|
+
}
|
|
294
298
|
return `<div class="${config.prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-mermaid-theme=${options.themeRef.value}>${code}</div>`;
|
|
295
299
|
}
|
|
296
300
|
return temp(tokens, idx, ops, env, slf);
|
package/lib/es/MdEditor.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { a as appendHandler } from "./chunks/dom.mjs";
|
|
|
13
13
|
import { M as MdModal, I as Icon } from "./chunks/index3.mjs";
|
|
14
14
|
import { b as base642File } from "./chunks/index4.mjs";
|
|
15
15
|
import { EditorView as EditorView$1 } from "codemirror";
|
|
16
|
-
import { EditorView, placeholder, keymap } from "@codemirror/view";
|
|
16
|
+
import { EditorView, placeholder, keymap, drawSelection } from "@codemirror/view";
|
|
17
17
|
import { languages } from "@codemirror/language-data";
|
|
18
18
|
import { markdown } from "@codemirror/lang-markdown";
|
|
19
19
|
import { EditorSelection, EditorState, Compartment, StateEffect } from "@codemirror/state";
|
|
@@ -2677,7 +2677,9 @@ const useCodeMirror = (props2) => {
|
|
|
2677
2677
|
}
|
|
2678
2678
|
}
|
|
2679
2679
|
}),
|
|
2680
|
-
eventComp.of(EditorView$1.domEventHandlers(domEventHandlers))
|
|
2680
|
+
eventComp.of(EditorView$1.domEventHandlers(domEventHandlers)),
|
|
2681
|
+
// 解决多行placeholder时,光标异常的情况
|
|
2682
|
+
drawSelection()
|
|
2681
2683
|
];
|
|
2682
2684
|
const getExtensions = () => {
|
|
2683
2685
|
const extensions = [
|
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -139,16 +139,16 @@ const useHighlight = (props) => {
|
|
|
139
139
|
);
|
|
140
140
|
return hljsRef;
|
|
141
141
|
};
|
|
142
|
+
const mermaidCache = new LRUCache({
|
|
143
|
+
max: 1e3,
|
|
144
|
+
// 缓存10分钟
|
|
145
|
+
ttl: 6e5
|
|
146
|
+
});
|
|
142
147
|
const useMermaid = (props) => {
|
|
143
148
|
const theme = inject("theme");
|
|
144
149
|
const { editorExtensions, editorExtensionsAttrs, mermaidConfig } = configOption;
|
|
145
150
|
const mermaidRef = shallowRef(editorExtensions.mermaid.instance);
|
|
146
151
|
const reRenderRef = shallowRef(-1);
|
|
147
|
-
const mermaidCache = new LRUCache({
|
|
148
|
-
max: 1e3,
|
|
149
|
-
// 缓存10分钟
|
|
150
|
-
ttl: 6e5
|
|
151
|
-
});
|
|
152
152
|
const configMermaid = () => {
|
|
153
153
|
const mermaid = mermaidRef.value;
|
|
154
154
|
if (!props.noMermaid && mermaid) {
|
|
@@ -290,6 +290,10 @@ const MermaidPlugin = (md, options) => {
|
|
|
290
290
|
line = tokens[idx].map[0];
|
|
291
291
|
tokens[idx].attrSet("data-line", String(line));
|
|
292
292
|
}
|
|
293
|
+
const mermaidHtml = mermaidCache.get(code);
|
|
294
|
+
if (mermaidHtml) {
|
|
295
|
+
return `<p class="${prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-processed>${mermaidHtml}</p>`;
|
|
296
|
+
}
|
|
293
297
|
return `<div class="${prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-mermaid-theme=${options.themeRef.value}>${code}</div>`;
|
|
294
298
|
}
|
|
295
299
|
return temp(tokens, idx, ops, env, slf);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComputedRef } from 'vue';
|
|
2
|
-
import { Themes } from '../../../../type';
|
|
3
2
|
import markdownit from 'markdown-it';
|
|
3
|
+
import { Themes } from '../../../../type';
|
|
4
4
|
declare const MermaidPlugin: (md: markdownit, options: {
|
|
5
5
|
themeRef: ComputedRef<Themes>;
|
|
6
6
|
}) => void;
|