diff --git a/package.json b/package.json index 0e32d14..e33166a 100644 --- a/package.json +++ b/package.json @@ -11,53 +11,46 @@ "mm": "npx mockm --cwd=mm" }, "dependencies": { - "@vue/shared": "^3.0.11", + "@vue/shared": "^3.2.23", "ali-oss": "^6.16.0", - "axios": "^0.21.2", - "buffer-from": "^1.1.1", - "codemirror": "^5.61.0", - "core-js": "^3.11.0", + "axios": "^0.24.0", + "buffer-from": "^1.1.2", + "codemirror": "^5.64.0", + "core-js": "^3.19.2", "cos-js-sdk-v5": "^1.3.1", - "crypto-js": "^4.0.0", - "element-ui": "^2.15.1", - "form-data": "2.3.3", + "crypto-js": "^4.1.1", + "element-ui": "^2.15.6", + "form-data": "4.0.0", "jquery": "^3.6.0", - "juice": "^7.0.0", - "marked": "^2.0.3", - "node-fetch": "2.6.2", - "prettier": "^2.2.1", + "juice": "^8.0.0", + "marked": "^4.0.5", + "node-fetch": "3.1.0", + "prettier": "^2.5.0", "prettify": "^0.1.7", "qiniu-js": "^3.4.0", - "regenerator-runtime": "^0.13.7", + "regenerator-runtime": "^0.13.9", "uuid": "^8.3.2", - "vue": "^2.6.12", - "vue-router": "^3.4.9", - "vuex": "^3.5.1" + "vue": "^2.6.14", + "vue-router": "^3.5.3", + "vuex": "^3.6.2" }, "devDependencies": { - "@vue/cli-plugin-babel": "~4.5.12", - "@vue/cli-service": "~4.5.12", - "async-validator": "^3.5.1", + "@vue/cli-plugin-babel": "~4.5.15", + "@vue/cli-service": "~4.5.15", + "async-validator": "^4.0.7", "babel-plugin-import": "^1.13.3", "cross-env": "^7.0.3", - "jest": "^25.4.0", - "less": "^3.12.2", - "less-loader": "^5.0.0", + "jest": "^27.4.0", + "less": "^4.1.2", + "less-loader": "^7.3.0", "mini-types": "*", "miniprogram-api-typings": "*", "mockm": "^1.1.25", "npm-run-all": "^4.1.5", "postcss-comment": "^2.0.0", "raw-loader": "^4.0.2", - "sass-loader": "^11.0.1", + "sass-loader": "^12.3.0", "shx": "^0.3.3", - "vue-template-compiler": "^2.6.12" - }, - "browserslist": [ - "Android >= 4", - "ios >= 8" - ], - "uni-app": { - "scripts": {} + "vue-template-compiler": "^2.6.14" } } diff --git a/src/assets/scripts/renderers/wx-renderer.js b/src/assets/scripts/renderers/wx-renderer.js index c53b72c..4ce10d5 100644 --- a/src/assets/scripts/renderers/wx-renderer.js +++ b/src/assets/scripts/renderers/wx-renderer.js @@ -1,4 +1,5 @@ -import marked from "marked"; +import { Renderer } from "marked"; + class WxRenderer { constructor(opts) { this.opts = opts; @@ -96,7 +97,7 @@ class WxRenderer { footnoteIndex = 0; styleMapping = this.buildTheme(this.opts.theme); - let renderer = new marked.Renderer(); + let renderer = new Renderer(); renderer.heading = (text, level) => { switch (level) { diff --git a/src/store/index.js b/src/store/index.js index cdd1a62..4c49db8 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2,7 +2,7 @@ import Vue from "vue"; import Vuex from "vuex"; import config from "../assets/scripts/config"; import WxRenderer from "../assets/scripts/renderers/wx-renderer"; -import marked from "marked"; +import { marked } from "marked"; import CodeMirror from "codemirror/lib/codemirror"; import DEFAULT_CONTENT from "@/assets/example/markdown.md"; import DEFAULT_CSS_CONTENT from "@/assets/example/theme-css.txt"; @@ -111,7 +111,7 @@ const mutations = { "Ctrl-I": function italic(editor) { const selected = editor.getSelection(); editor.replaceSelection(`*${selected}*`); - } + }, }, }); }, @@ -140,9 +140,9 @@ const mutations = { }); }, editorRefresh(state) { - let output = marked(state.editor.getValue(0), { - renderer: state.wxRenderer.getRenderer(state.citeStatus), - }); + let renderer = state.wxRenderer.getRenderer(state.citeStatus); + marked.setOptions({ renderer }); + let output = marked.parse(state.editor.getValue(0)); // 去除第一行的 margin-top output = output.replace(/(style=".*?)"/, '$1;margin-top: 0"');