diff --git a/package.json b/package.json index 815b1814..2b036670 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "md-editor-v3", - "version": "4.17.4", + "version": "4.18.0", "keywords": [ "vue", "vue3", @@ -40,7 +40,7 @@ "markdown-it-anchor": "^9.0.1", "markdown-it-link-attributes": "^4.0.1", "markdown-it-mark": "^4.0.0", - "md-editor-v3": "^4.17.4", + "md-editor-v3": "^4.18.0", "nprogress": "^0.2.0", "vue": "3.2.47", "vue-router": "^4.3.0", diff --git a/public/demo-en-US.md b/public/demo-en-US.md index 797243cb..da62acc1 100644 --- a/public/demo-en-US.md +++ b/public/demo-en-US.md @@ -1008,6 +1008,34 @@ config({ }); ``` +### ☑️ Toggleable status task list + +```js +import { config } from 'md-editor-v3'; +config({ + markdownItPlugins(plugins, { editorId }) { + return plugins.map((item) => { + if (item.type === 'taskList') { + return { + ...item, + options: { + ...item.options, + enabled: true + // If you just want to enable this feature for a certain editor + // enabled: editorId === 'myId' + } + }; + } + return item; + }); + } +}); +``` + +```vue + +``` + ## 🧻 Edit This Page [demo-en-US](https://github.com/imzbf/md-editor-v3/blob/dev-docs/public/demo-en-US.md) diff --git a/public/demo-zh-CN.md b/public/demo-zh-CN.md index 7b1322dc..b13df2ff 100644 --- a/public/demo-zh-CN.md +++ b/public/demo-zh-CN.md @@ -1018,6 +1018,34 @@ config({ }); ``` +### ☑️ 可切换状态的任务列表 + +```js +import { config } from 'md-editor-v3'; +config({ + markdownItPlugins(plugins, { editorId }) { + return plugins.map((item) => { + if (item.type === 'taskList') { + return { + ...item, + options: { + ...item.options, + enabled: true + // 如果只是想对某个编辑器开启这个功能 + // enabled: editorId === 'myId' + } + }; + } + return item; + }); + } +}); +``` + +```vue + +``` + ## 🧻 编辑此页面 [demo-zh-CN](https://github.com/imzbf/md-editor-v3/blob/dev-docs/public/demo-zh-CN.md) diff --git a/public/grammar-en-US.md b/public/grammar-en-US.md index 31a4adda..88ada73e 100644 --- a/public/grammar-en-US.md +++ b/public/grammar-en-US.md @@ -215,6 +215,8 @@ According to the understanding of other editors, no other editors currently empl - [x] Sunday ``` +[Example](https://imzbf.github.io/md-editor-v3/en-US/demo#☑%EF%B8%8F%20Toggleable%20status%20task%20list) that supports toggling task status in the preview module. + --- ## 🐮 Table diff --git a/public/grammar-zh-CN.md b/public/grammar-zh-CN.md index 562fd067..4fe1a370 100644 --- a/public/grammar-zh-CN.md +++ b/public/grammar-zh-CN.md @@ -215,6 +215,8 @@ import 'md-editor-v3/lib/style.css'; - [x] 周天 ``` +支持在预览模块切换任务状态的[示例](https://imzbf.github.io/md-editor-v3/zh-CN/demo#☑%EF%B8%8F%20可切换状态的任务列表) + --- ## 🐮 表格 diff --git a/src/main.ts b/src/main.ts index dfedc16b..43746565 100644 --- a/src/main.ts +++ b/src/main.ts @@ -22,9 +22,21 @@ import ZH_TW from '@vavt/cm-extension/dist/locale/zh-TW'; import '@vavt/cm-extension/dist/previewTheme/arknights.css'; config({ - markdownItPlugins(plugins) { + markdownItPlugins(plugins, { editorId }) { return [ - ...plugins, + ...plugins.map((item) => { + if (item.type === 'taskList') { + return { + ...item, + options: { + ...item.options, + enabled: editorId === 'editor-preview' + } + }; + } + + return item; + }), { type: 'mark', plugin: MarkExtension, diff --git a/yarn.lock b/yarn.lock index 8165e93c..9ae364e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3192,11 +3192,6 @@ markdown-it-mark@^4.0.0: resolved "https://registry.npmjs.org/markdown-it-mark/-/markdown-it-mark-4.0.0.tgz#c19cbc87d9cb9fd1a495e8fe31b740b6d9ebf8c8" integrity sha512-YLhzaOsU9THO/cal0lUjfMjrqSMPjjyjChYM7oyj4DnyaXEzA8gnW6cVJeyCrCVeyesrY2PlEdUYJSPFYL4Nkg== -markdown-it-task-lists@^2.1.1: - version "2.1.1" - resolved "https://registry.npmjs.org/markdown-it-task-lists/-/markdown-it-task-lists-2.1.1.tgz#f68f4d2ac2bad5a2c373ba93081a1a6848417088" - integrity sha512-TxFAc76Jnhb2OUu+n3yz9RMu4CwGfaT788br6HhEDlvWfdeJcLUsxk1Hgw2yJio0OXsxv7pyIPmvECY7bMbluA== - markdown-it@^14.0.0: version "14.1.0" resolved "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz#3c3c5992883c633db4714ccb4d7b5935d98b7d45" @@ -3214,10 +3209,10 @@ marked@*: resolved "https://registry.npmjs.org/marked/-/marked-13.0.2.tgz#d5d05bd2683a85cb9cc6afbe5240e3a8bffcb92a" integrity sha512-J6CPjP8pS5sgrRqxVRvkCIkZ6MFdRIjDkwUwgJ9nL2fbmM6qGQeB2C16hi8Cc9BOzj6xXzy0jyi0iPIfnMHYzA== -md-editor-v3@^4.17.4: - version "4.17.4" - resolved "https://registry.npmjs.org/md-editor-v3/-/md-editor-v3-4.17.4.tgz#1abd3bab74202e28078b6761bbf456b788d7eddf" - integrity sha512-g7fDBFNfahS0bNHbweVLepd1e8BnZtHNSobduSIa3nTEiGHCD0VzQtf+JyHsDYdGhDwZrBGReGpHxK+/9AZb/w== +md-editor-v3@^4.18.0: + version "4.18.0" + resolved "https://registry.npmjs.org/md-editor-v3/-/md-editor-v3-4.18.0.tgz#adea0c2488cadc09dabb3ce025b9310f5b468dc9" + integrity sha512-lKGPTTqPM6BDuidcMXw9G/Lh9UXOAV7XRlUbOHnaiLVeJzwMhwXGqugtq3GgSJiNKvz9r1QpVgH6jYyT8zpPNQ== dependencies: "@codemirror/lang-markdown" "^6.2.5" "@codemirror/language-data" "^6.5.1" @@ -3228,7 +3223,6 @@ md-editor-v3@^4.17.4: lru-cache "^10.2.0" markdown-it "^14.0.0" markdown-it-image-figures "^2.1.1" - markdown-it-task-lists "^2.1.1" medium-zoom "^1.1.0" punycode "^2.3.1" xss "^1.0.15"