Skip to content

Commit

Permalink
Merge branch 'develop' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
imzbf committed Aug 14, 2024
2 parents e4373fb + fc679e9 commit 6018e79
Show file tree
Hide file tree
Showing 18 changed files with 241 additions and 202 deletions.
19 changes: 18 additions & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,23 @@ config({
});
```
### 🔧 katexConfig
katex 配置项,[配置详情](https://katex.org/docs/options)
```js
import { config } from 'md-editor-v3';

config({
katexConfig(base: any) {
return {
...base,
strict: false
};
}
});
```
## 🪡 快捷键
主要以`CTRL`搭配对应功能英文单词首字母,冲突项添加`SHIFT`,再冲突替换为`ALT`
Expand Down Expand Up @@ -1030,7 +1047,7 @@ const onUploadImg = async (files, callback) => {
--md-color: if(@isDark, #999, #222);
--md-hover-color: if(@isDark, #bbb, #000);
--md-bk-color: if(@isDark, #000, #fff);
--md-bk-color-outstand: if(@isDark, #111, #f6f6f6);
--md-bk-color-outstand: if(@isDark, #333, #f2f2f2);
--md-bk-hover-color: if(@isDark, #1b1a1a, #f5f7fa);
--md-border-color: if(@isDark, #2d2d2d, #e6e6e6);
--md-border-hover-color: if(@isDark, #636262, #b9b9b9);
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,23 @@ config({
});
```
### 🔧 katexConfig
Configure `katex`, [Details](https://katex.org/docs/options)
```js
import { config } from 'md-editor-v3';

config({
katexConfig(base: any) {
return {
...base,
strict: false
};
}
});
```
## 🪡 Shortcut Key
_Pay attention: shortcut keys are only available when the textarea has received focus!_
Expand Down Expand Up @@ -1008,7 +1025,7 @@ const onUploadImg = async (files, callback) => {
--md-color: if(@isDark, #999, #222);
--md-hover-color: if(@isDark, #bbb, #000);
--md-bk-color: if(@isDark, #000, #fff);
--md-bk-color-outstand: if(@isDark, #111, #f6f6f6);
--md-bk-color-outstand: if(@isDark, #333, #f2f2f2);
--md-bk-hover-color: if(@isDark, #1b1a1a, #f5f7fa);
--md-border-color: if(@isDark, #2d2d2d, #e6e6e6);
--md-border-hover-color: if(@isDark, #636262, #b9b9b9);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "md-editor-v3",
"version": "4.18.0-4",
"version": "4.18.1",
"license": "MIT",
"keywords": [
"vue",
Expand Down Expand Up @@ -61,7 +61,7 @@
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"@vavt/markdown-theme": "^4.1.1",
"@vavt/markdown-theme": "^4.1.2",
"@vavt/vite-plugin-import-markdown": "^1.0.0",
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
Expand Down
1 change: 1 addition & 0 deletions packages/MdEditor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const Editor = defineComponent({
defToolbars={defToolbars}
noUploadImg={noUploadImg}
showToolbarName={props.showToolbarName}
catalogVisible={catalogVisible.value}
/>
)}
<Content
Expand Down
3 changes: 2 additions & 1 deletion packages/MdEditor/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ export const configOption: ConfigOption = {
markdownItConfig: () => {},
markdownItPlugins: (s) => s,
iconfontType: 'svg',
mermaidConfig: (c) => c
mermaidConfig: (c) => c,
katexConfig: (c) => c
};

export const config: Config = (option) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const createAutocompletion = (completions: Array<CompletionSource> | undefined)
from: word.from,
options: [
// 标题
...['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].map((key, index) => {
...['h2', 'h3', 'h4', 'h5', 'h6'].map((key, index) => {
const label = new Array(index + 1).fill('#').join('');
return {
label,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ref, onMounted, inject, ComputedRef, watch, shallowRef } from 'vue';
import { EditorView } from 'codemirror';
import { keymap } from '@codemirror/view';
import { keymap, drawSelection } from '@codemirror/view';
import { languages } from '@codemirror/language-data';
import { markdown } from '@codemirror/lang-markdown';
import { Compartment } from '@codemirror/state';
Expand Down Expand Up @@ -115,7 +115,9 @@ const useCodeMirror = (props: ContentProps) => {
}
}
}),
eventComp.of(EditorView.domEventHandlers(domEventHandlers))
eventComp.of(EditorView.domEventHandlers(domEventHandlers)),
// 解决多行placeholder时,光标异常的情况
drawSelection()
];

const getExtensions = () => {
Expand Down
8 changes: 1 addition & 7 deletions packages/MdEditor/layouts/Content/composition/useMermaid.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { watch, inject, ComputedRef, onMounted, shallowRef, nextTick } from 'vue';
import { LRUCache } from 'lru-cache';
import { prefix, configOption } from '~/config';
import { appendHandler } from '~/utils/dom';
import { uuid } from '@vavt/util';
import { mermaidCache } from '~/utils/cache';

import { ContentPreviewProps } from '../ContentPreview';

Expand All @@ -17,12 +17,6 @@ const useMermaid = (props: ContentPreviewProps) => {
const mermaidRef = shallowRef(editorExtensions!.mermaid!.instance);
const reRenderRef = shallowRef(-1);

const mermaidCache = new LRUCache({
max: 1000,
// 缓存10分钟
ttl: 600000
});

const configMermaid = () => {
const mermaid = mermaidRef.value;

Expand Down
Loading

0 comments on commit 6018e79

Please sign in to comment.