From 3cc0f894f4950c221efdc268aed5afa04b6971b2 Mon Sep 17 00:00:00 2001 From: Alan Date: Tue, 1 Mar 2022 12:08:21 +0800 Subject: [PATCH] fix caption display and pasting --- Roo/htmleditor/BlockFigure.js | 6 ++++-- roojs-all.js | 4 ++-- roojs-debug.js | 6 ++++-- roojs-ui-debug.js | 6 ++++-- roojs-ui.js | 4 ++-- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Roo/htmleditor/BlockFigure.js b/Roo/htmleditor/BlockFigure.js index 2306237643..9f2dc276fb 100644 --- a/Roo/htmleditor/BlockFigure.js +++ b/Roo/htmleditor/BlockFigure.js @@ -326,7 +326,8 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { maxWidth : this.align == 'center' ? '100% !important' : (this.width + ' !important'), width : this.align == 'center' ? '100%' : this.width, margin: '0px', - padding: '10px' + padding: '10px', + textAlign : this.align // seems to work for email.. }, @@ -354,7 +355,8 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { { tag: 'div', style : { - 'margin-top' : '16px' + marginTop : '16px', + textAlign : 'left' }, align: 'left', cn : [ diff --git a/roojs-all.js b/roojs-all.js index c3ea108766..36ee8cff0e 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -1994,8 +1994,8 @@ var b=B();b.align=r.get('val');b.updateElement();D();A.editorcore.onEditorEvent( },listeners:{toggle:function(F,G){var b=B();b.caption_display=b.caption_display=='block'?'none':'block';this.setText(b.caption_display=='block'?"Hide Caption":"Show Caption");b.updateElement();D();A.editorcore.selectNode(A.tb.selectedNode);A.editorcore.onEditorEvent(); }},xns:C.Toolbar}];},toObject:function(){var d=document.createElement('div');d.innerHTML=this.caption;var m=this.width=='50%'&&this.align=='center'?'0 auto':0;var iw=this.align=='center'?this.width:'100%';var A={tag:'img',contenteditable:'false',src:this.image_src,alt:d.innerText.replace(/\n/g," ").replace(/\s+/g,' ').trim(),style:{width:iw,maxWidth:iw+' !important',margin:m} };if(this.href.length>0){A={tag:'a',href:this.href,contenteditable:'true',cn:[A]};}if(this.video_url.length>0){A={tag:'div',cls:this.cls,frameborder:0,allowfullscreen:true,width:420,height:315,src:this.video_url,cn:[A]};}var B=this.caption_display=='none'?'':(this.caption.length?this.caption:"Caption"); -return {tag:'figure','data-block':'Figure',contenteditable:'false',style:{display:'block',float:this.align,maxWidth:this.align=='center'?'100% !important':(this.width+' !important'),width:this.align=='center'?'100%':this.width,margin:'0px',padding:'10px'} -,align:this.align,cn:[A,{tag:'figcaption','data-display':this.caption_display,style:{textAlign:'left',fontSize:'16px',lineHeight:'24px',display:this.caption_display,maxWidth:this.width+' !important',margin:m,width:this.width},cls:this.cls.length>0?(this.cls+'-thumbnail'):'',cn:[{tag:'div',style:{'margin-top':'16px'} +return {tag:'figure','data-block':'Figure',contenteditable:'false',style:{display:'block',float:this.align,maxWidth:this.align=='center'?'100% !important':(this.width+' !important'),width:this.align=='center'?'100%':this.width,margin:'0px',padding:'10px',textAlign:this.align} +,align:this.align,cn:[A,{tag:'figcaption','data-display':this.caption_display,style:{textAlign:'left',fontSize:'16px',lineHeight:'24px',display:this.caption_display,maxWidth:this.width+' !important',margin:m,width:this.width},cls:this.cls.length>0?(this.cls+'-thumbnail'):'',cn:[{tag:'div',style:{marginTop:'16px',textAlign:'left'} ,align:'left',cn:[{tag:'i',contenteditable:true,html: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'); var B=this.getVal(A,'figcaption',false);this.caption=this.getVal(B,'i','html');this.caption_display=this.getVal(A,'figcaption','data-display');this.width=this.getVal(A,'figcaption','style','width');},removeNode:function(){return this.node;}}) // Roo/htmleditor/BlockTable.js diff --git a/roojs-debug.js b/roojs-debug.js index 5180972350..e4c6e1a7fb 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -48136,7 +48136,8 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { maxWidth : this.align == 'center' ? '100% !important' : (this.width + ' !important'), width : this.align == 'center' ? '100%' : this.width, margin: '0px', - padding: '10px' + padding: '10px', + textAlign : this.align // seems to work for email.. }, @@ -48164,7 +48165,8 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { { tag: 'div', style : { - 'margin-top' : '16px' + marginTop : '16px', + textAlign : 'left' }, align: 'left', cn : [ diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index 71a05c64dd..687480b0c6 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -23667,7 +23667,8 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { maxWidth : this.align == 'center' ? '100% !important' : (this.width + ' !important'), width : this.align == 'center' ? '100%' : this.width, margin: '0px', - padding: '10px' + padding: '10px', + textAlign : this.align // seems to work for email.. }, @@ -23695,7 +23696,8 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { { tag: 'div', style : { - 'margin-top' : '16px' + marginTop : '16px', + textAlign : 'left' }, align: 'left', cn : [ diff --git a/roojs-ui.js b/roojs-ui.js index 67db75b245..1678916541 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -1049,8 +1049,8 @@ var b=B();b.align=r.get('val');b.updateElement();D();A.editorcore.onEditorEvent( },listeners:{toggle:function(F,G){var b=B();b.caption_display=b.caption_display=='block'?'none':'block';this.setText(b.caption_display=='block'?"Hide Caption":"Show Caption");b.updateElement();D();A.editorcore.selectNode(A.tb.selectedNode);A.editorcore.onEditorEvent(); }},xns:C.Toolbar}];},toObject:function(){var d=document.createElement('div');d.innerHTML=this.caption;var m=this.width=='50%'&&this.align=='center'?'0 auto':0;var iw=this.align=='center'?this.width:'100%';var A={tag:'img',contenteditable:'false',src:this.image_src,alt:d.innerText.replace(/\n/g," ").replace(/\s+/g,' ').trim(),style:{width:iw,maxWidth:iw+' !important',margin:m} };if(this.href.length>0){A={tag:'a',href:this.href,contenteditable:'true',cn:[A]};}if(this.video_url.length>0){A={tag:'div',cls:this.cls,frameborder:0,allowfullscreen:true,width:420,height:315,src:this.video_url,cn:[A]};}var B=this.caption_display=='none'?'':(this.caption.length?this.caption:"Caption"); -return {tag:'figure','data-block':'Figure',contenteditable:'false',style:{display:'block',float:this.align,maxWidth:this.align=='center'?'100% !important':(this.width+' !important'),width:this.align=='center'?'100%':this.width,margin:'0px',padding:'10px'} -,align:this.align,cn:[A,{tag:'figcaption','data-display':this.caption_display,style:{textAlign:'left',fontSize:'16px',lineHeight:'24px',display:this.caption_display,maxWidth:this.width+' !important',margin:m,width:this.width},cls:this.cls.length>0?(this.cls+'-thumbnail'):'',cn:[{tag:'div',style:{'margin-top':'16px'} +return {tag:'figure','data-block':'Figure',contenteditable:'false',style:{display:'block',float:this.align,maxWidth:this.align=='center'?'100% !important':(this.width+' !important'),width:this.align=='center'?'100%':this.width,margin:'0px',padding:'10px',textAlign:this.align} +,align:this.align,cn:[A,{tag:'figcaption','data-display':this.caption_display,style:{textAlign:'left',fontSize:'16px',lineHeight:'24px',display:this.caption_display,maxWidth:this.width+' !important',margin:m,width:this.width},cls:this.cls.length>0?(this.cls+'-thumbnail'):'',cn:[{tag:'div',style:{marginTop:'16px',textAlign:'left'} ,align:'left',cn:[{tag:'i',contenteditable:true,html: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'); var B=this.getVal(A,'figcaption',false);this.caption=this.getVal(B,'i','html');this.caption_display=this.getVal(A,'figcaption','data-display');this.width=this.getVal(A,'figcaption','style','width');},removeNode:function(){return this.node;}}) // Roo/htmleditor/BlockTable.js -- 2.39.2