Roo/HtmlEditorCore.js
authorleon <leon@roojs.com>
Mon, 14 Aug 2023 03:09:13 +0000 (11:09 +0800)
committerleon <leon@roojs.com>
Mon, 14 Aug 2023 03:09:13 +0000 (11:09 +0800)
roojs-core.js
roojs-core-debug.js
roojs-ui.js
roojs-ui-debug.js
roojs-all.js
roojs-debug.js

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

index 12ee270..73147de 100644 (file)
@@ -368,6 +368,9 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
             
             var div = document.createElement('div');
             div.innerHTML = bd.innerHTML;
+
+            Roo.log('DIV');
+            Roo.log(div);
             var gtx = div.getElementsByClassName('gtx-trans-icon'); // google translate - really annoying and difficult to get rid of.
             if (gtx.length > 0) {
                 var rm = gtx.item(0).parentNode;
@@ -380,6 +383,9 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
             }
             
             var html = div.innerHTML;
+
+            Roo.log('HTML');
+            Roo.log(html);
             
             //?? tidy?
             if (this.autoClean) {
index f263f58..2c5f15d 100644 (file)
@@ -2082,9 +2082,9 @@ this.iframe=C.dom;this.assignDocWin();this.doc.designMode='on';this.doc.open();t
 catch(e){return;}Roo.TaskMgr.stop(D);this.initEditor.defer(10,this);}},interval:10,duration:10000,scope:this};Roo.TaskMgr.start(D);},onResize:function(w,h){Roo.log('resize: '+w+','+h);if(!this.iframe){return;}if(typeof w=='number'){this.iframe.style.width=w+'px';
 }if(typeof h=='number'){this.iframe.style.height=h+'px';if(this.doc){(this.doc.body||this.doc.documentElement).style.height=(h-(this.iframePad*2))+'px';}}},toggleSourceEdit:function(A){this.sourceEditMode=A===true;if(this.sourceEditMode){Roo.get(this.iframe).addClass(['x-hidden','hide','d-none']);
 }else{Roo.get(this.iframe).removeClass(['x-hidden','hide','d-none']);this.deferFocus();}},cleanHtml:function(A){A=String(A);if(A.length>5){if(Roo.isSafari){A=A.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi,'');}}if(A=='&nbsp;'){A='';}
