From d97e0976f1719f86bbaee600d9591d911cdaac9f Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 7 Jul 2022 14:02:09 +0800 Subject: [PATCH] fix table align --- docs/src/Roo_htmleditor_BlockTd.js.html | 3 +++ roojs-bootstrap-debug.js | 3 +++ roojs-bootstrap.js | 10 +++++----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/src/Roo_htmleditor_BlockTd.js.html b/docs/src/Roo_htmleditor_BlockTd.js.html index 5b345c291e..55d0376a3b 100644 --- a/docs/src/Roo_htmleditor_BlockTd.js.html +++ b/docs/src/Roo_htmleditor_BlockTd.js.html @@ -379,6 +379,9 @@ this.colspan = Math.max(1,1*node.getAttribute('colspan')); this.rowspan = Math.max(1,1*node.getAttribute('rowspan')); this.html = node.innerHTML; + if (node.style.textAlign != '') { + this.textAlign = node.style.textAlign; + } }, diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index fd4388088b..5d2c70fb30 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -28526,6 +28526,9 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, { this.colspan = Math.max(1,1*node.getAttribute('colspan')); this.rowspan = Math.max(1,1*node.getAttribute('rowspan')); this.html = node.innerHTML; + if (node.style.textAlign != '') { + this.textAlign = node.style.textAlign; + } }, diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 840bb7a5f3..dd79e07980 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -1231,11 +1231,11 @@ B().deleteColumn();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEven ,{xtype:'Separator',xns:rooui.menu},{xtype:'Item',html:'Table',listeners:{click:function(G,e){var t=C();var nn=t.node.nextSibling||t.node.previousSibling;t.node.parentNode.removeChild(t.node);if(nn){A.editorcore.selectNode(nn,true);}A.editorcore.onEditorEvent(); }},xns:rooui.menu}]}}];},toObject:function(){var A={tag:'td',contenteditable:'true','data-block':'Td',valign:this.valign,style:{'text-align':this.textAlign,border:'solid 1px rgb(0, 0, 0)','border-collapse':'collapse',padding:'6px','vertical-align':this.valign} ,html:this.html};if(this.width!=''){A.width=this.width;A.style.width=this.width;}if(this.colspan>1){A.colspan=this.colspan;}if(this.rowspan>1){A.rowspan=this.rowspan;}return A;},readElement:function(A){A=A?A:this.node;this.width=A.style.width;this.colspan=Math.max(1,1*A.getAttribute('colspan')); -this.rowspan=Math.max(1,1*A.getAttribute('rowspan'));this.html=A.innerHTML;},emptyCell:function(){return {colspan:1,rowspan:1,textAlign:'left',html:" "};},removeNode:function(){return this.node.closest('table');},cellData:false,colWidths:false,toTableArray:function(){var A=[]; -var B=this.node.closest('tr').closest('table');Array.from(B.rows).forEach(function(r,ri){A[ri]=[];});var rn=0;this.colWidths=[];var C=true;Array.from(B.rows).forEach(function(r,ri){var cn=0;Array.from(r.cells).forEach(function(ce,ci){var c={cell:ce,row:rn,col:cn,colspan:ce.colSpan,rowspan:ce.rowSpan} -;if(ce.isEqualNode(this.node)){this.cellData=c;}if(typeof(A[rn][cn])!='undefined'){while(typeof(A[rn][cn])!='undefined'){cn++;}c.col=cn;}if(typeof(this.colWidths[cn])=='undefined'&&c.colspan<2){this.colWidths[cn]=ce.style.width;if(this.colWidths[cn]!=''){C=false; -}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;cn++;return;}for(var j=0;j=tr.childNodes.length-1){return;}var A=this.toTableArray();if(typeof(A[this.cellData.row][this.cellData.col+this.cellData.colspan])=='undefined'){return; +this.rowspan=Math.max(1,1*A.getAttribute('rowspan'));this.html=A.innerHTML;if(A.style.textAlign!=''){this.textAlign=A.style.textAlign;}},emptyCell:function(){return {colspan:1,rowspan:1,textAlign:'left',html:" "};},removeNode:function(){return this.node.closest('table'); +},cellData:false,colWidths:false,toTableArray:function(){var A=[];var B=this.node.closest('tr').closest('table');Array.from(B.rows).forEach(function(r,ri){A[ri]=[];});var rn=0;this.colWidths=[];var C=true;Array.from(B.rows).forEach(function(r,ri){var cn=0; +Array.from(r.cells).forEach(function(ce,ci){var c={cell:ce,row:rn,col:cn,colspan:ce.colSpan,rowspan:ce.rowSpan};if(ce.isEqualNode(this.node)){this.cellData=c;}if(typeof(A[rn][cn])!='undefined'){while(typeof(A[rn][cn])!='undefined'){cn++;}c.col=cn;}if(typeof(this.colWidths[cn])=='undefined'&&c.colspan<2){this.colWidths[cn]=ce.style.width; +if(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;cn++;return;}for(var j=0;j=tr.childNodes.length-1){return;}var A=this.toTableArray();if(typeof(A[this.cellData.row][this.cellData.col+this.cellData.colspan])=='undefined'){return; }var rc=A[this.cellData.row][this.cellData.col+this.cellData.colspan];if(rc.rowspan!=this.cellData.rowspan||rc.row!=this.cellData.row){return;}this.node.innerHTML+=' '+rc.cell.innerHTML;tr.removeChild(rc.cell);this.colspan+=rc.colspan;this.node.setAttribute('colspan',this.colspan); var A=this.toTableArray();this.normalizeWidths(A);this.updateWidths(A);},mergeBelow:function(){var A=this.toTableArray();if(typeof(A[this.cellData.row+this.cellData.rowspan])=='undefined'){return;}if(typeof(A[this.cellData.row+this.cellData.rowspan][this.cellData.col])=='undefined'){return; }var rc=A[this.cellData.row+this.cellData.rowspan][this.cellData.col];if(rc.colspan!=this.cellData.colspan||rc.col!=this.cellData.col){return;}this.node.innerHTML=this.node.innerHTML+rc.cell.innerHTML;rc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan; -- 2.39.2