roojs-ui.js
authorAlan <alan@roojs.com>
Thu, 19 Jan 2023 08:01:11 +0000 (16:01 +0800)
committerAlan <alan@roojs.com>
Thu, 19 Jan 2023 08:01:11 +0000 (16:01 +0800)
roojs-ui-debug.js
roojs-bootstrap.js
roojs-bootstrap-debug.js
roojs-all.js
roojs-debug.js
Roo/HtmlEditorCore.js

Roo/HtmlEditorCore.js
roojs-all.js
roojs-bootstrap-debug.js
roojs-bootstrap.js
roojs-debug.js
roojs-ui-debug.js
roojs-ui.js

index e3466d6..df711e9 100644 (file)
@@ -608,8 +608,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
                 (window.webkitURL && webkitURL);
     
             var url = urlAPI.createObjectURL( cd.files[0]);
-            this.insertAtCursor('<img src="' + url + '">');
-            var d = (new DOMParser().parseFromString('<img src="' + url + '">', 'text/html')).body;
+             var d = (new DOMParser().parseFromString('<img src="' + url + '">', 'text/html')).body;
             // is insert asycn?
             if (this.enableBlocks) {
                 
index 08e4b49..b1ce3d5 100644 (file)
@@ -2094,7 +2094,8 @@ this.win=(A.contentWindow||Roo.get(this.frameId).dom.contentWindow);}},initEdito
 A.bgProperties='fixed';A.setAttribute("translate","no");Roo.EventManager.on(this.doc,{'mouseup':this.onEditorEvent,'dblclick':this.onEditorEvent,'click':this.onEditorEvent,'keyup':this.onEditorEvent,buffer:100,scope:this});Roo.EventManager.on(this.doc,{'paste':this.onPasteEvent,scope:this}
 );if(Roo.isGecko){Roo.EventManager.on(this.doc,'keypress',this.mozKeyPress,this);}if(Roo.isIE||Roo.isSafari||Roo.isOpera){Roo.EventManager.on(this.doc,'keydown',this.fixKeys,this);}this.initialized=true;new Roo.htmleditor.KeyEnter({core:this});this.owner.fireEvent('initialize',this);
 this.pushValue();},onPasteEvent:function(e,v){var cd=(e.browserEvent.clipboardData||window.clipboardData);if(cd.files&&cd.files.length>0){var A=(window.createObjectURL&&window)||(window.URL&&URL.revokeObjectURL&&URL)||(window.webkitURL&&webkitURL);var B=A.createObjectURL(cd.files[0]);
-this.insertAtCursor('<img src=" + url + ">');return false;}if(cd.types.indexOf('text/html')<0){return false;}var C=[];var D=cd.getData('text/html');if(cd.types.indexOf('text/rtf')>-1){var E=new Roo.rtf.Parser(cd.getData('text/rtf'));C=E.doc?E.doc.getElementsByType('pict'):[];
+var d=(new DOMParser().parseFromString('<img src="'+B+'">','text/html')).body;if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(F){if(F.closest('figure')){return;}var G=new Roo.htmleditor.BlockFigure({image_src:F.src});G.updateElement(F);
+});}this.insertAtCursor(d.innerHTML.replace(/&nbsp;/g,' '));return false;}if(cd.types.indexOf('text/html')<0){return false;}var C=[];var D=cd.getData('text/html');if(cd.types.indexOf('text/rtf')>-1){var E=new Roo.rtf.Parser(cd.getData('text/rtf'));C=E.doc?E.doc.getElementsByType('pict'):[];
 }C=C.filter(function(g){return !g.path.match(/^rtf\/(head|pgdsctbl|listtable|footerf)/);}).map(function(g){return g.toDataURL();}).filter(function(g){return g!='about:blank';});D=this.cleanWordChars(D);var d=(new DOMParser().parseFromString(D,'text/html')).body;
 var sn=this.getParentElement();if(d.getElementsByTagName('table').length&&sn&&sn.closest('table')){e.preventDefault();this.insertAtCursor("You can not nest tables");return false;}if(C.length>0){var ar=Array.from(d.getElementsByTagName('v:imagedata'));Roo.each(ar,function(F){F.parentNode.insertBefore(d.ownerDocument.createElement('img'),F);
 F.parentNode.removeChild(F);});Roo.each(d.getElementsByTagName('img'),function(F,i){F.setAttribute('src',C[i]);});}if(this.autoClean){new Roo.htmleditor.FilterWord({node:d});new Roo.htmleditor.FilterStyleToTag({node:d});new Roo.htmleditor.FilterAttributes({node:d,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-width','start'],attrib_clean:['href','src']}
index ab78981..75ac4ff 100644 (file)
@@ -31375,7 +31375,22 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
                 (window.webkitURL && webkitURL);
     
             var url = urlAPI.createObjectURL( cd.files[0]);
-            this.insertAtCursor('<img src=" + url + ">');
+             var d = (new DOMParser().parseFromString('<img src="' + url + '">', 'text/html')).body;
+            // is insert asycn?
+            if (this.enableBlocks) {
+                
+                Array.from(d.getElementsByTagName('img')).forEach(function(img) {
+                    if (img.closest('figure')) { // assume!! that it's aready
+                        return;
+                    }
+                    var fig  = new Roo.htmleditor.BlockFigure({
+                        image_src  : img.src
+                    });
+                    fig.updateElement(img); // replace it..
+                    
+                });
+            }
+            this.insertAtCursor(d.innerHTML.replace(/&nbsp;/g,' '));
             return false;
         }
         if (cd.types.indexOf('text/html') < 0 ) {
index dd8aed6..f4b7a72 100644 (file)
@@ -1349,7 +1349,8 @@ this.win=(A.contentWindow||Roo.get(this.frameId).dom.contentWindow);}},initEdito
 A.bgProperties='fixed';A.setAttribute("translate","no");Roo.EventManager.on(this.doc,{'mouseup':this.onEditorEvent,'dblclick':this.onEditorEvent,'click':this.onEditorEvent,'keyup':this.onEditorEvent,buffer:100,scope:this});Roo.EventManager.on(this.doc,{'paste':this.onPasteEvent,scope:this}
 );if(Roo.isGecko){Roo.EventManager.on(this.doc,'keypress',this.mozKeyPress,this);}if(Roo.isIE||Roo.isSafari||Roo.isOpera){Roo.EventManager.on(this.doc,'keydown',this.fixKeys,this);}this.initialized=true;new Roo.htmleditor.KeyEnter({core:this});this.owner.fireEvent('initialize',this);
 this.pushValue();},onPasteEvent:function(e,v){var cd=(e.browserEvent.clipboardData||window.clipboardData);if(cd.files&&cd.files.length>0){var A=(window.createObjectURL&&window)||(window.URL&&URL.revokeObjectURL&&URL)||(window.webkitURL&&webkitURL);var B=A.createObjectURL(cd.files[0]);
-this.insertAtCursor('<img src=" + url + ">');return false;}if(cd.types.indexOf('text/html')<0){return false;}var C=[];var D=cd.getData('text/html');if(cd.types.indexOf('text/rtf')>-1){var E=new Roo.rtf.Parser(cd.getData('text/rtf'));C=E.doc?E.doc.getElementsByType('pict'):[];
+var d=(new DOMParser().parseFromString('<img src="'+B+'">','text/html')).body;if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(F){if(F.closest('figure')){return;}var G=new Roo.htmleditor.BlockFigure({image_src:F.src});G.updateElement(F);
+});}this.insertAtCursor(d.innerHTML.replace(/&nbsp;/g,' '));return false;}if(cd.types.indexOf('text/html')<0){return false;}var C=[];var D=cd.getData('text/html');if(cd.types.indexOf('text/rtf')>-1){var E=new Roo.rtf.Parser(cd.getData('text/rtf'));C=E.doc?E.doc.getElementsByType('pict'):[];
 }C=C.filter(function(g){return !g.path.match(/^rtf\/(head|pgdsctbl|listtable|footerf)/);}).map(function(g){return g.toDataURL();}).filter(function(g){return g!='about:blank';});D=this.cleanWordChars(D);var d=(new DOMParser().parseFromString(D,'text/html')).body;
 var sn=this.getParentElement();if(d.getElementsByTagName('table').length&&sn&&sn.closest('table')){e.preventDefault();this.insertAtCursor("You can not nest tables");return false;}if(C.length>0){var ar=Array.from(d.getElementsByTagName('v:imagedata'));Roo.each(ar,function(F){F.parentNode.insertBefore(d.ownerDocument.createElement('img'),F);
 F.parentNode.removeChild(F);});Roo.each(d.getElementsByTagName('img'),function(F,i){F.setAttribute('src',C[i]);});}if(this.autoClean){new Roo.htmleditor.FilterWord({node:d});new Roo.htmleditor.FilterStyleToTag({node:d});new Roo.htmleditor.FilterAttributes({node:d,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-width','start'],attrib_clean:['href','src']}
index be87bff..65b8f24 100644 (file)
@@ -50542,7 +50542,22 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
                 (window.webkitURL && webkitURL);
     
             var url = urlAPI.createObjectURL( cd.files[0]);
-            this.insertAtCursor('<img src=" + url + ">');
+             var d = (new DOMParser().parseFromString('<img src="' + url + '">', 'text/html')).body;
+            // is insert asycn?
+            if (this.enableBlocks) {
+                
+                Array.from(d.getElementsByTagName('img')).forEach(function(img) {
+                    if (img.closest('figure')) { // assume!! that it's aready
+                        return;
+                    }
+                    var fig  = new Roo.htmleditor.BlockFigure({
+                        image_src  : img.src
+                    });
+                    fig.updateElement(img); // replace it..
+                    
+                });
+            }
+            this.insertAtCursor(d.innerHTML.replace(/&nbsp;/g,' '));
             return false;
         }
         if (cd.types.indexOf('text/html') < 0 ) {
index 1fff0c8..090f491 100644 (file)
@@ -26040,7 +26040,22 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
                 (window.webkitURL && webkitURL);
     
             var url = urlAPI.createObjectURL( cd.files[0]);
-            this.insertAtCursor('<img src=" + url + ">');
+             var d = (new DOMParser().parseFromString('<img src="' + url + '">', 'text/html')).body;
+            // is insert asycn?
+            if (this.enableBlocks) {
+                
+                Array.from(d.getElementsByTagName('img')).forEach(function(img) {
+                    if (img.closest('figure')) { // assume!! that it's aready
+                        return;
+                    }
+                    var fig  = new Roo.htmleditor.BlockFigure({
+                        image_src  : img.src
+                    });
+                    fig.updateElement(img); // replace it..
+                    
+                });
+            }
+            this.insertAtCursor(d.innerHTML.replace(/&nbsp;/g,' '));
             return false;
         }
         if (cd.types.indexOf('text/html') < 0 ) {
index 220dacb..b284928 100644 (file)
@@ -1147,7 +1147,8 @@ this.win=(A.contentWindow||Roo.get(this.frameId).dom.contentWindow);}},initEdito
 A.bgProperties='fixed';A.setAttribute("translate","no");Roo.EventManager.on(this.doc,{'mouseup':this.onEditorEvent,'dblclick':this.onEditorEvent,'click':this.onEditorEvent,'keyup':this.onEditorEvent,buffer:100,scope:this});Roo.EventManager.on(this.doc,{'paste':this.onPasteEvent,scope:this}
 );if(Roo.isGecko){Roo.EventManager.on(this.doc,'keypress',this.mozKeyPress,this);}if(Roo.isIE||Roo.isSafari||Roo.isOpera){Roo.EventManager.on(this.doc,'keydown',this.fixKeys,this);}this.initialized=true;new Roo.htmleditor.KeyEnter({core:this});this.owner.fireEvent('initialize',this);
 this.pushValue();},onPasteEvent:function(e,v){var cd=(e.browserEvent.clipboardData||window.clipboardData);if(cd.files&&cd.files.length>0){var A=(window.createObjectURL&&window)||(window.URL&&URL.revokeObjectURL&&URL)||(window.webkitURL&&webkitURL);var B=A.createObjectURL(cd.files[0]);
-this.insertAtCursor('<img src=" + url + ">');return false;}if(cd.types.indexOf('text/html')<0){return false;}var C=[];var D=cd.getData('text/html');if(cd.types.indexOf('text/rtf')>-1){var E=new Roo.rtf.Parser(cd.getData('text/rtf'));C=E.doc?E.doc.getElementsByType('pict'):[];
+var d=(new DOMParser().parseFromString('<img src="'+B+'">','text/html')).body;if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(F){if(F.closest('figure')){return;}var G=new Roo.htmleditor.BlockFigure({image_src:F.src});G.updateElement(F);
+});}this.insertAtCursor(d.innerHTML.replace(/&nbsp;/g,' '));return false;}if(cd.types.indexOf('text/html')<0){return false;}var C=[];var D=cd.getData('text/html');if(cd.types.indexOf('text/rtf')>-1){var E=new Roo.rtf.Parser(cd.getData('text/rtf'));C=E.doc?E.doc.getElementsByType('pict'):[];
 }C=C.filter(function(g){return !g.path.match(/^rtf\/(head|pgdsctbl|listtable|footerf)/);}).map(function(g){return g.toDataURL();}).filter(function(g){return g!='about:blank';});D=this.cleanWordChars(D);var d=(new DOMParser().parseFromString(D,'text/html')).body;
 var sn=this.getParentElement();if(d.getElementsByTagName('table').length&&sn&&sn.closest('table')){e.preventDefault();this.insertAtCursor("You can not nest tables");return false;}if(C.length>0){var ar=Array.from(d.getElementsByTagName('v:imagedata'));Roo.each(ar,function(F){F.parentNode.insertBefore(d.ownerDocument.createElement('img'),F);
 F.parentNode.removeChild(F);});Roo.each(d.getElementsByTagName('img'),function(F,i){F.setAttribute('src',C[i]);});}if(this.autoClean){new Roo.htmleditor.FilterWord({node:d});new Roo.htmleditor.FilterStyleToTag({node:d});new Roo.htmleditor.FilterAttributes({node:d,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-width','start'],attrib_clean:['href','src']}