From 640731308cafbadde457d2589528ec53b90ad306 Mon Sep 17 00:00:00 2001 From: Alan Date: Wed, 1 Mar 2023 11:34:31 +0800 Subject: [PATCH] fix caption on hidden figures --- docs/src/Roo_htmleditor_BlockFigure.js.html | 7 +++++++ roojs-bootstrap-debug.js | 9 ++++++++- roojs-bootstrap.js | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/src/Roo_htmleditor_BlockFigure.js.html b/docs/src/Roo_htmleditor_BlockFigure.js.html index 3167c5ee36..7c012dfdf9 100644 --- a/docs/src/Roo_htmleditor_BlockFigure.js.html +++ b/docs/src/Roo_htmleditor_BlockFigure.js.html @@ -323,6 +323,7 @@ tag: 'figure', 'data-block' : 'Figure', 'data-width' : this.width, + 'data-caption' : this.caption, contenteditable : 'false', style : { @@ -395,6 +396,8 @@ this.image_src = this.getVal(node, 'img', 'src'); this.align = this.getVal(node, 'figure', 'align'); + + /// not really used - as hidden captions do not store the content here.. var figcaption = this.getVal(node, 'figcaption', false); if (figcaption !== '') { this.caption = this.getVal(figcaption, 'i', 'html'); @@ -402,6 +405,10 @@ this.caption_display = this.getVal(node, 'figcaption', 'data-display'); + var dc = this.getVal(node, 'figcaption', 'data-caption'); + if (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-bootstrap-debug.js b/roojs-bootstrap-debug.js index c18737852d..3f835e47c4 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -29425,7 +29425,8 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { var ret = { tag: 'figure', 'data-block' : 'Figure', - 'data-width' : this.width, + 'data-width' : this.width, + 'data-caption' : this.caption, contenteditable : 'false', style : { @@ -29498,6 +29499,8 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { this.image_src = this.getVal(node, 'img', 'src'); this.align = this.getVal(node, 'figure', 'align'); + + /// not really used - as hidden captions do not store the content here.. var figcaption = this.getVal(node, 'figcaption', false); if (figcaption !== '') { this.caption = this.getVal(figcaption, 'i', 'html'); @@ -29505,6 +29508,10 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { this.caption_display = this.getVal(node, 'figcaption', 'data-display'); + var dc = this.getVal(node, 'figcaption', 'data-caption'); + if (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-bootstrap.js b/roojs-bootstrap.js index 04503c5e8e..761739cb07 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -1270,11 +1270,11 @@ var b=B();b.align=r.get('val');b.updateElement();D();A.editorcore.onEditorEvent( this.setPressed(v!='block');},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!='100%'&&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"); -var C={tag:'figure','data-block':'Figure','data-width':this.width,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:this.align=='center'?'0':'0 10px',textAlign:this.align} +var C={tag:'figure','data-block':'Figure','data-width':this.width,'data-caption':this.caption,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:this.align=='center'?'0':'0 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.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:true,html:B}]}]}]};return C;},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);if(B!==''){this.caption=this.getVal(B,'i','html');}this.caption_display=this.getVal(A,'figcaption','data-display'); -this.width=this.getVal(A,true,'data-width');},removeNode:function(){return this.node;}}) +var dc=this.getVal(A,'figcaption','data-caption');if(dc&&dc.length){this.caption=dc;}this.width=this.getVal(A,true,'data-width');},removeNode:function(){return this.node;}}) // 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;r