From df91db588293fe4074e189bd6f8c4e04a11903fa Mon Sep 17 00:00:00 2001 From: "xiaoqi.cxq" Date: Sat, 5 Nov 2022 12:37:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E5=89=8D=E6=96=87=E6=A1=A3=E7=A9=BA?= =?UTF-8?q?=E9=97=B4=E5=9B=BE=E7=89=87=E8=B7=AF=E5=BE=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 1 - package-lock.json | 101 +++++++++++++----- package.json | 2 +- .../modals/WorkspaceImgPathModal.vue | 5 +- .../modals/providers/GiteaImgStorageModal.vue | 7 +- .../providers/GithubImgStorageModal.vue | 7 +- src/services/editorSvc.js | 39 ++++--- src/services/imageSvc.js | 6 +- src/services/syncSvc.js | 4 +- src/services/utils.js | 9 +- 10 files changed, 121 insertions(+), 60 deletions(-) diff --git a/Dockerfile b/Dockerfile index c0aac4b7..80314ab9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ FROM mafgwo/wkhtmltopdf-nodejs:11.15.0 -RUN mkdir -p /opt/stackedit WORKDIR /opt/stackedit COPY package*json /opt/stackedit/ diff --git a/package-lock.json b/package-lock.json index 16eafb33..8e19bf84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -736,7 +736,8 @@ "abab": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.0.tgz", - "integrity": "sha512-sY5AXXVZv4Y1VACTtR11UJCPHHudgY5i26Qj5TypE6DKlIApbwb5uqhXcJ5UUGbvZNRh7EeIoW+LrJumBsKp7w==" + "integrity": "sha512-sY5AXXVZv4Y1VACTtR11UJCPHHudgY5i26Qj5TypE6DKlIApbwb5uqhXcJ5UUGbvZNRh7EeIoW+LrJumBsKp7w==", + "dev": true }, "abbrev": { "version": "1.1.1", @@ -763,7 +764,8 @@ "acorn": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz", - "integrity": "sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==" + "integrity": "sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==", + "dev": true }, "acorn-dynamic-import": { "version": "2.0.2", @@ -786,6 +788,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.1.0.tgz", "integrity": "sha512-KjZwU26uG3u6eZcfGbTULzFcsoz6pegNKtHPksZPOUsiKo5bUmiBPa38FuHZ/Eun+XYh/JCCkS9AS3Lu4McQOQ==", + "dev": true, "requires": { "acorn": "^5.0.0" } @@ -1021,7 +1024,8 @@ "array-equal": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz", - "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=" + "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=", + "dev": true }, "array-filter": { "version": "0.0.1", @@ -1237,7 +1241,8 @@ "async-limiter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", - "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", + "dev": true }, "async-settle": { "version": "1.0.0", @@ -2481,7 +2486,8 @@ "browser-process-hrtime": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz", - "integrity": "sha1-Ql1opY00R/AqBKqJQYf86K+Le44=" + "integrity": "sha1-Ql1opY00R/AqBKqJQYf86K+Le44=", + "dev": true }, "browser-resolve": { "version": "1.11.3", @@ -3904,12 +3910,14 @@ "cssom": { "version": "0.3.4", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.4.tgz", - "integrity": "sha512-+7prCSORpXNeR4/fUP3rL+TzqtiFfhMvTd7uEqMdgPvLPt4+uzFUeufx5RHjGTACCargg/DiEt/moMQmvnfkog==" + "integrity": "sha512-+7prCSORpXNeR4/fUP3rL+TzqtiFfhMvTd7uEqMdgPvLPt4+uzFUeufx5RHjGTACCargg/DiEt/moMQmvnfkog==", + "dev": true }, "cssstyle": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-1.1.1.tgz", "integrity": "sha512-364AI1l/M5TYcFH83JnOH/pSqgaNnKmYgKrm0didZMGKWjQB60dymwWy1rKUgL3J1ffdq9xVi2yGLHdSjjSNog==", + "dev": true, "requires": { "cssom": "0.3.x" } @@ -4249,6 +4257,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-1.0.1.tgz", "integrity": "sha512-0HdcMZzK6ubMUnsMmQmG0AcLQPvbvb47R0+7CCZQCYgcd8OUWG91CG7sM6GoXgjz+WLl4ArFzHtBMy/QqSF4eg==", + "dev": true, "requires": { "abab": "^2.0.0", "whatwg-mimetype": "^2.1.0", @@ -4259,6 +4268,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.0.0.tgz", "integrity": "sha512-37GeVSIJ3kn1JgKyjiYNmSLP1yzbpb29jdmwBSgkD9h40/hyrR/OifpVUndji3tmwGgD8qpw7iQu3RSbCrBpsQ==", + "dev": true, "requires": { "lodash.sortby": "^4.7.0", "tr46": "^1.0.1", @@ -4317,7 +4327,8 @@ "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true }, "default-compare": { "version": "1.0.0", @@ -4579,6 +4590,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/domexception/-/domexception-1.0.1.tgz", "integrity": "sha512-raigMkn7CJNNo6Ihro1fzG7wr3fHuYVytzquZKX5n0yizGsTcYgzdIUwj1X9pK0VvjeihV+XiclP+DjwbsSKug==", + "dev": true, "requires": { "webidl-conversions": "^4.0.2" } @@ -4592,6 +4604,11 @@ "domelementtype": "1" } }, + "domino": { + "version": "2.1.6", + "resolved": "https://registry.npmmirror.com/domino/-/domino-2.1.6.tgz", + "integrity": "sha512-3VdM/SXBZX2omc9JF9nOPCtDaYQ67BGp5CoLpIQlO2KCAPETs8TcDHacF26jXadGbvUteZzRTeos2fhID5+ucQ==" + }, "domutils": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.6.2.tgz", @@ -4881,6 +4898,7 @@ "version": "1.11.0", "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.11.0.tgz", "integrity": "sha512-IeMV45ReixHS53K/OmfKAIztN/igDHzTJUhZM3k1jMhIZWjk45SMwAtBsEXiJp3vSPmTcu6CXn7mDvFHRN66fw==", + "dev": true, "requires": { "esprima": "^3.1.3", "estraverse": "^4.2.0", @@ -4892,12 +4910,14 @@ "esprima": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", - "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=" + "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", + "dev": true }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, "optional": true } } @@ -5349,12 +5369,14 @@ "estraverse": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", - "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=" + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true }, "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true }, "etag": { "version": "1.8.1", @@ -6060,7 +6082,8 @@ "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true }, "fastparse": { "version": "1.1.1", @@ -9069,6 +9092,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz", "integrity": "sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw==", + "dev": true, "requires": { "whatwg-encoding": "^1.0.1" } @@ -11298,6 +11322,7 @@ "version": "11.12.0", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-11.12.0.tgz", "integrity": "sha512-y8Px43oyiBM13Zc1z780FrfNLJCXTL40EWlty/LXUtcjykRBNgLlCjWXpfSPBl2iv+N7koQN+dvqszHZgT/Fjw==", + "dev": true, "requires": { "abab": "^2.0.0", "acorn": "^5.5.3", @@ -11330,17 +11355,20 @@ "acorn": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", - "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==" + "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==", + "dev": true }, "sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "dev": true }, "whatwg-url": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-6.5.0.tgz", "integrity": "sha512-rhRZRqx/TLJQWUpQ6bmrt2UV4f0HCQ463yQuONJqC6fO2VoEb1pTYddbe59SkYq87aoM5A3bdhMZiUiVws+fzQ==", + "dev": true, "requires": { "lodash.sortby": "^4.7.0", "tr46": "^1.0.1", @@ -11351,6 +11379,7 @@ "version": "5.2.2", "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz", "integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==", + "dev": true, "requires": { "async-limiter": "~1.0.0" } @@ -11549,7 +11578,8 @@ "left-pad": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz", - "integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==" + "integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==", + "dev": true }, "leven": { "version": "2.1.0", @@ -11561,6 +11591,7 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, "requires": { "prelude-ls": "~1.1.2", "type-check": "~0.3.2" @@ -13342,7 +13373,8 @@ "nwsapi": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.8.tgz", - "integrity": "sha512-7RZ+qbFGiVc6v14Y8DSZjPN1wZPOaMbiiP4tzf5eNuyOITAeOIA3cMhjuKUypVIqBgCSg1KaSyAv8Ocq/0ZJ1A==" + "integrity": "sha512-7RZ+qbFGiVc6v14Y8DSZjPN1wZPOaMbiiP4tzf5eNuyOITAeOIA3cMhjuKUypVIqBgCSg1KaSyAv8Ocq/0ZJ1A==", + "dev": true }, "oauth-sign": { "version": "0.9.0", @@ -13677,6 +13709,7 @@ "version": "0.8.2", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, "requires": { "deep-is": "~0.1.3", "fast-levenshtein": "~2.0.4", @@ -13689,7 +13722,8 @@ "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true } } }, @@ -14007,7 +14041,8 @@ "parse5": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/parse5/-/parse5-4.0.0.tgz", - "integrity": "sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA==" + "integrity": "sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA==", + "dev": true }, "parseurl": { "version": "1.3.2", @@ -14208,7 +14243,8 @@ "pn": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pn/-/pn-1.1.0.tgz", - "integrity": "sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==" + "integrity": "sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==", + "dev": true }, "pngjs": { "version": "3.3.3", @@ -15111,7 +15147,8 @@ "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true }, "prepend-http": { "version": "1.0.4", @@ -16250,6 +16287,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz", "integrity": "sha1-Pu4AssWqgyOc+wTFcA2jb4HNCLY=", + "dev": true, "requires": { "lodash": "^4.13.1" } @@ -16258,6 +16296,7 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.5.tgz", "integrity": "sha1-UoF3D2jgyXGeUWP9P6tIIhX0/aU=", + "dev": true, "requires": { "request-promise-core": "1.1.1", "stealthy-require": "^1.1.0", @@ -18448,7 +18487,8 @@ "stealthy-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", - "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=" + "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=", + "dev": true }, "stream-browserify": { "version": "2.0.1", @@ -19607,7 +19647,8 @@ "symbol-tree": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz", - "integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=" + "integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=", + "dev": true }, "table": { "version": "4.0.2", @@ -20466,11 +20507,11 @@ } }, "turndown": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/turndown/-/turndown-4.0.2.tgz", - "integrity": "sha512-pqZ6WrHFGnxXC9q2xJ3Qa7EoLAwrojgFRajWZjxTKwbz9vnNnyi8lLjiD5h86UTPOcMlEyHjm6NMhjEDdlc25A==", + "version": "7.1.1", + "resolved": "https://registry.npmmirror.com/turndown/-/turndown-7.1.1.tgz", + "integrity": "sha512-BEkXaWH7Wh7e9bd2QumhfAXk5g34+6QUmmWx+0q6ThaVOLuLUqsnkq35HQ5SBHSaxjSfSM7US5o4lhJNH7B9MA==", "requires": { - "jsdom": "^11.9.0" + "domino": "^2.1.6" } }, "tweetnacl": { @@ -20489,6 +20530,7 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, "requires": { "prelude-ls": "~1.1.2" } @@ -21336,6 +21378,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz", "integrity": "sha1-gqwr/2PZUOqeMYmlimViX+3xkEU=", + "dev": true, "requires": { "browser-process-hrtime": "^0.1.2" } @@ -21757,6 +21800,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.4.tgz", "integrity": "sha512-vM9KWN6MP2mIHZ86ytcyIv7e8Cj3KTfO2nd2c8PFDqcI4bxFmQp83ibq4wadq7rL9l9sZV6o9B0LTt8ygGAAXg==", + "dev": true, "requires": { "iconv-lite": "0.4.23" }, @@ -21765,6 +21809,7 @@ "version": "0.4.23", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "dev": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" } @@ -21774,7 +21819,8 @@ "whatwg-mimetype": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.1.0.tgz", - "integrity": "sha512-FKxhYLytBQiUKjkYteN71fAUA3g6KpNXoho1isLiLSB3N1G4F35Q5vUxWfKFhBwi5IWF27VE6WxhrnnC+m0Mew==" + "integrity": "sha512-FKxhYLytBQiUKjkYteN71fAUA3g6KpNXoho1isLiLSB3N1G4F35Q5vUxWfKFhBwi5IWF27VE6WxhrnnC+m0Mew==", + "dev": true }, "whatwg-url": { "version": "6.4.0", @@ -21953,7 +21999,8 @@ "xml-name-validator": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", - "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==" + "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", + "dev": true }, "xml-parse-from-string": { "version": "1.0.1", diff --git a/package.json b/package.json index d95dd2bf..648e08d9 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "request": "^2.85.0", "serve-static": "^1.13.2", "tmp": "^0.0.33", - "turndown": "^4.0.2", + "turndown": "^7.1.1", "vue": "^2.5.16", "vuex": "^3.0.1" }, diff --git a/src/components/modals/WorkspaceImgPathModal.vue b/src/components/modals/WorkspaceImgPathModal.vue index d873d122..ca1c6191 100644 --- a/src/components/modals/WorkspaceImgPathModal.vue +++ b/src/components/modals/WorkspaceImgPathModal.vue @@ -8,8 +8,9 @@ diff --git a/src/components/modals/providers/GiteaImgStorageModal.vue b/src/components/modals/providers/GiteaImgStorageModal.vue index d05ddeab..f409fe35 100644 --- a/src/components/modals/providers/GiteaImgStorageModal.vue +++ b/src/components/modals/providers/GiteaImgStorageModal.vue @@ -12,9 +12,10 @@ - + @@ -62,7 +63,7 @@ export default modalTemplate({ const path = this.path && this.path.replace(/^\//, ''); this.config.resolve({ repoUri: projectPath, - path: path || '{YYYY}/{MM}/{DD}', + path: path || 'imgs/{YYYY}-{MM}-{DD}', branch: this.branch || 'master', }); } catch (err) { diff --git a/src/components/modals/providers/GithubImgStorageModal.vue b/src/components/modals/providers/GithubImgStorageModal.vue index 6ad57b06..58673cda 100644 --- a/src/components/modals/providers/GithubImgStorageModal.vue +++ b/src/components/modals/providers/GithubImgStorageModal.vue @@ -12,9 +12,10 @@ - + @@ -63,7 +64,7 @@ export default modalTemplate({ this.config.resolve({ owner, repo, - path: path || '{YYYY}/{MM}/{DD}', + path: path || 'imgs/{YYYY}-{MM}-{DD}', branch: this.branch || 'master', }); } catch (err) { diff --git a/src/services/editorSvc.js b/src/services/editorSvc.js index a6b49238..b5731987 100644 --- a/src/services/editorSvc.js +++ b/src/services/editorSvc.js @@ -209,9 +209,17 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils, this.previewElt.appendChild(sectionPreviewElt); } extensionSvc.sectionPreview(sectionPreviewElt, this.options, true); + const imgs = Array.prototype.slice.call(sectionPreviewElt.getElementsByTagName('img')).map((imgElt) => { + if (imgElt.src.indexOf(constants.origin) >= 0) { + const uri = decodeURIComponent(imgElt.attributes.src.nodeValue); + imgElt.removeAttribute('src'); + return { imgElt, uri }; + } + return { imgElt }; + }); loadingImages = [ ...loadingImages, - ...Array.prototype.slice.call(sectionPreviewElt.getElementsByTagName('img')), + ...imgs, ]; // Create TOC section element @@ -249,22 +257,22 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils, this.makeTextToPreviewDiffs(); // Wait for images to load - const loadedPromises = loadingImages.map(imgElt => new Promise((resolve, reject) => { - if (!imgElt.src) { - resolve(); + const loadedPromises = loadingImages.map(it => new Promise((resolve, reject) => { + if (!it.imgElt.src && it.uri) { + getImgUrl(it.uri).then((newUrl) => { + it.imgElt.src = newUrl; + resolve(); + }, () => reject(new Error('加载当前空间图片出错'))); return; } - if (imgElt.src.indexOf(constants.origin) >= 0) { - getImgUrl(imgElt.attributes.src.nodeValue).then((newUrl) => { - imgElt.src = newUrl; - resolve(); - }, () => reject(new Error('加载本地空间图片出错'))); + if (!it.imgElt.src) { + resolve(); return; } const img = new window.Image(); img.onload = resolve; img.onerror = resolve; - img.src = imgElt.src; + img.src = it.imgElt.src; })); await Promise.all(loadedPromises); @@ -542,7 +550,8 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils, } imgEltsToCache.push(imgElt); if (imgElt.src.indexOf(origin) >= 0) { - loadImgs.push(imgElt); + imgElt.removeAttribute('src'); + loadImgs.push({ imgElt, uri: decodeURIComponent(uri) }); } } const imgTokenWrapper = document.createElement('span'); @@ -554,11 +563,11 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils, }); if (loadImgs.length) { // Wait for images to load - const loadWorkspaceImg = loadImgs.map(imgElt => new Promise((resolve, reject) => { - getImgUrl(imgElt.attributes.src.nodeValue).then((newUrl) => { - imgElt.src = newUrl; + const loadWorkspaceImg = loadImgs.map(it => new Promise((resolve, reject) => { + getImgUrl(it.uri).then((newUrl) => { + it.imgElt.src = newUrl; resolve(); - }, () => reject(new Error(`加载本地空间图片出错,uri:${imgElt.attributes.src.nodeValue}`))); + }, () => reject(new Error(`加载当前空间图片出错,uri:${it.uri}`))); })); Promise.all(loadWorkspaceImg).then(); } diff --git a/src/services/imageSvc.js b/src/services/imageSvc.js index b811349f..757eceea 100644 --- a/src/services/imageSvc.js +++ b/src/services/imageSvc.js @@ -19,8 +19,8 @@ function getImagePath(confPath, imgType) { const date = time.getDate(); const month = time.getMonth() + 1; const year = time.getFullYear(); - const path = confPath.replace('{YYYY}', year) - .replace('{MM}', `0${month}`.slice(-2)).replace('{DD}', `0${date}`.slice(-2)); + const path = confPath.replace('{YYYY}', year).replace('{MM}', `0${month}`.slice(-2)) + .replace('{DD}', `0${date}`.slice(-2)).replace('{MDNAME}', store.getters['file/current'].name); return `${path}${path.endsWith('/') ? '' : '/'}${utils.uid()}.${imgType.split('/')[1]}`; } @@ -44,7 +44,7 @@ export default { path: absolutePath, content: base64, }); - return { url: path }; + return { url: path.replace(' ', '%20') }; } if (!currStorage.provider) { return { error: '暂无已选择的图床!' }; diff --git a/src/services/syncSvc.js b/src/services/syncSvc.js index 4f3f1ee7..decf4ce6 100644 --- a/src/services/syncSvc.js +++ b/src/services/syncSvc.js @@ -844,7 +844,7 @@ const syncWorkspace = async (skipContents = false) => { const syncImg = async (absolutePath) => { const token = workspaceProvider.getToken(); - const path = absolutePath.substring(1, absolutePath.length); + const path = absolutePath.substring(1, absolutePath.length).replace('%20', ' '); const { sha, content } = await workspaceProvider.downloadFile({ token, path, @@ -877,7 +877,7 @@ const uploadImg = async (imgIds, index = 0) => { file: { ...utils.deepCopy(item), type: 'img', - path: item.path.substring(1, item.path.length), + path: item.path.substring(1, item.path.length).replace('%20', ' '), }, isImg: true, }); diff --git a/src/services/utils.js b/src/services/utils.js index 60bfbf36..b8dc52e0 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -387,14 +387,17 @@ export default { getAbsoluteFilePath(currAbsolutePath, filePath) { // "/"开头说明已经是绝对路径 if (filePath.indexOf('/') === 0) { - return filePath; + return this.encodeUrlPath(filePath); } let path = filePath; - if (filePath.indexOf('./') === 0) { + // 相对上级路径 + if (path.indexOf('../') === 0) { + return this.getAbsoluteFilePath(currAbsolutePath.substring(0, currAbsolutePath.lastIndexOf('/')), path.replace('../', '')); + } else if (path.indexOf('./') === 0) { path = `${currAbsolutePath}/${path.replace('./', '')}`; } else { path = `${currAbsolutePath}/${path}`; } - return path.indexOf('/') === 0 ? path : `/${path}`; + return (path.indexOf('/') === 0 ? path : `/${path}`).replace(' ', '%20'); }, };