From d4a05789ab4b83c2392d81717e410d465904c4d8 Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 7 Sep 2023 12:50:05 +0800 Subject: [PATCH] fix #7793 - captions editing should store values in outer figure, rather than caption --- docs/src/Roo_HtmlEditorCore.js.html | 23 ++++- docs/src/Roo_form_VTypes.js.html | 2 +- docs/src/Roo_htmleditor_BlockFigure.js.html | 105 +++++++++++--------- roojs-all.js | 8 +- roojs-bootstrap-debug.js | 25 ++++- roojs-bootstrap.js | 8 +- roojs-debug.js | 25 ++++- roojs-ui-debug.js | 25 ++++- roojs-ui.js | 8 +- 9 files changed, 163 insertions(+), 66 deletions(-) diff --git a/docs/src/Roo_HtmlEditorCore.js.html b/docs/src/Roo_HtmlEditorCore.js.html index 8cec2ce890..f0c3f2bfde 100644 --- a/docs/src/Roo_HtmlEditorCore.js.html +++ b/docs/src/Roo_HtmlEditorCore.js.html @@ -394,6 +394,7 @@ 'colspan', 'rowspan', 'data-display', + 'data-caption-display', 'data-width', 'data-caption', 'start' , @@ -692,7 +693,27 @@ 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_white : [ + 'href', + 'src', + 'name', + 'align', + 'colspan', + 'rowspan', + 'data-display', + 'data-caption-display', + 'data-width', + 'data-caption', + 'start' , + 'style', + // youtube embed. + 'class', + 'allowfullscreen', + 'frameborder', + 'width', + 'height', + 'alt' + ], attrib_clean : ['href', 'src' ] }); new Roo.htmleditor.FilterBlack({ node : d, tag : this.black}); diff --git a/docs/src/Roo_form_VTypes.js.html b/docs/src/Roo_form_VTypes.js.html index 9fe8cb7cc7..39316c8de9 100644 --- a/docs/src/Roo_form_VTypes.js.html +++ b/docs/src/Roo_form_VTypes.js.html @@ -17,7 +17,7 @@ // closure these in so they are only created once. var alpha = /^[a-zA-Z_]+$/; var alphanum = /^[a-zA-Z0-9_]+$/; - var email = /^([\w]+)(\.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/; + var email = /^([\w-]+)(\.[\w-]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/; var url = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i; var urlWeb = /^((https?):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i; diff --git a/docs/src/Roo_htmleditor_BlockFigure.js.html b/docs/src/Roo_htmleditor_BlockFigure.js.html index 31e3595096..574a27e4e2 100644 --- a/docs/src/Roo_htmleditor_BlockFigure.js.html +++ b/docs/src/Roo_htmleditor_BlockFigure.js.html @@ -315,8 +315,7 @@ ] }; } - // we remove caption totally if its hidden... - will delete data.. but otherwise we end up with fake caption - var captionhtml = this.caption_display == 'none' ? '' : (this.caption.length ? this.caption : "Caption"); + var ret = { @@ -324,6 +323,7 @@ 'data-block' : 'Figure', 'data-width' : this.width, 'data-caption' : this.caption, + 'data-caption-display' : this.caption_display, contenteditable : 'false', style : { @@ -337,50 +337,51 @@ }, - align : this.align, cn : [ - img, - - { - tag: 'figcaption', - 'data-display' : this.caption_display, - style : { - textAlign : 'left', - fontSize : '16px', - lineHeight : '24px', - display : this.caption_display, - maxWidth : (this.align == 'center' ? this.width : '100%' ) + ' !important', - margin: m, - width: this.align == 'center' ? this.width : '100%' - - - }, - cls : this.cls.length > 0 ? (this.cls + '-thumbnail' ) : '', - cn : [ - { - tag: 'div', - style : { - marginTop : '16px', - textAlign : 'left' - }, - align: 'left', - cn : [ - { - // we can not rely on yahoo syndication to use CSS elements - so have to use '<i>' to encase stuff. - tag : 'i', - contenteditable : Roo.htmleditor.BlockFigure.caption_edit, - html : captionhtml - } - - ] - } - - ] - - } - ] + img + ] }; + + // show figcaption only if caption_display is 'block' + if(this.caption_display == 'block') { + ret['cn'].push({ + tag: 'figcaption', + style : { + textAlign : 'left', + fontSize : '16px', + lineHeight : '24px', + display : this.caption_display, + maxWidth : (this.align == 'center' ? this.width : '100%' ) + ' !important', + margin: m, + width: this.align == 'center' ? this.width : '100%' + + + }, + cls : this.cls.length > 0 ? (this.cls + '-thumbnail' ) : '', + cn : [ + { + tag: 'div', + style : { + marginTop : '16px', + textAlign : 'left' + }, + align: 'left', + cn : [ + { + // we can not rely on yahoo syndication to use CSS elements - so have to use '<i>' to encase stuff. + tag : 'i', + contenteditable : Roo.htmleditor.BlockFigure.caption_edit, + html : this.caption.length ? this.caption : "Caption" // fake caption + } + + ] + } + + ] + + }); + } return ret; }, @@ -397,18 +398,30 @@ this.align = this.getVal(node, 'figure', 'align'); - /// not really used - as hidden captions do not store the content here.. + // caption display is stored in figure + this.caption_display = this.getVal(node, true, 'data-caption-display'); + + // backward compatible + // it was stored in figcaption + if(this.caption_display == '') { + this.caption_display = this.getVal(node, 'figcaption', 'data-display'); + } + + // read caption from figcaption var figcaption = this.getVal(node, 'figcaption', false); + if (figcaption !== '') { this.caption = this.getVal(figcaption, 'i', 'html'); } - this.caption_display = this.getVal(node, 'figcaption', 'data-display'); + // read caption from data-caption in figure if no caption from figcaption var dc = this.getVal(node, true, 'data-caption'); - if (this.caption_display == 'none' && figcaption != '' && dc && dc.length) { + + if(this.caption_display == 'none' && dc && dc.length){ this.caption = dc; } + //this.text_align = this.getVal(node, 'figcaption', 'style','text-align'); this.width = this.getVal(node, true, 'data-width'); //this.margin = this.getVal(node, 'figure', 'style', 'margin'); diff --git a/roojs-all.js b/roojs-all.js index 7e8904f35d..6c81e57786 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -2016,8 +2016,8 @@ A.editorcore.onEditorEvent();}},xns:C.Toolbar}];},toObject:function(){var d=docu ,align:this.align,cn:[A]};if(this.caption_display=='block'){B['cn'].push({tag:'figcaption',style:{textAlign:'left',fontSize:'16px',lineHeight:'24px',display:this.caption_display,maxWidth:(this.align=='center'?this.width:'100%')+' !important',margin:m,width:this.align=='center'?this.width:'100%'} ,cls:this.cls.length>0?(this.cls+'-thumbnail'):'',cn:[{tag:'div',style:{marginTop:'16px',textAlign:'left'},align:'left',cn:[{tag:'i',contenteditable:Roo.htmleditor.BlockFigure.caption_edit,html:this.caption.length?this.caption:"Caption"}]}]});}return B;},readElement:function(A){this.video_url=this.getVal(A,'div','src'); this.cls=this.getVal(A,'div','class');this.href=this.getVal(A,'a','href');this.image_src=this.getVal(A,'img','src');this.align=this.getVal(A,'figure','align');this.caption_display=this.getVal(A,true,'data-caption-display');if(this.caption_display==''){this.caption_display=this.getVal(A,'figcaption','data-display'); -}var B=this.getVal(A,'figcaption',false);if(B!==''){this.caption=this.getVal(B,'i','html');}var dc=this.getVal(A,true,'data-caption');if(this.caption_display=='none'&&this.caption==''&&dc&&dc.length){this.caption=dc;}this.width=this.getVal(A,true,'data-width'); -},removeNode:function(){return this.node;}});Roo.apply(Roo.htmleditor.BlockFigure,{caption_edit:true}); +}var B=this.getVal(A,'figcaption',false);if(B!==''){this.caption=this.getVal(B,'i','html');}var dc=this.getVal(A,true,'data-caption');if(this.caption_display=='none'&&dc&&dc.length){this.caption=dc;}this.width=this.getVal(A,true,'data-width');},removeNode:function(){return this.node; +}});Roo.apply(Roo.htmleditor.BlockFigure,{caption_edit:true}); // Roo/htmleditor/BlockTable.js Roo.htmleditor.BlockTable=function(A){if(A.node){this.readElement(A.node);this.updateElement(A.node);}Roo.apply(this,A);if(!A.node){this.rows=[];for(var r=0;r5){if(Roo.isSafari){A=A.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi,'');}}if(A==' '){A='';} return A;},syncValue:function(){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-caption-display','data-width','data-caption','start','style','class','allowfullscreen','frameborder','width','height','alt'],attrib_clean:['href','src']} +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-caption-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='
'+D+'
';}}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; @@ -2099,7 +2099,7 @@ var r=new FileReader();var t=this;r.addEventListener('load',function(){var d=(ne }var B=[];var C=cd.getData('text/html');if(cd.types.indexOf('text/rtf')>-1){var D=new Roo.rtf.Parser(cd.getData('text/rtf'));B=D.doc?D.doc.getElementsByType('pict'):[];}B=B.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';});C=this.cleanWordChars(C);var d=(new DOMParser().parseFromString(C,'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(B.length>0){var ar=Array.from(d.getElementsByTagName('v:imagedata'));Roo.each(ar,function(E){E.parentNode.insertBefore(d.ownerDocument.createElement('img'),E);E.parentNode.removeChild(E);});Roo.each(d.getElementsByTagName('img'),function(E,i){E.setAttribute('src',B[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']} +});}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-caption-display','data-width','data-caption','start','style','class','allowfullscreen','frameborder','width','height','alt'],attrib_clean:['href','src']} );new Roo.htmleditor.FilterBlack({node:d,tag:this.black});new Roo.htmleditor.FilterKeepChildren({node:d,tag:['FONT',':']});new Roo.htmleditor.FilterParagraph({node:d});new Roo.htmleditor.FilterSpan({node:d});new Roo.htmleditor.FilterLongBr({node:d});new Roo.htmleditor.FilterComment({node:d} );}if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(E){if(E.closest('figure')){return;}var F=new Roo.htmleditor.BlockFigure({image_src:E.src});F.updateElement(E);});}this.insertAtCursor(d.innerHTML.replace(/ /g,' '));if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body); }e.preventDefault();this.owner.fireEvent('paste',this);return false;},onDestroy:function(){if(this.rendered){}},onFirstFocus:function(){this.assignDocWin();this.undoManager=new Roo.lib.UndoManager(100,(this.doc.body||this.doc.documentElement));this.activated=true; diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index d7a36ad3f5..ef5098bbea 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -29800,7 +29800,7 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { // read caption from data-caption in figure if no caption from figcaption var dc = this.getVal(node, true, 'data-caption'); - if(this.caption_display == 'none' && this.caption == '' && dc && dc.length){ + if(this.caption_display == 'none' && dc && dc.length){ this.caption = dc; } @@ -31469,6 +31469,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { 'align', 'colspan', 'rowspan', + 'data-display', 'data-caption-display', 'data-width', 'data-caption', @@ -31768,7 +31769,27 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { 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_white : [ + 'href', + 'src', + 'name', + 'align', + 'colspan', + 'rowspan', + 'data-display', + 'data-caption-display', + 'data-width', + 'data-caption', + 'start' , + 'style', + // youtube embed. + 'class', + 'allowfullscreen', + 'frameborder', + 'width', + 'height', + 'alt' + ], attrib_clean : ['href', 'src' ] }); new Roo.htmleditor.FilterBlack({ node : d, tag : this.black}); diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 2832bbcb1d..ab86e6d24d 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -1290,8 +1290,8 @@ A.editorcore.onEditorEvent();}},xns:C.Toolbar}];},toObject:function(){var d=docu ,align:this.align,cn:[A]};if(this.caption_display=='block'){B['cn'].push({tag:'figcaption',style:{textAlign:'left',fontSize:'16px',lineHeight:'24px',display:this.caption_display,maxWidth:(this.align=='center'?this.width:'100%')+' !important',margin:m,width:this.align=='center'?this.width:'100%'} ,cls:this.cls.length>0?(this.cls+'-thumbnail'):'',cn:[{tag:'div',style:{marginTop:'16px',textAlign:'left'},align:'left',cn:[{tag:'i',contenteditable:Roo.htmleditor.BlockFigure.caption_edit,html:this.caption.length?this.caption:"Caption"}]}]});}return B;},readElement:function(A){this.video_url=this.getVal(A,'div','src'); this.cls=this.getVal(A,'div','class');this.href=this.getVal(A,'a','href');this.image_src=this.getVal(A,'img','src');this.align=this.getVal(A,'figure','align');this.caption_display=this.getVal(A,true,'data-caption-display');if(this.caption_display==''){this.caption_display=this.getVal(A,'figcaption','data-display'); -}var B=this.getVal(A,'figcaption',false);if(B!==''){this.caption=this.getVal(B,'i','html');}var dc=this.getVal(A,true,'data-caption');if(this.caption_display=='none'&&this.caption==''&&dc&&dc.length){this.caption=dc;}this.width=this.getVal(A,true,'data-width'); -},removeNode:function(){return this.node;}});Roo.apply(Roo.htmleditor.BlockFigure,{caption_edit:true}); +}var B=this.getVal(A,'figcaption',false);if(B!==''){this.caption=this.getVal(B,'i','html');}var dc=this.getVal(A,true,'data-caption');if(this.caption_display=='none'&&dc&&dc.length){this.caption=dc;}this.width=this.getVal(A,true,'data-width');},removeNode:function(){return this.node; +}});Roo.apply(Roo.htmleditor.BlockFigure,{caption_edit:true}); // Roo/htmleditor/BlockTable.js Roo.htmleditor.BlockTable=function(A){if(A.node){this.readElement(A.node);this.updateElement(A.node);}Roo.apply(this,A);if(!A.node){this.rows=[];for(var r=0;r5){if(Roo.isSafari){A=A.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi,'');}}if(A==' '){A='';} return A;},syncValue:function(){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-caption-display','data-width','data-caption','start','style','class','allowfullscreen','frameborder','width','height','alt'],attrib_clean:['href','src']} +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-caption-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='
'+D+'
';}}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; @@ -1373,7 +1373,7 @@ var r=new FileReader();var t=this;r.addEventListener('load',function(){var d=(ne }var B=[];var C=cd.getData('text/html');if(cd.types.indexOf('text/rtf')>-1){var D=new Roo.rtf.Parser(cd.getData('text/rtf'));B=D.doc?D.doc.getElementsByType('pict'):[];}B=B.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';});C=this.cleanWordChars(C);var d=(new DOMParser().parseFromString(C,'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(B.length>0){var ar=Array.from(d.getElementsByTagName('v:imagedata'));Roo.each(ar,function(E){E.parentNode.insertBefore(d.ownerDocument.createElement('img'),E);E.parentNode.removeChild(E);});Roo.each(d.getElementsByTagName('img'),function(E,i){E.setAttribute('src',B[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']} +});}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-caption-display','data-width','data-caption','start','style','class','allowfullscreen','frameborder','width','height','alt'],attrib_clean:['href','src']} );new Roo.htmleditor.FilterBlack({node:d,tag:this.black});new Roo.htmleditor.FilterKeepChildren({node:d,tag:['FONT',':']});new Roo.htmleditor.FilterParagraph({node:d});new Roo.htmleditor.FilterSpan({node:d});new Roo.htmleditor.FilterLongBr({node:d});new Roo.htmleditor.FilterComment({node:d} );}if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(E){if(E.closest('figure')){return;}var F=new Roo.htmleditor.BlockFigure({image_src:E.src});F.updateElement(E);});}this.insertAtCursor(d.innerHTML.replace(/ /g,' '));if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body); }e.preventDefault();this.owner.fireEvent('paste',this);return false;},onDestroy:function(){if(this.rendered){}},onFirstFocus:function(){this.assignDocWin();this.undoManager=new Roo.lib.UndoManager(100,(this.doc.body||this.doc.documentElement));this.activated=true; diff --git a/roojs-debug.js b/roojs-debug.js index 010cdd7b04..a9c4f96d3c 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -48693,7 +48693,7 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { // read caption from data-caption in figure if no caption from figcaption var dc = this.getVal(node, true, 'data-caption'); - if(this.caption_display == 'none' && this.caption == '' && dc && dc.length){ + if(this.caption_display == 'none' && dc && dc.length){ this.caption = dc; } @@ -50362,6 +50362,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { 'align', 'colspan', 'rowspan', + 'data-display', 'data-caption-display', 'data-width', 'data-caption', @@ -50661,7 +50662,27 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { 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_white : [ + 'href', + 'src', + 'name', + 'align', + 'colspan', + 'rowspan', + 'data-display', + 'data-caption-display', + 'data-width', + 'data-caption', + 'start' , + 'style', + // youtube embed. + 'class', + 'allowfullscreen', + 'frameborder', + 'width', + 'height', + 'alt' + ], attrib_clean : ['href', 'src' ] }); new Roo.htmleditor.FilterBlack({ node : d, tag : this.black}); diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index 07f94148fe..f62a8e52e0 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -24191,7 +24191,7 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { // read caption from data-caption in figure if no caption from figcaption var dc = this.getVal(node, true, 'data-caption'); - if(this.caption_display == 'none' && this.caption == '' && dc && dc.length){ + if(this.caption_display == 'none' && dc && dc.length){ this.caption = dc; } @@ -25860,6 +25860,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { 'align', 'colspan', 'rowspan', + 'data-display', 'data-caption-display', 'data-width', 'data-caption', @@ -26159,7 +26160,27 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { 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_white : [ + 'href', + 'src', + 'name', + 'align', + 'colspan', + 'rowspan', + 'data-display', + 'data-caption-display', + 'data-width', + 'data-caption', + 'start' , + 'style', + // youtube embed. + 'class', + 'allowfullscreen', + 'frameborder', + 'width', + 'height', + 'alt' + ], attrib_clean : ['href', 'src' ] }); new Roo.htmleditor.FilterBlack({ node : d, tag : this.black}); diff --git a/roojs-ui.js b/roojs-ui.js index e3736a2149..22170c6343 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -1069,8 +1069,8 @@ A.editorcore.onEditorEvent();}},xns:C.Toolbar}];},toObject:function(){var d=docu ,align:this.align,cn:[A]};if(this.caption_display=='block'){B['cn'].push({tag:'figcaption',style:{textAlign:'left',fontSize:'16px',lineHeight:'24px',display:this.caption_display,maxWidth:(this.align=='center'?this.width:'100%')+' !important',margin:m,width:this.align=='center'?this.width:'100%'} ,cls:this.cls.length>0?(this.cls+'-thumbnail'):'',cn:[{tag:'div',style:{marginTop:'16px',textAlign:'left'},align:'left',cn:[{tag:'i',contenteditable:Roo.htmleditor.BlockFigure.caption_edit,html:this.caption.length?this.caption:"Caption"}]}]});}return B;},readElement:function(A){this.video_url=this.getVal(A,'div','src'); this.cls=this.getVal(A,'div','class');this.href=this.getVal(A,'a','href');this.image_src=this.getVal(A,'img','src');this.align=this.getVal(A,'figure','align');this.caption_display=this.getVal(A,true,'data-caption-display');if(this.caption_display==''){this.caption_display=this.getVal(A,'figcaption','data-display'); -}var B=this.getVal(A,'figcaption',false);if(B!==''){this.caption=this.getVal(B,'i','html');}var dc=this.getVal(A,true,'data-caption');if(this.caption_display=='none'&&this.caption==''&&dc&&dc.length){this.caption=dc;}this.width=this.getVal(A,true,'data-width'); -},removeNode:function(){return this.node;}});Roo.apply(Roo.htmleditor.BlockFigure,{caption_edit:true}); +}var B=this.getVal(A,'figcaption',false);if(B!==''){this.caption=this.getVal(B,'i','html');}var dc=this.getVal(A,true,'data-caption');if(this.caption_display=='none'&&dc&&dc.length){this.caption=dc;}this.width=this.getVal(A,true,'data-width');},removeNode:function(){return this.node; +}});Roo.apply(Roo.htmleditor.BlockFigure,{caption_edit:true}); // Roo/htmleditor/BlockTable.js Roo.htmleditor.BlockTable=function(A){if(A.node){this.readElement(A.node);this.updateElement(A.node);}Roo.apply(this,A);if(!A.node){this.rows=[];for(var r=0;r5){if(Roo.isSafari){A=A.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi,'');}}if(A==' '){A='';} return A;},syncValue:function(){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-caption-display','data-width','data-caption','start','style','class','allowfullscreen','frameborder','width','height','alt'],attrib_clean:['href','src']} +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-caption-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='
'+D+'
';}}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; @@ -1152,7 +1152,7 @@ var r=new FileReader();var t=this;r.addEventListener('load',function(){var d=(ne }var B=[];var C=cd.getData('text/html');if(cd.types.indexOf('text/rtf')>-1){var D=new Roo.rtf.Parser(cd.getData('text/rtf'));B=D.doc?D.doc.getElementsByType('pict'):[];}B=B.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';});C=this.cleanWordChars(C);var d=(new DOMParser().parseFromString(C,'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(B.length>0){var ar=Array.from(d.getElementsByTagName('v:imagedata'));Roo.each(ar,function(E){E.parentNode.insertBefore(d.ownerDocument.createElement('img'),E);E.parentNode.removeChild(E);});Roo.each(d.getElementsByTagName('img'),function(E,i){E.setAttribute('src',B[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']} +});}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-caption-display','data-width','data-caption','start','style','class','allowfullscreen','frameborder','width','height','alt'],attrib_clean:['href','src']} );new Roo.htmleditor.FilterBlack({node:d,tag:this.black});new Roo.htmleditor.FilterKeepChildren({node:d,tag:['FONT',':']});new Roo.htmleditor.FilterParagraph({node:d});new Roo.htmleditor.FilterSpan({node:d});new Roo.htmleditor.FilterLongBr({node:d});new Roo.htmleditor.FilterComment({node:d} );}if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(E){if(E.closest('figure')){return;}var F=new Roo.htmleditor.BlockFigure({image_src:E.src});F.updateElement(E);});}this.insertAtCursor(d.innerHTML.replace(/ /g,' '));if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body); }e.preventDefault();this.owner.fireEvent('paste',this);return false;},onDestroy:function(){if(this.rendered){}},onFirstFocus:function(){this.assignDocWin();this.undoManager=new Roo.lib.UndoManager(100,(this.doc.body||this.doc.documentElement));this.activated=true; -- 2.39.2