Explorar el Código

#4276 - Editor: incorrect detection of active editor when pasting image from buffer

roman.lesnikov@gmail.com hace 3 años
padre
commit
9e2d722609

+ 13 - 4
inc/js/editor.quill.js

@@ -324,16 +324,23 @@ function bx_editor_init(oEditor, oParams){
     oConfig.modules.imageUploader = {
     oConfig.modules.imageUploader = {
         upload: file => {
         upload: file => {
             return new Promise((resolve, reject) => {
             return new Promise((resolve, reject) => {
+                var bProcessed = false;
+                
                 if (typeof glOnInsertImageInEditor !== 'undefined' && glOnInsertImageInEditor instanceof Array && glOnInsertImageInEditor.length > 0) {
                 if (typeof glOnInsertImageInEditor !== 'undefined' && glOnInsertImageInEditor instanceof Array && glOnInsertImageInEditor.length > 0) {
                     for (var i = 0; i < glOnInsertImageInEditor.length; i++) {
                     for (var i = 0; i < glOnInsertImageInEditor.length; i++) {
                         if (typeof glOnInsertImageInEditor[i] === "function") {
                         if (typeof glOnInsertImageInEditor[i] === "function") {
-                            glOnInsertImageInEditor[i](file);
+                            var bTmp = glOnInsertImageInEditor[i](file,oParams.selector);
+                            if (bTmp)
+                                bProcessed = true;
                         }
                         }
                     }
                     }
-                    reject("External uploader");
+                    if(bProcessed)
+                        reject("External uploader");
                 }
                 }
-                else{
+                
+                if(!bProcessed){
                     const formData = new FormData();
                     const formData = new FormData();
+                   
                     formData.append("file", file);
                     formData.append("file", file);
                     fetch(oParams.root_url + "storage.php?o=sys_images_editor&t=sys_images_editor&a=upload", {
                     fetch(oParams.root_url + "storage.php?o=sys_images_editor&t=sys_images_editor&a=upload", {
                             method: "POST",
                             method: "POST",
@@ -444,7 +451,9 @@ function bx_editor_insert_html (sEditorId, sImgId, sHtml)
     }
     }
 }
 }
 
 
-function bx_editor_insert_img (sEditorId, sImgId, sImgUrl, sClasses) {
+function bx_editor_insert_img (sEditorId, sImgId, sImgUrl, sClasses) 
+{
+    console.log(888);
 
 
     if ('undefined' == typeof(sClasses))
     if ('undefined' == typeof(sClasses))
         sClasses = '';
         sClasses = '';

+ 6 - 1
modules/base/text/js/links.js

@@ -57,7 +57,11 @@ BxBaseModTextLinks.prototype.initFormPost = function(sFormId)
         if (typeof window.glOnInsertImageInEditor === 'undefined')
         if (typeof window.glOnInsertImageInEditor === 'undefined')
             window.glOnInsertImageInEditor = [];
             window.glOnInsertImageInEditor = [];
 
 
-        window.glOnInsertImageInEditor.push(function (oFile) {
+        window.glOnInsertImageInEditor.push(function (oFile, sSelector) {
+            
+            if(!oTextarea.is(sSelector))
+                return false;
+            
             const oFormData = new FormData();
             const oFormData = new FormData();
             oFormData.append('file', oFile);
             oFormData.append('file', oFile);
             oFormData.append('u', $this._sAutoUploader);
             oFormData.append('u', $this._sAutoUploader);
@@ -68,6 +72,7 @@ BxBaseModTextLinks.prototype.initFormPost = function(sFormId)
             .then(result => {
             .then(result => {
                 processJsonData(result)
                 processJsonData(result)
             });
             });
+            return true;
         });
         });
    }
    }
 };
 };

+ 9 - 2
modules/boonex/timeline/js/main.js

@@ -292,14 +292,20 @@ BxTimelineMain.prototype.initTrackerInsertSpace = function(sFormId, iEventId)
     });
     });
 };
 };
 
 
-BxTimelineMain.prototype.initTrackerInsertImage = function()
+BxTimelineMain.prototype.initTrackerInsertImage = function(sFormId)
 {
 {
     var $this = this;
     var $this = this;
 
 
+    var oForm = $('#' + sFormId);
+    var oTextarea = oForm.find('textarea');
+    
     if (typeof window.glOnInsertImageInEditor === 'undefined')
     if (typeof window.glOnInsertImageInEditor === 'undefined')
         window.glOnInsertImageInEditor = [];
         window.glOnInsertImageInEditor = [];
 
 
-    window.glOnInsertImageInEditor.push(function (oFile) {
+    window.glOnInsertImageInEditor.push(function (oFile, sSelector) {
+        if(!oTextarea.is(sSelector))
+            return false;
+        
         const oFormData = new FormData();
         const oFormData = new FormData();
         oFormData.append('file', oFile);
         oFormData.append('file', oFile);
         oFormData.append('u', $this._sAutoUploader);
         oFormData.append('u', $this._sAutoUploader);
@@ -310,6 +316,7 @@ BxTimelineMain.prototype.initTrackerInsertImage = function()
         .then(result => {
         .then(result => {
             processJsonData(result)
             processJsonData(result)
         });
         });
+        return true;
     });
     });
 };
 };
 
 

+ 1 - 2
modules/boonex/timeline/js/post.js

@@ -57,9 +57,8 @@ function BxTimelinePost(oOptions) {
             $this.initFormPost(sId);
             $this.initFormPost(sId);
 
 
             $this.initTrackerInsertSpace(sId);
             $this.initTrackerInsertSpace(sId);
-
             if($this._bAutoAttach) 
             if($this._bAutoAttach) 
-                $this.initTrackerInsertImage();
+                $this.initTrackerInsertImage(sId);
     	});
     	});
     });
     });
 }
 }

+ 0 - 1
template/calendar.html

@@ -15,7 +15,6 @@
             return oParams.event.extendedProps.class;
             return oParams.event.extendedProps.class;
         },
         },
         eventContent: function(oParams) {
         eventContent: function(oParams) {
-            console.log(oParams.view.type);
             if(oParams.view.type != 'dayGridDay' || !oParams.event.extendedProps.card)
             if(oParams.view.type != 'dayGridDay' || !oParams.event.extendedProps.card)
                 return oParams.event._def.title;
                 return oParams.event._def.title;