Browse Source

图片上传功能优化

dusenyao 1 year ago
parent
commit
e209cf36f6
2 changed files with 29 additions and 12 deletions
  1. 29 11
      patches/tinymce+5.10.8.patch
  2. 0 1
      src/components/common/RichText.vue

+ 29 - 11
patches/tinymce+5.10.8.patch

@@ -13,7 +13,7 @@ index 0000000..02edc4d
 +require('./plugin.js');
 diff --git a/node_modules/tinymce/plugins/ax_wordlimit/plugin.js b/node_modules/tinymce/plugins/ax_wordlimit/plugin.js
 new file mode 100644
-index 0000000..143777e
+index 0000000..bd4704d
 --- /dev/null
 +++ b/node_modules/tinymce/plugins/ax_wordlimit/plugin.js
 @@ -0,0 +1,55 @@
@@ -51,7 +51,7 @@ index 0000000..143777e
 +            }
 +            setTimeout(function(){onsign=1}, ax_wordlimit_delay);
 +        }
-+        
++
 +    }
 +    var setup = function(){
 +        if( ax_wordlimit_num>0 ){
@@ -134,14 +134,32 @@ index 0000000..143777e
 +    };
 +});
 diff --git a/node_modules/tinymce/plugins/image/plugin.js b/node_modules/tinymce/plugins/image/plugin.js
-index 63e741c..ce7fc90 100644
+index 63e741c..48382d5 100644
 --- a/node_modules/tinymce/plugins/image/plugin.js
 +++ b/node_modules/tinymce/plugins/image/plugin.js
-@@ -621,6 +621,7 @@
-     };
-     var create = function (normalizeCss, data) {
-       var image = document.createElement('img');
-+      console.log(1);
-       write(normalizeCss, __assign(__assign({}, data), { caption: false }), image);
-       setAlt(image, data.alt, data.isDecorative);
-       if (data.caption) {
+@@ -8,7 +8,6 @@
+  */
+ (function () {
+     'use strict';
+-
+     var global$6 = tinymce.util.Tools.resolve('tinymce.PluginManager');
+ 
+     var __assign = function () {
+@@ -1407,7 +1406,7 @@
+               meta: {}
+             }
+           });
+-          api.showTab('general');
++          // api.showTab('general'); 切换 tab 为普通
+           changeSrc(helpers, info, state, api);
+         };
+         blobToDataUri(file).then(function (dataUrl) {
+@@ -1416,6 +1415,8 @@
+             helpers.uploadImage(blobInfo).then(function (result) {
+               updateSrcAndSwitchTab(result.url);
+               finalize();
++              helpers.onSubmit(info)(api); // 上传成功后,触发保存事件
++              updateSrcAndSwitchTab(""); // 保存事件成功后,清空 src
+             }).catch(function (err) {
+               finalize();
+               helpers.alertErr(err);

+ 0 - 1
src/components/common/RichText.vue

@@ -100,7 +100,6 @@ export default {
          */
         images_upload_handler(blobInfo, success, fail) {
           let file = blobInfo.blob();
-          console.log(success);
           const formData = new FormData();
           formData.append(file.name, file, file.name);
           fileUpload('Mid', formData)