fix #7610 - 206_minor_fixes_to_portal
[roojs1] / Roo / bootstrap / form / HtmlEditorToolbar / Standard.js
index 108c250..1fb81fc 100644 (file)
@@ -221,19 +221,27 @@ Roo.extend(Roo.bootstrap.form.HtmlEditorToolbar.Standard, Roo.bootstrap.nav.Simp
         }
     
          
-        this.addFiles(Array.prototype.slice.call(this.input.dom.files));
+        this.addFiles(Array.prototype.slice.call(this.input.dom.files), false);
     },
     
-    addFiles : function(far) {
+    addFiles : function(far, fire_add) {
 
+         
+        var editor =  this.editorcore;
+  
         if (!far.length) {
+            if (fire_add) {
+                this.editor.syncValue();
+                editor.owner.fireEvent('editorevent', editor.owner, false);
+                editor.owner.fireEvent('imageadd', editor.owner, false);
+            }
             return;
         }
         
         var f = far.pop();
         
         if (!f.type.match(/^image/)) {
-            this.addFiles(far);
+            this.addFiles(far, fire_add);
             return;
         }
          
@@ -241,15 +249,17 @@ Roo.extend(Roo.bootstrap.form.HtmlEditorToolbar.Standard, Roo.bootstrap.nav.Simp
         
         var bl = sn  && this.editorcore.enableBlocks ? Roo.htmleditor.Block.factory(sn) : false;
         
-        var editor =  this.editorcore;
         
         var reader = new FileReader();
         reader.addEventListener('load', (function() {
             if (bl) {
+                var oldSrc = bl.image_src;
                 bl.image_src = reader.result;
                 //bl.caption = f.name;
                 bl.updateElement(sn);
-                editor.owner.fireEvent('editorevent', editor, false);
+                this.editor.syncValue();
+                editor.owner.fireEvent('editorevent', editor.owner, false);
+                editor.owner.fireEvent('imageupdate', editor.owner, sn, oldSrc);
                 // we only do the first file!! and replace.
                 return;
             }
@@ -260,17 +270,20 @@ Roo.extend(Roo.bootstrap.form.HtmlEditorToolbar.Standard, Roo.bootstrap.nav.Simp
                     caption_display : 'none'  //default to hide captions..
                  });
                 editor.insertAtCursor(fig.toHTML());
-                editor.owner.fireEvent('editorevent', editor, false);
+                this.addFiles(far, true);
                 return;
             }
             // just a standard img..
             if (sn && sn.tagName.toUpperCase() == 'IMG') {
+                var oldSrc = sn.src;
                 sn.src = reader.result;
-                editor.owner.fireEvent('editorevent', editor, false);
+                this.editor.syncValue();
+                editor.owner.fireEvent('editorevent', editor.owner, false);
+                editor.owner.fireEvent('imageupdate', editor.owner, sn, oldSrc);
                 return;
             }
             editor.insertAtCursor('<img src="' + reader.result +'">');
-            editor.owner.fireEvent('editorevent', editor, false);
+            this.addFiles(far, true);
             
         }).createDelegate(this));
         reader.readAsDataURL(f);
@@ -306,13 +319,15 @@ Roo.extend(Roo.bootstrap.form.HtmlEditorToolbar.Standard, Roo.bootstrap.nav.Simp
                 }
                 if (url != '') {
                     this.selectedNode.setAttribute('href', newurl);
+                    this.editor.syncValue();
                     return;
                 }
                 if(newurl && newurl .match(/http(s):\/\/.+/)) {
                     this.editorcore.relayCmd('createlink', newurl);
                 }
                 this.editorcore.focus();
-            }
+            },
+            cls : this.editorcore.linkDialogCls
         });
     },
     /**
@@ -436,6 +451,12 @@ Roo.extend(Roo.bootstrap.form.HtmlEditorToolbar.Standard, Roo.bootstrap.nav.Simp
                 selection.removeAllRanges();
                 selection.addRange(range);
                 this.updateToolbar(null, null, null);
+                if (sn.tagName.toUpperCase() == 'FIGURE') {
+                    this.editor.syncValue();
+                    this.editor.fireEvent('imagedelete', this.editor, sn);
+                }
+                
+                this.selectedNode = false;
                 this.editorcore.fireEditorEvent(false);
                 return;
             }   
@@ -455,6 +476,12 @@ Roo.extend(Roo.bootstrap.form.HtmlEditorToolbar.Standard, Roo.bootstrap.nav.Simp
         
         selection.removeAllRanges();
         selection.addRange(range);
+        if (sn.tagName.toUpperCase() == 'IMG"') {
+            this.editor.syncValue();
+            this.editor.fireEvent('imagedelete', this.editor, sn);
+        }
+        
+        this.selectedNode = false;
         this.editorcore.fireEditorEvent(false);