-return A;},syncValue:function(){Roo.log('SSYNC VALUE');Roo.log("HtmlEditorCore:syncValue (EDITOR->TEXT)");if(this.initialized){if(this.undoManager){this.undoManager.addEvent();}var bd=(this.doc.body||this.doc.documentElement);var A=this.win.getSelection();
-var B=document.createElement('div');B.innerHTML=bd.innerHTML;var C=B.getElementsByClassName('gtx-trans-icon');if(C.length>0){var rm=C.item(0).parentNode;rm.parentNode.removeChild(rm);}if(this.enableBlocks){new Roo.htmleditor.FilterBlock({node:B});}var D=B.innerHTML;
-if(this.autoClean){new Roo.htmleditor.FilterAttributes({node:B,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-width','data-caption','start','style','class','allowfullscreen','frameborder','width','height','alt'],attrib_clean:['href','src']}
+return A;},syncValue:function(){Roo.log("HtmlEditorCore:syncValue (EDITOR->TEXT)");if(this.initialized){if(this.undoManager){this.undoManager.addEvent();}var bd=(this.doc.body||this.doc.documentElement);var A=this.win.getSelection();var B=document.createElement('div');
+B.innerHTML=bd.innerHTML;Roo.log('DIV');Roo.log(B);var C=B.getElementsByClassName('gtx-trans-icon');if(C.length>0){var rm=C.item(0).parentNode;rm.parentNode.removeChild(rm);}if(this.enableBlocks){new Roo.htmleditor.FilterBlock({node:B});}var D=B.innerHTML;
+Roo.log('HTML');Roo.log(D);if(this.autoClean){new Roo.htmleditor.FilterAttributes({node:B,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-width','data-caption','start','style','class','allowfullscreen','frameborder','width','height','alt'],attrib_clean:['href','src']}
 );var E=new Roo.htmleditor.TidySerializer({inner:true});D=E.serialize(B);}if(Roo.isSafari){var bs=bd.getAttribute('style');var m=bs?bs.match(/text-align:(.*?);/i):false;if(m&&m[1]){D='<div style="'+m[0]+'">'+D+'</div>';}}D=this.cleanHtml(D);D=D.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g,function(F){var cc=F.charCodeAt();
 if(F.length==2){var G=F.charCodeAt(0)-0xD800;var H=F.charCodeAt(1)-0xDC00;cc=(G*0x400)+H+0x10000;}else if((cc>=0x4E00&&cc<0xA000)||(cc>=0x3400&&cc<0x4E00)||(cc>=0xf900&&cc<0xfb00)){return F;}return "&#"+cc+";";});if(this.owner.fireEvent('beforesync',this,D)!==false){this.el.dom.value=D;
 this.owner.fireEvent('sync',this,D);}}},pushValue:function(){if(this.initialized){var v=this.el.dom.value.trim();if(this.owner.fireEvent('beforepush',this,v)!==false){var d=(this.doc.body||this.doc.documentElement);d.innerHTML=v;this.el.dom.value=d.innerHTML;
index 4a1b3b0..1c2a4af 100644 (file)
@@ -50305,7 +50305,6 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
      */
     syncValue : function()
     {
-        Roo.log('SSYNC VALUE');
         Roo.log("HtmlEditorCore:syncValue (EDITOR->TEXT)");
         if(this.initialized){
             
@@ -50321,6 +50320,9 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
             
             var div = document.createElement('div');
             div.innerHTML = bd.innerHTML;
+
+            Roo.log('DIV');
+            Roo.log(div);
             var gtx = div.getElementsByClassName('gtx-trans-icon'); // google translate - really annoying and difficult to get rid of.
             if (gtx.length > 0) {
                 var rm = gtx.item(0).parentNode;
@@ -50333,6 +50335,9 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
             }
             
             var html = div.innerHTML;
+
+            Roo.log('HTML');
+            Roo.log(html);
             
             //?? tidy?
             if (this.autoClean) {
index f527cc5..9afcfa1 100644 (file)
@@ -25803,7 +25803,6 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
      */
     syncValue : function()
     {
-        Roo.log('SSYNC VALUE');
         Roo.log("HtmlEditorCore:syncValue (EDITOR->TEXT)");
         if(this.initialized){
             
@@ -25819,6 +25818,9 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
             
             var div = document.createElement('div');
             div.innerHTML = bd.innerHTML;
+
+            Roo.log('DIV');
+            Roo.log(div);
             var gtx = div.getElementsByClassName('gtx-trans-icon'); // google translate - really annoying and difficult to get rid of.
             if (gtx.length > 0) {
                 var rm = gtx.item(0).parentNode;
@@ -25831,6 +25833,9 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
             }
             
             var html = div.innerHTML;
+
+            Roo.log('HTML');
+            Roo.log(html);
             
             //?? tidy?
             if (this.autoClean) {
index ab5f366..78df5d8 100644 (file)
@@ -1135,9 +1135,9 @@ this.iframe=C.dom;this.assignDocWin();this.doc.designMode='on';this.doc.open();t
 catch(e){return;}Roo.TaskMgr.stop(D);this.initEditor.defer(10,this);}},interval:10,duration:10000,scope:this};Roo.TaskMgr.start(D);},onResize:function(w,h){Roo.log('resize: '+w+','+h);if(!this.iframe){return;}if(typeof w=='number'){this.iframe.style.width=w+'px';
 }if(typeof h=='number'){this.iframe.style.height=h+'px';if(this.doc){(this.doc.body||this.doc.documentElement).style.height=(h-(this.iframePad*2))+'px';}}},toggleSourceEdit:function(A){this.sourceEditMode=A===true;if(this.sourceEditMode){Roo.get(this.iframe).addClass(['x-hidden','hide','d-none']);
 }else{Roo.get(this.iframe).removeClass(['x-hidden','hide','d-none']);this.deferFocus();}},cleanHtml:function(A){A=String(A);if(A.length>5){if(Roo.isSafari){A=A.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi,'');}}if(A=='&nbsp;'){A='';}
-return A;},syncValue:function(){Roo.log('SSYNC VALUE');Roo.log("HtmlEditorCore:syncValue (EDITOR->TEXT)");if(this.initialized){if(this.undoManager){this.undoManager.addEvent();}var bd=(this.doc.body||this.doc.documentElement);var A=this.win.getSelection();
-var B=document.createElement('div');B.innerHTML=bd.innerHTML;var C=B.getElementsByClassName('gtx-trans-icon');if(C.length>0){var rm=C.item(0).parentNode;rm.parentNode.removeChild(rm);}if(this.enableBlocks){new Roo.htmleditor.FilterBlock({node:B});}var D=B.innerHTML;
-if(this.autoClean){new Roo.htmleditor.FilterAttributes({node:B,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-width','data-caption','start','style','class','allowfullscreen','frameborder','width','height','alt'],attrib_clean:['href','src']}
+return A;},syncValue:function(){Roo.log("HtmlEditorCore:syncValue (EDITOR->TEXT)");if(this.initialized){if(this.undoManager){this.undoManager.addEvent();}var bd=(this.doc.body||this.doc.documentElement);var A=this.win.getSelection();var B=document.createElement('div');
+B.innerHTML=bd.innerHTML;Roo.log('DIV');Roo.log(B);var C=B.getElementsByClassName('gtx-trans-icon');if(C.length>0){var rm=C.item(0).parentNode;rm.parentNode.removeChild(rm);}if(this.enableBlocks){new Roo.htmleditor.FilterBlock({node:B});}var D=B.innerHTML;
+Roo.log('HTML');Roo.log(D);if(this.autoClean){new Roo.htmleditor.FilterAttributes({node:B,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-width','data-caption','start','style','class','allowfullscreen','frameborder','width','height','alt'],attrib_clean:['href','src']}
 );var E=new Roo.htmleditor.TidySerializer({inner:true});D=E.serialize(B);}if(Roo.isSafari){var bs=bd.getAttribute('style');var m=bs?bs.match(/text-align:(.*?);/i):false;if(m&&m[1]){D='<div style="'+m[0]+'">'+D+'</div>';}}D=this.cleanHtml(D);D=D.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g,function(F){var cc=F.charCodeAt();
 if(F.length==2){var G=F.charCodeAt(0)-0xD800;var H=F.charCodeAt(1)-0xDC00;cc=(G*0x400)+H+0x10000;}else if((cc>=0x4E00&&cc<0xA000)||(cc>=0x3400&&cc<0x4E00)||(cc>=0xf900&&cc<0xfb00)){return F;}return "&#"+cc+";";});if(this.owner.fireEvent('beforesync',this,D)!==false){this.el.dom.value=D;
 this.owner.fireEvent('sync',this,D);}}},pushValue:function(){if(this.initialized){var v=this.el.dom.value.trim();if(this.owner.fireEvent('beforepush',this,v)!==false){var d=(this.doc.body||this.doc.documentElement);d.innerHTML=v;this.el.dom.value=d.innerHTML;