diff --git a/.prettierrc.js b/.prettierrc.js index 5e922325a..38e1f7cea 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -18,7 +18,7 @@ module.exports = { // 大括号内的首尾需要空格 bracketSpacing: true, // jsx 标签的反尖括号需要换行 - jsxBracketSameLine: false, + bracketSameLine: false, // 箭头函数,只有一个参数的时候,也需要括号 arrowParens: 'always', // 每个文件格式化的范围是文件的全部内容 diff --git a/package.json b/package.json index 951d26217..5d40444cb 100644 --- a/package.json +++ b/package.json @@ -102,9 +102,10 @@ "gulp-iconfont": "^11.0.0", "gulp-rename": "^2.0.0", "jest": "^27.5.1", - "node-sass": "^7.0.0", "jest-diff": "^27.5.1", + "node-sass": "^7.0.0", "npm-run-all": "^4.1.5", + "postcss": "^8.2.15", "prettier": "2.6.2", "rimraf": "^3.0.2", "rollup": "^1.27.5", diff --git a/src/Previewer.js b/src/Previewer.js index 5cf944db0..7e3a98357 100644 --- a/src/Previewer.js +++ b/src/Previewer.js @@ -113,9 +113,9 @@ export default class Previewer { } getDomContainer = () => - /** @type {HTMLDivElement} */ (this.isMobilePreview - ? document.querySelector('.cherry-mobile-previewer-content') - : this.options.previewerDom); + /** @type {HTMLDivElement} */ ( + this.isMobilePreview ? document.querySelector('.cherry-mobile-previewer-content') : this.options.previewerDom + ); getDom() { return this.options.previewerDom; diff --git a/src/core/hooks/Blockquote.js b/src/core/hooks/Blockquote.js index 385989b2f..3c35a4db4 100644 --- a/src/core/hooks/Blockquote.js +++ b/src/core/hooks/Blockquote.js @@ -40,7 +40,8 @@ export default class Blockquote extends ParagraphBase { const { sign: contentSign, html: parsedHtml } = sentenceMakeFunc(content); const sign = this.signWithCache(parsedHtml) || contentSign; const lineCount = this.getLineCount(match, lines); // 段落所占行数 - const listRegex = /^(([ \t]{0,3}([*+-]|\d+[.]|[a-z]\.|[I一二三四五六七八九十]+\.)[ \t]+)([^\r]+?)($|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.]|[a-z]\.|[I一二三四五六七八九十]+\.)[ \t]+)))/; + const listRegex = + /^(([ \t]{0,3}([*+-]|\d+[.]|[a-z]\.|[I一二三四五六七八九十]+\.)[ \t]+)([^\r]+?)($|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.]|[a-z]\.|[I一二三四五六七八九十]+\.)[ \t]+)))/; let lastIndent = computeLeadingSpaces(lines); // 逐行处理 const contentLines = parsedHtml.split('\n'); diff --git a/src/core/hooks/List.js b/src/core/hooks/List.js index e98b199bd..e7e994860 100644 --- a/src/core/hooks/List.js +++ b/src/core/hooks/List.js @@ -71,7 +71,8 @@ function getListStyle(m2) { // 标识符处理 function handleMark(str, node) { - const listRegex = /^((([*+-]|\d+[.]|[a-z]\.|[I一二三四五六七八九十]+\.)[ \t]+)([^\r]*?)($|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.]|[a-z]\.|[I一二三四五六七八九十]+\.)[ \t]+)))/; + const listRegex = + /^((([*+-]|\d+[.]|[a-z]\.|[I一二三四五六七八九十]+\.)[ \t]+)([^\r]*?)($|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.]|[a-z]\.|[I一二三四五六七八九十]+\.)[ \t]+)))/; if (!listRegex.test(str)) { node.type = 'blank'; return str; diff --git a/src/toolbars/MenuBase.js b/src/toolbars/MenuBase.js index 26a5d8c42..c6308577e 100644 --- a/src/toolbars/MenuBase.js +++ b/src/toolbars/MenuBase.js @@ -28,9 +28,11 @@ import { createElement } from '@/utils/dom'; * @returns {HTMLDivElement} */ function createDiv(name, className, position, type = 'bottom') { - const div = /** @type {HTMLDivElement} */ (createElement('div', className, { - name, - })); + const div = /** @type {HTMLDivElement} */ ( + createElement('div', className, { + name, + }) + ); setPosition(div, position); return div; } diff --git a/yarn.lock b/yarn.lock index 2293ccbff..c78c9bff6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8423,6 +8423,11 @@ nan@^2.12.1, nan@^2.13.2, nan@^2.14.2: resolved "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee" integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ== +nanoid@^3.3.4: + version "3.3.4" + resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab" + integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw== + nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" @@ -9476,6 +9481,15 @@ postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0: resolved "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== +postcss@^8.2.15: + version "8.4.14" + resolved "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz#ee9274d5622b4858c1007a74d76e42e56fd21caf" + integrity sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig== + dependencies: + nanoid "^3.3.4" + picocolors "^1.0.0" + source-map-js "^1.0.2" + prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" @@ -10425,6 +10439,11 @@ socks@^2.6.2: ip "^1.1.5" smart-buffer "^4.2.0" +source-map-js@^1.0.2: + version "1.0.2" + resolved "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" + integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw== + source-map-resolve@^0.5.0: version "0.5.3" resolved "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a"