From 0730e548cf0bca80cb5d2bdbb3b1e14d317d5e54 Mon Sep 17 00:00:00 2001 From: Libin YANG Date: Fri, 30 Aug 2024 15:17:45 +0800 Subject: [PATCH] chore: upgrade prettier to v3 (#371) --- package-lock.json | 247 +++++++++++---------------------- package.json | 3 +- src/config/theme.ts | 4 +- src/stores/index.js | 20 +-- src/utils/index.js | 85 ++++++------ src/utils/renderer.js | 2 +- src/views/CodemirrorEditor.vue | 5 +- 7 files changed, 136 insertions(+), 230 deletions(-) diff --git a/package-lock.json b/package-lock.json index d2ce071..857a438 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,7 +46,6 @@ "@types/codemirror": "^5.60.15", "@types/marked": "^4.0.0", "@types/node": "^22.4.1", - "@types/prettier": "^2.7.3", "@unocss/eslint-plugin": "^0.62.2", "@vitejs/plugin-vue": "^5.1.2", "autoprefixer": "^10.4.20", @@ -55,7 +54,7 @@ "eslint-plugin-format": "^0.1.2", "less": "^4.2.0", "npm-run-all": "^4.1.5", - "prettier": "^2.8.8", + "prettier": "^3.3.3", "shx": "^0.3.4", "simple-git-hooks": "^2.11.1", "tailwindcss": "^3.4.10", @@ -279,12 +278,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.25.5", - "resolved": "https://registry.npmmirror.com/@babel/generator/-/generator-7.25.5.tgz", - "integrity": "sha512-abd43wyLfbWoxC6ahM8xTkqLpGB2iWBVyuKC9/srhFunCd1SDNrV1s72bBpK4hLj8KLzHBBcOblvLQZBNw9r3w==", + "version": "7.25.6", + "resolved": "https://registry.npmmirror.com/@babel/generator/-/generator-7.25.6.tgz", + "integrity": "sha512-VPC82gr1seXOpkjAAKoLhP50vx4vGNlF4msF64dSFq1P8RfB+QAuJWGHPXXPc8QyfVWwwB/TNNU4+ayZmHNbZw==", "dev": true, "dependencies": { - "@babel/types": "^7.25.4", + "@babel/types": "^7.25.6", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^2.5.1" @@ -506,13 +505,13 @@ } }, "node_modules/@babel/helpers": { - "version": "7.25.0", - "resolved": "https://registry.npmmirror.com/@babel/helpers/-/helpers-7.25.0.tgz", - "integrity": "sha512-MjgLZ42aCm0oGjJj8CtSM3DB8NOOf8h2l7DCTePJs29u+v7yO/RBX9nShlKMgFnRks/Q4tBAe7Hxnov9VkGwLw==", + "version": "7.25.6", + "resolved": "https://registry.npmmirror.com/@babel/helpers/-/helpers-7.25.6.tgz", + "integrity": "sha512-Xg0tn4HcfTijTwfDwYlvVCl43V6h4KyVVX2aEm4qdO/PC6L2YvzLHFdmxhoeSA3eslcE6+ZVXHgWwopXYLNq4Q==", "dev": true, "dependencies": { "@babel/template": "^7.25.0", - "@babel/types": "^7.25.0" + "@babel/types": "^7.25.6" }, "engines": { "node": ">=6.9.0" @@ -605,11 +604,11 @@ } }, "node_modules/@babel/parser": { - "version": "7.25.4", - "resolved": "https://registry.npmmirror.com/@babel/parser/-/parser-7.25.4.tgz", - "integrity": "sha512-nq+eWrOgdtu3jG5Os4TQP3x3cLA8hR8TvJNjD8vnPa20WGycimcparWnLK4jJhElTK6SDyuJo1weMKO/5LpmLA==", + "version": "7.25.6", + "resolved": "https://registry.npmmirror.com/@babel/parser/-/parser-7.25.6.tgz", + "integrity": "sha512-trGdfBdbD0l1ZPmcJ83eNxB9rbEax4ALFTF7fN386TMYbeCQbyme5cOEXQhbGXKebwGaB/J52w1mrklMcbgy6Q==", "dependencies": { - "@babel/types": "^7.25.4" + "@babel/types": "^7.25.6" }, "bin": { "parser": "bin/babel-parser.js" @@ -704,9 +703,9 @@ } }, "node_modules/@babel/runtime-corejs2": { - "version": "7.25.4", - "resolved": "https://registry.npmmirror.com/@babel/runtime-corejs2/-/runtime-corejs2-7.25.4.tgz", - "integrity": "sha512-6IxkDkxN13FQAB8FGF+vrvZVA77EqG4UzCwVGc9x9Ylerj70W3nMUwoXDbj2LtJxXlFKM256APcDQIItT2OFYA==", + "version": "7.25.6", + "resolved": "https://registry.npmmirror.com/@babel/runtime-corejs2/-/runtime-corejs2-7.25.6.tgz", + "integrity": "sha512-24uCmOJPrsnS7HtRamCibYabHRV0bscPJNFFcyKgj7FqUA0V5XcbZUmz9PVNDW4L+euMsZtCIetU1LxTmUaIlA==", "dependencies": { "core-js": "^2.6.12", "regenerator-runtime": "^0.14.0" @@ -737,16 +736,16 @@ } }, "node_modules/@babel/traverse": { - "version": "7.25.4", - "resolved": "https://registry.npmmirror.com/@babel/traverse/-/traverse-7.25.4.tgz", - "integrity": "sha512-VJ4XsrD+nOvlXyLzmLzUs/0qjFS4sK30te5yEFlvbbUNEgKaVb2BHZUpAL+ttLPQAHNrsI3zZisbfha5Cvr8vg==", + "version": "7.25.6", + "resolved": "https://registry.npmmirror.com/@babel/traverse/-/traverse-7.25.6.tgz", + "integrity": "sha512-9Vrcx5ZW6UwK5tvqsj0nGpp/XzqthkT0dqIc9g1AdtygFToNtTF67XzYS//dm+SAK9cp3B9R4ZO/46p63SCjlQ==", "dev": true, "dependencies": { "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.25.4", - "@babel/parser": "^7.25.4", + "@babel/generator": "^7.25.6", + "@babel/parser": "^7.25.6", "@babel/template": "^7.25.0", - "@babel/types": "^7.25.4", + "@babel/types": "^7.25.6", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -764,9 +763,9 @@ } }, "node_modules/@babel/types": { - "version": "7.25.4", - "resolved": "https://registry.npmmirror.com/@babel/types/-/types-7.25.4.tgz", - "integrity": "sha512-zQ1ijeeCXVEh+aNL0RlmkPkG8HUiDcU2pzQQFjtbntgAczRASFzj4H+6+bV+dy1ntKR14I/DypeuRG1uma98iQ==", + "version": "7.25.6", + "resolved": "https://registry.npmmirror.com/@babel/types/-/types-7.25.6.tgz", + "integrity": "sha512-/l42B1qxpG6RdfYf343Uw1vmDjeNhneUXtzhojE7pDgfpEypmRhI6j1kr17XCVv4Cgl9HdAiQY2x0GwKm7rWCw==", "dependencies": { "@babel/helper-string-parser": "^7.24.8", "@babel/helper-validator-identifier": "^7.24.7", @@ -842,6 +841,7 @@ }, "node_modules/@clack/prompts/node_modules/is-unicode-supported": { "version": "1.3.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -2097,50 +2097,13 @@ ] }, "node_modules/@stylistic/eslint-plugin": { - "version": "2.6.4", - "resolved": "https://registry.npmmirror.com/@stylistic/eslint-plugin/-/eslint-plugin-2.6.4.tgz", - "integrity": "sha512-euUGnjzH8EOqEYTGk9dB2OBINp0FX1nuO7/k4fO82zNRBIKZgJoDwTLM4Ce+Om6W1Qmh1PrZjCr4jh4tMEXGPQ==", + "version": "2.7.1", + "resolved": "https://registry.npmmirror.com/@stylistic/eslint-plugin/-/eslint-plugin-2.7.1.tgz", + "integrity": "sha512-JqnHom8CP14oOgPhwTPbn0QgsBJwgNySQSe00V9GQQDlY1tEqZUlK4jM2DIOJ5nE+oXoy51vZWHnHkfZ6rEruw==", "dev": true, "dependencies": { - "@stylistic/eslint-plugin-js": "2.6.4", - "@stylistic/eslint-plugin-jsx": "2.6.4", - "@stylistic/eslint-plugin-plus": "2.6.4", - "@stylistic/eslint-plugin-ts": "2.6.4", - "@types/eslint": "^9.6.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "peerDependencies": { - "eslint": ">=8.40.0" - } - }, - "node_modules/@stylistic/eslint-plugin-js": { - "version": "2.6.4", - "resolved": "https://registry.npmmirror.com/@stylistic/eslint-plugin-js/-/eslint-plugin-js-2.6.4.tgz", - "integrity": "sha512-kx1hS3xTvzxZLdr/DCU/dLBE++vcP97sHeEFX2QXhk1Ipa4K1rzPOLw1HCbf4mU3s+7kHP5eYpDe+QteEOFLug==", - "dev": true, - "dependencies": { - "@types/eslint": "^9.6.0", - "acorn": "^8.12.1", - "eslint-visitor-keys": "^4.0.0", - "espree": "^10.1.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "peerDependencies": { - "eslint": ">=8.40.0" - } - }, - "node_modules/@stylistic/eslint-plugin-jsx": { - "version": "2.6.4", - "resolved": "https://registry.npmmirror.com/@stylistic/eslint-plugin-jsx/-/eslint-plugin-jsx-2.6.4.tgz", - "integrity": "sha512-bIvVhdtjmyu3S10V7QRIuawtCZSq9gRmzAX23ucjCOdSFzEwlq+di0IM0riBAvvQerrJL4SM6G3xgyPs8BSXIA==", - "dev": true, - "dependencies": { - "@stylistic/eslint-plugin-js": "^2.6.4", - "@types/eslint": "^9.6.0", + "@types/eslint": "^9.6.1", + "@typescript-eslint/utils": "^8.3.0", "eslint-visitor-keys": "^4.0.0", "espree": "^10.1.0", "estraverse": "^5.3.0", @@ -2153,35 +2116,6 @@ "eslint": ">=8.40.0" } }, - "node_modules/@stylistic/eslint-plugin-plus": { - "version": "2.6.4", - "resolved": "https://registry.npmmirror.com/@stylistic/eslint-plugin-plus/-/eslint-plugin-plus-2.6.4.tgz", - "integrity": "sha512-EuRvtxhf7Hv8OoMIePulP/6rBJIgPTu1l5GAm1780WcF1Cl8bOZXIn84Pdac5pNv6lVlzCOFm8MD3VE+2YROuA==", - "dev": true, - "dependencies": { - "@types/eslint": "^9.6.0" - }, - "peerDependencies": { - "eslint": "*" - } - }, - "node_modules/@stylistic/eslint-plugin-ts": { - "version": "2.6.4", - "resolved": "https://registry.npmmirror.com/@stylistic/eslint-plugin-ts/-/eslint-plugin-ts-2.6.4.tgz", - "integrity": "sha512-yxL8Hj6WkObw1jfiLpBzKy5yfxY6vwlwO4miq34ySErUjUecPV5jxfVbOe4q1QDPKemQGPq93v7sAQS5PzM8lA==", - "dev": true, - "dependencies": { - "@stylistic/eslint-plugin-js": "2.6.4", - "@types/eslint": "^9.6.0", - "@typescript-eslint/utils": "^8.1.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "peerDependencies": { - "eslint": ">=8.40.0" - } - }, "node_modules/@swc/helpers": { "version": "0.5.12", "resolved": "https://registry.npmmirror.com/@swc/helpers/-/helpers-0.5.12.tgz", @@ -2191,20 +2125,20 @@ } }, "node_modules/@tanstack/virtual-core": { - "version": "3.10.5", - "resolved": "https://registry.npmmirror.com/@tanstack/virtual-core/-/virtual-core-3.10.5.tgz", - "integrity": "sha512-WlJp8CipNzBz8Q4g159uMfswYHZ8p1+xJwLBdnbBTcSSu0zVoY6i27Suw5J0Y88YBnJ9jHR8jJMH/qSuZWWfNw==", + "version": "3.10.6", + "resolved": "https://registry.npmmirror.com/@tanstack/virtual-core/-/virtual-core-3.10.6.tgz", + "integrity": "sha512-1giLc4dzgEKLMx5pgKjL6HlG5fjZMgCjzlKAlpr7yoUtetVPELgER1NtephAI910nMwfPTHNyWKSFmJdHkz2Cw==", "funding": { "type": "github", "url": "https://github.com/sponsors/tannerlinsley" } }, "node_modules/@tanstack/vue-virtual": { - "version": "3.10.5", - "resolved": "https://registry.npmmirror.com/@tanstack/vue-virtual/-/vue-virtual-3.10.5.tgz", - "integrity": "sha512-mgVcU53RD0qcJR8fVz8yVQ8QWvDW65IxYkwzV8JXauVll0a7LfP5sQF/CjqU42qwWbuDUcPZ3n98Ecno2JsCNw==", + "version": "3.10.6", + "resolved": "https://registry.npmmirror.com/@tanstack/vue-virtual/-/vue-virtual-3.10.6.tgz", + "integrity": "sha512-uVyUAV7rugRxgrw/f3J6FX6TGhxWAjXdT0PAbVNcIFNrj1Ftu/NT9bFLxKVQTkd8hnM6y8ijAlJ1xtBDGmo4gQ==", "dependencies": { - "@tanstack/virtual-core": "3.10.5" + "@tanstack/virtual-core": "3.10.6" }, "funding": { "type": "github", @@ -2293,12 +2227,6 @@ "integrity": "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==", "dev": true }, - "node_modules/@types/prettier": { - "version": "2.7.3", - "resolved": "https://registry.npmmirror.com/@types/prettier/-/prettier-2.7.3.tgz", - "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==", - "dev": true - }, "node_modules/@types/tern": { "version": "0.23.9", "resolved": "https://registry.npmmirror.com/@types/tern/-/tern-0.23.9.tgz", @@ -2882,9 +2810,9 @@ } }, "node_modules/@vitejs/plugin-vue": { - "version": "5.1.2", - "resolved": "https://registry.npmmirror.com/@vitejs/plugin-vue/-/plugin-vue-5.1.2.tgz", - "integrity": "sha512-nY9IwH12qeiJqumTCLJLE7IiNx7HZ39cbHaysEUd+Myvbz9KAqd2yq+U01Kab1R/H1BmiyM2ShTYlNH32Fzo3A==", + "version": "5.1.3", + "resolved": "https://registry.npmmirror.com/@vitejs/plugin-vue/-/plugin-vue-5.1.3.tgz", + "integrity": "sha512-3xbWsKEKXYlmX82aOHufFQVnkbMC/v8fLpWwh6hWOUrK5fbbtBh9Q/WWse27BFgSy2/e2c0fz5Scgya9h2GLhw==", "dev": true, "engines": { "node": "^18.0.0 || >=20.0.0" @@ -2895,9 +2823,9 @@ } }, "node_modules/@vitest/eslint-plugin": { - "version": "1.0.5", - "resolved": "https://registry.npmmirror.com/@vitest/eslint-plugin/-/eslint-plugin-1.0.5.tgz", - "integrity": "sha512-F4zlKv5S/aG3kiFyJHbkbInKfGuIs3muDnpNfr62g8tV0ALbP/MYjLKWN92olLCtWUb2cKl0pew0gKkkoHEUqw==", + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/@vitest/eslint-plugin/-/eslint-plugin-1.1.0.tgz", + "integrity": "sha512-Ur80Y27Wbw8gFHJ3cv6vypcjXmrx6QHfw+q435h6Q2L+tf+h4Xf5pJTCL4YU/Jps9EVeggQxS85OcUZU7sdXRw==", "dev": true, "peerDependencies": { "@typescript-eslint/utils": ">= 8.0", @@ -2918,27 +2846,27 @@ } }, "node_modules/@volar/language-core": { - "version": "2.4.0", - "resolved": "https://registry.npmmirror.com/@volar/language-core/-/language-core-2.4.0.tgz", - "integrity": "sha512-FTla+khE+sYK0qJP+6hwPAAUwiNHVMph4RUXpxf/FIPKUP61NFrVZorml4mjFShnueR2y9/j8/vnh09YwVdH7A==", + "version": "2.4.1", + "resolved": "https://registry.npmmirror.com/@volar/language-core/-/language-core-2.4.1.tgz", + "integrity": "sha512-9AKhC7Qn2mQYxj7Dz3bVxeOk7gGJladhWixUYKef/o0o7Bm4an+A3XvmcTHVqZ8stE6lBVH++g050tBtJ4TZPQ==", "dev": true, "dependencies": { - "@volar/source-map": "2.4.0" + "@volar/source-map": "2.4.1" } }, "node_modules/@volar/source-map": { - "version": "2.4.0", - "resolved": "https://registry.npmmirror.com/@volar/source-map/-/source-map-2.4.0.tgz", - "integrity": "sha512-2ceY8/NEZvN6F44TXw2qRP6AQsvCYhV2bxaBPWxV9HqIfkbRydSksTFObCF1DBDNBfKiZTS8G/4vqV6cvjdOIQ==", + "version": "2.4.1", + "resolved": "https://registry.npmmirror.com/@volar/source-map/-/source-map-2.4.1.tgz", + "integrity": "sha512-Xq6ep3OZg9xUqN90jEgB9ztX5SsTz1yiV8wiQbcYNjWkek+Ie3dc8l7AVt3EhDm9mSIR58oWczHkzM2H6HIsmQ==", "dev": true }, "node_modules/@volar/typescript": { - "version": "2.4.0", - "resolved": "https://registry.npmmirror.com/@volar/typescript/-/typescript-2.4.0.tgz", - "integrity": "sha512-9zx3lQWgHmVd+JRRAHUSRiEhe4TlzL7U7e6ulWXOxHH/WNYxzKwCvZD7WYWEZFdw4dHfTD9vUR0yPQO6GilCaQ==", + "version": "2.4.1", + "resolved": "https://registry.npmmirror.com/@volar/typescript/-/typescript-2.4.1.tgz", + "integrity": "sha512-UoRzC0PXcwajFQTu8XxKSYNsWNBtVja6Y9gC8eLv7kYm+UEKJCcZ8g7dialsOYA0HKs3Vpg57MeCsawFLC6m9Q==", "dev": true, "dependencies": { - "@volar/language-core": "2.4.0", + "@volar/language-core": "2.4.1", "path-browserify": "^1.0.1", "vscode-uri": "^3.0.8" } @@ -3005,12 +2933,12 @@ "integrity": "sha512-0MiMsFma/HqA6g3KLKn+AGpL1kgKhFWszC9U29NfpWK5LE7bjeXxySWJrOJ77hBz+TBrBQ7o4QJqbPbqbs8rJw==" }, "node_modules/@vue/language-core": { - "version": "2.0.29", - "resolved": "https://registry.npmmirror.com/@vue/language-core/-/language-core-2.0.29.tgz", - "integrity": "sha512-o2qz9JPjhdoVj8D2+9bDXbaI4q2uZTHQA/dbyZT4Bj1FR9viZxDJnLcKVHfxdn6wsOzRgpqIzJEEmSSvgMvDTQ==", + "version": "2.1.2", + "resolved": "https://registry.npmmirror.com/@vue/language-core/-/language-core-2.1.2.tgz", + "integrity": "sha512-tt2J7C+l0J/T5PaLhJ0jvCCi0JNwu3e8azWTYxW3jmAW5B/dac0g5UxmI7l59CQgCGFotqUqI3tXjfZgoWNtog==", "dev": true, "dependencies": { - "@volar/language-core": "~2.4.0-alpha.18", + "@volar/language-core": "~2.4.1", "@vue/compiler-dom": "^3.4.0", "@vue/compiler-vue2": "^2.7.16", "@vue/shared": "^3.4.0", @@ -5630,9 +5558,9 @@ } }, "node_modules/escalade": { - "version": "3.1.2", - "resolved": "https://registry.npmmirror.com/escalade/-/escalade-3.1.2.tgz", - "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", + "version": "3.2.0", + "resolved": "https://registry.npmmirror.com/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", "dev": true, "engines": { "node": ">=6" @@ -5891,21 +5819,6 @@ "eslint": "^8.40.0 || ^9.0.0" } }, - "node_modules/eslint-plugin-format/node_modules/prettier": { - "version": "3.3.3", - "resolved": "https://registry.npmmirror.com/prettier/-/prettier-3.3.3.tgz", - "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", - "dev": true, - "bin": { - "prettier": "bin/prettier.cjs" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, "node_modules/eslint-plugin-import-x": { "version": "3.1.0", "resolved": "https://registry.npmmirror.com/eslint-plugin-import-x/-/eslint-plugin-import-x-3.1.0.tgz", @@ -6202,13 +6115,13 @@ } }, "node_modules/eslint-plugin-perfectionist": { - "version": "3.2.0", - "resolved": "https://registry.npmmirror.com/eslint-plugin-perfectionist/-/eslint-plugin-perfectionist-3.2.0.tgz", - "integrity": "sha512-cX1aztMbSfRWPKJH8CD+gadrbkS+RNH1OGWuNGws8J6rHzYYhawxWTU/yzMYjq2IRJCpBCfhgfa7BHRXQYxLHA==", + "version": "3.3.0", + "resolved": "https://registry.npmmirror.com/eslint-plugin-perfectionist/-/eslint-plugin-perfectionist-3.3.0.tgz", + "integrity": "sha512-sGgShkEqDBqIZ3WlenGHwLe1cl3vHKTfeh9b1XXAamaxSC7AY4Os0jdNCXnGJW4l0TlpismT5t2r7CXY7sfKlw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "^8.1.0", - "@typescript-eslint/utils": "^8.1.0", + "@typescript-eslint/types": "^8.3.0", + "@typescript-eslint/utils": "^8.3.0", "minimatch": "^10.0.1", "natural-compare-lite": "^1.4.0" }, @@ -6965,9 +6878,9 @@ } }, "node_modules/get-tsconfig": { - "version": "4.7.6", - "resolved": "https://registry.npmmirror.com/get-tsconfig/-/get-tsconfig-4.7.6.tgz", - "integrity": "sha512-ZAqrLlu18NbDdRaHq+AKXzAmqIUPswPWKUchfytdAjiRFnCe5ojG2bstg6mRiZabkKfCoL/e98pbBELIV/YCeA==", + "version": "4.8.0", + "resolved": "https://registry.npmmirror.com/get-tsconfig/-/get-tsconfig-4.8.0.tgz", + "integrity": "sha512-Pgba6TExTZ0FJAn1qkJAjIeKoDJ3CsI2ChuLohJnZl/tTU8MVrq3b+2t5UOPfRa4RMsorClBjJALkJUMjG1PAw==", "dev": true, "dependencies": { "resolve-pkg-maps": "^1.0.0" @@ -9872,15 +9785,15 @@ } }, "node_modules/prettier": { - "version": "2.8.8", - "resolved": "https://registry.npmmirror.com/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "version": "3.3.3", + "resolved": "https://registry.npmmirror.com/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", "dev": true, "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=10.13.0" + "node": ">=14" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" @@ -12555,13 +12468,13 @@ } }, "node_modules/vue-tsc": { - "version": "2.0.29", - "resolved": "https://registry.npmmirror.com/vue-tsc/-/vue-tsc-2.0.29.tgz", - "integrity": "sha512-MHhsfyxO3mYShZCGYNziSbc63x7cQ5g9kvijV7dRe1TTXBRLxXyL0FnXWpUF1xII2mJ86mwYpYsUmMwkmerq7Q==", + "version": "2.1.2", + "resolved": "https://registry.npmmirror.com/vue-tsc/-/vue-tsc-2.1.2.tgz", + "integrity": "sha512-PH1BDxWT3eaPhl73elyZj6DV0nR3K4IFoUM1sGzMXXQneovVUwHQytdSyAHiED5MtEINGSHpL/Hs9ch+c/tDTw==", "dev": true, "dependencies": { - "@volar/typescript": "~2.4.0-alpha.18", - "@vue/language-core": "2.0.29", + "@volar/typescript": "~2.4.1", + "@vue/language-core": "2.1.2", "semver": "^7.5.4" }, "bin": { diff --git a/package.json b/package.json index 29687e2..b9e5ac0 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,6 @@ "@types/codemirror": "^5.60.15", "@types/marked": "^4.0.0", "@types/node": "^22.4.1", - "@types/prettier": "^2.7.3", "@unocss/eslint-plugin": "^0.62.2", "@vitejs/plugin-vue": "^5.1.2", "autoprefixer": "^10.4.20", @@ -63,7 +62,7 @@ "eslint-plugin-format": "^0.1.2", "less": "^4.2.0", "npm-run-all": "^4.1.5", - "prettier": "^2.8.8", + "prettier": "^3.3.3", "shx": "^0.3.4", "simple-git-hooks": "^2.11.1", "tailwindcss": "^3.4.10", diff --git a/src/config/theme.ts b/src/config/theme.ts index c7c5cd9..6d1c521 100644 --- a/src/config/theme.ts +++ b/src/config/theme.ts @@ -2,8 +2,6 @@ import { toMerged } from 'es-toolkit' import type { Theme } from '@/types' -const baseColor = `#3f3f3f` - const defaultTheme: Theme = { base: { '--md-primary-color': `#000000`, @@ -190,7 +188,7 @@ const defaultTheme: Theme = { td: { border: `1px solid #dfdfdf`, padding: `0.25em 0.5em`, - color: baseColor, + color: `#3f3f3f`, }, footnote: { diff --git a/src/stores/index.js b/src/stores/index.js index a24bff8..6dace7b 100644 --- a/src/stores/index.js +++ b/src/stores/index.js @@ -9,7 +9,7 @@ import { altKey, codeBlockThemeOptions, colorOptions, fontFamilyOptions, fontSiz import WxRenderer from '@/utils/renderer' import DEFAULT_CONTENT from '@/assets/example/markdown.md?raw' import DEFAULT_CSS_CONTENT from '@/assets/example/theme-css.txt?raw' -import { addPrefix, css2json, customCssWithTemplate, customizeTheme, downloadMD, exportHTML, formatCss, formatDoc } from '@/utils' +import { addPrefix, css2json, customCssWithTemplate, customizeTheme, downloadMD, exportHTML, formatDoc } from '@/utils' export const useStore = defineStore(`store`, () => { // 是否开启深色模式 @@ -54,13 +54,14 @@ export const useStore = defineStore(`store`, () => { // 内容编辑器编辑器 const editor = ref(null) // 编辑区域内容 - const editorContent = useStorage(`__editor_content`, formatDoc(DEFAULT_CONTENT)) + const editorContent = useStorage(`__editor_content`, DEFAULT_CONTENT) // 格式化文档 const formatContent = () => { - const doc = formatDoc(editor.value.getValue()) - editorContent.value = doc - editor.value.setValue(doc) + formatDoc(editor.value.getValue()).then((doc) => { + editorContent.value = doc + editor.value.setValue(doc) + }) } // 切换 highlight.js 代码主题 @@ -208,9 +209,10 @@ export const useStore = defineStore(`store`, () => { autofocus: true, extraKeys: { [`${shiftKey}-${altKey}-F`]: function autoFormat(editor) { - const doc = formatCss(editor.getValue()) - getCurrentTab().content = doc - editor.setValue(doc) + formatDoc(editor.getValue(), `css`).then((doc) => { + getCurrentTab().content = doc + editor.setValue(doc) + }) }, }, }), @@ -350,7 +352,7 @@ export const useStore = defineStore(`store`, () => { const reader = new FileReader() reader.readAsText(file) reader.onload = (event) => { - editor.value.setValue(formatDoc(event.target.result)) + editor.value.setValue(event.target.result) ElMessage.success(`文档导入成功`) } } diff --git a/src/utils/index.js b/src/utils/index.js index 2165d79..09bcaca 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,8 +1,10 @@ import juice from 'juice' -import prettier from 'prettier/standalone' -import prettierCss from 'prettier/parser-postcss' -import prettierMarkdown from 'prettier/parser-markdown' +import { format } from 'prettier/standalone' +import * as prettierPluginMarkdown from 'prettier/plugins/markdown' +import * as prettierPluginBabel from 'prettier/plugins/babel'; +import * as prettierPluginEstree from 'prettier/plugins/estree'; +import * as prettierPluginCss from 'prettier/plugins/postcss' import { prefix } from '@/config' export function addPrefix(str) { @@ -25,28 +27,37 @@ export function customizeTheme(theme, options) { } export function customCssWithTemplate(jsonString, color, theme) { - const newTheme = customizeTheme(theme, { color }); + const newTheme = customizeTheme(theme, { color }) const mergeProperties = (target, source, keys) => { - keys.forEach(key => { + keys.forEach((key) => { if (source[key]) { - target[key] = Object.assign(target[key] || {}, source[key]); + target[key] = Object.assign(target[key] || {}, source[key]) } - }); - }; + }) + } const blockKeys = [ - 'h1', 'h2', 'h3', 'h4', 'code', 'p', 'hr', 'blockquote', - 'blockquote_p', 'image', 'ul', 'ol' - ]; - const inlineKeys = ['strong', 'codespan', 'link', 'wx_link', 'listitem']; + `h1`, + `h2`, + `h3`, + `h4`, + `code`, + `p`, + `hr`, + `blockquote`, + `blockquote_p`, + `image`, + `ul`, + `ol`, + ] + const inlineKeys = [`strong`, `codespan`, `link`, `wx_link`, `listitem`] - mergeProperties(newTheme.block, jsonString, blockKeys); - mergeProperties(newTheme.inline, jsonString, inlineKeys); - return newTheme; + mergeProperties(newTheme.block, jsonString, blockKeys) + mergeProperties(newTheme.inline, jsonString, inlineKeys) + return newTheme } - /** * 将 CSS 字符串转换为 JSON 对象 * @@ -98,39 +109,21 @@ export function css2json(css) { } /** - * 将编辑器内容保存到 LocalStorage - * @param {*} editor - * @param {*} name + * 格式化内容 + * @param {string} content - 要格式化的内容 + * @param {'markdown' | 'css'} [type] - 内容类型,决定使用的解析器,默认为'markdown' + * @returns {Promise} - 格式化后的内容 */ -export function saveEditorContent(editor, name) { - const content = editor.getValue(0) - if (content) { - localStorage.setItem(name, content) +export async function formatDoc(content, type = `markdown`) { + const plugins = { + markdown: [prettierPluginMarkdown, prettierPluginBabel, prettierPluginEstree], + css: [prettierPluginCss], } - else { - localStorage.removeItem(name) - } -} -/** - * 格式化文档 - * @param {string} content - 文档内容 - */ -export function formatDoc(content) { - return prettier.format(content, { - parser: `markdown`, - plugins: [prettierMarkdown], - }) -} - -/** - * 格式化css - * @param {string} content - css内容 - */ -export function formatCss(content) { - return prettier.format(content, { - parser: `css`, - plugins: [prettierCss], + const parser = type in plugins ? type : `markdown` + return await format(content, { + parser, + plugins: plugins[parser], }) } diff --git a/src/utils/renderer.js b/src/utils/renderer.js index 1a03260..6147169 100644 --- a/src/utils/renderer.js +++ b/src/utils/renderer.js @@ -132,7 +132,7 @@ class WxRenderer extends Renderer { } codeIndex = 0 - code({ text, lang }) { + code({ text, lang = `` }) { if (lang.startsWith(`mermaid`)) { clearTimeout(this.codeIndex) this.codeIndex = setTimeout(() => { diff --git a/src/views/CodemirrorEditor.vue b/src/views/CodemirrorEditor.vue index 151b98a..d0d05d4 100644 --- a/src/views/CodemirrorEditor.vue +++ b/src/views/CodemirrorEditor.vue @@ -197,8 +197,9 @@ function initEditor() { autoCloseBrackets: true, extraKeys: { [`${shiftKey}-${altKey}-F`]: function autoFormat(editor) { - const doc = formatDoc(editor.getValue(0)) - editor.setValue(doc) + formatDoc(editor.getValue(0)).then((doc) => { + editor.setValue(doc) + }) }, [`${ctrlKey}-B`]: function bold(editor) { const selected = editor.getSelection()