1 \e[1mdiff --git a/Roo/htmleditor/BlockTd.js b/Roo/htmleditor/BlockTd.js
\e[m
2 \e[1mindex b6022caa76..74706b723c 100644
\e[m
3 \e[1m--- a/Roo/htmleditor/BlockTd.js
\e[m
4 \e[1m+++ b/Roo/htmleditor/BlockTd.js
\e[m
5 \e[36m@@ -339,7 +339,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
7 toObject : function()
\e[m
12 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
13 \e[36m@@ -481,6 +480,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
15 mergeRight: function()
\e[m
17 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
19 // get the contents of the next cell along..
\e[m
20 var tr = this.node.closest('tr');
\e[m
21 \e[36m@@ -506,6 +506,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
22 this.colspan += rc.colspan;
\e[m
23 this.node.setAttribute('colspan', this.colspan);
\e[m
25 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
26 \e[32m+
\e[m
\e[32m this.normalizeWidths(table);
\e[m
27 \e[32m+
\e[m
\e[32m this.updateWidths(table);
\e[m
31 \e[36m@@ -598,6 +601,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
33 updateWidths : function(table)
\e[m
35 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd updateWidths");
\e[m
36 \e[32m+
\e[m
\e[32m console.log("TABLE");
\e[m
37 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
38 \e[32m+
\e[m
\e[32m console.log("COLWIDTH");
\e[m
39 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
40 for(var r = 0 ; r < table.length; r++) {
\e[m
42 for(var c = 0 ; c < table[r].length; c++) {
\e[m
43 \e[36m@@ -606,10 +614,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
46 if (this.colWidths[0] != false && table[r][c].colspan < 2) {
\e[m
47 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
48 \e[32m+
\e[m
\e[32m console.log(table[r][c].cell);
\e[m
49 var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
50 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
51 el.updateElement(el.node);
\e[m
53 \e[32m+
\e[m
\e[32m else {
\e[m
54 \e[32m+
\e[m
\e[32m console.log("CELL COLSPAN");
\e[m
55 \e[32m+
\e[m
\e[32m console.log(table[r][c]);
\e[m
56 \e[32m+
\e[m
\e[32m var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
57 \e[32m+
\e[m
\e[32m var width = 0;
\e[m
58 \e[32m+
\e[m
\e[32m for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
59 \e[32m+
\e[m
\e[32m width += Math.floor(this.colWidths[c + i]);
\e[m
60 \e[32m+
\e[m
\e[32m }
\e[m
61 \e[32m+
\e[m
\e[32m el.width = width +'%';
\e[m
62 \e[32m+
\e[m
\e[32m el.updateElement(el.node);
\e[m
63 \e[32m+
\e[m
\e[32m }
\e[m
64 table[r][c].cell = false; // done
\e[m
67 \e[1mdiff --git a/roojs-all.js b/roojs-all.js
\e[m
68 \e[1mindex 39a3e49f52..4fa4af1418 100644
\e[m
69 \e[1m--- a/roojs-all.js
\e[m
70 \e[1m+++ b/roojs-all.js
\e[m
71 \e[36m@@ -2042,16 +2042,17 @@
\e[m
\e[mB().deleteColumn();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEven
\e[m
72 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=[];
\e[m
73 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}
\e[m
74 ;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'){this.colWidths[cn]=ce.style.width;if(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;
\e[m
75 \e[31m-cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){var tr=this.node.closest('tr');
\e[m
76 \e[31m-var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
77 \e[31m-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);},mergeBelow:function(){var A=this.toTableArray();
\e[m
78 \e[31m-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;
\e[m
79 \e[31m-}this.node.innerHTML=this.node.innerHTML+rc.cell.innerHTML;rc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();
\e[m
80 \e[31m-var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();
\e[m
81 \e[31m-B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
82 \e[32m+
\e[m
\e[32mcn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){console.log("htmleditor.BlockTd mergeRight");
\e[m
83 \e[32m+
\e[m
\e[32mvar tr=this.node.closest('tr');var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
84 \e[32m+
\e[m
\e[32mif(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);
\e[m
85 \e[32m+
\e[m
\e[32mthis.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];
\e[m
86 \e[32m+
\e[m
\e[32mif(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;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;
\e[m
87 \e[32m+
\e[m
\e[32m}var A=this.toTableArray();var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');
\e[m
88 \e[32m+
\e[m
\e[32mcontinue;}var B=this.node.cloneNode();B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
89 });r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}
\e[m
90 \e[31m-}},updateWidths:function(A){for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';
\e[m
91 \e[31m-el.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
92 \e[32m+
\e[m
\e[32m}},updateWidths:function(A){console.log("htmleditor.BlockTd updateWidths");console.log("TABLE");console.log(A);console.log("COLWIDTH");console.log(this.colWidths);for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;
\e[m
93 \e[32m+
\e[m
\e[32m}if(this.colWidths[0]!=false&&A[r][c].colspan<2){console.log("CELL");console.log(A[r][c].cell);var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';el.updateElement(el.node);}else{console.log("CELL COLSPAN");console.log(A[r][c]);
\e[m
94 \e[32m+
\e[m
\e[32m}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
95 var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);var t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;
\e[m
96 },this);}},shrinkColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;
\e[m
97 return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);
\e[m
98 \e[1mdiff --git a/roojs-debug.js b/roojs-debug.js
\e[m
99 \e[1mindex 779fa0189f..df0c12750f 100644
\e[m
100 \e[1m--- a/roojs-debug.js
\e[m
101 \e[1m+++ b/roojs-debug.js
\e[m
102 \e[36m@@ -49276,7 +49276,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
104 toObject : function()
\e[m
109 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
110 \e[36m@@ -49418,6 +49417,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
112 mergeRight: function()
\e[m
114 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
116 // get the contents of the next cell along..
\e[m
117 var tr = this.node.closest('tr');
\e[m
118 \e[36m@@ -49443,6 +49443,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
119 this.colspan += rc.colspan;
\e[m
120 this.node.setAttribute('colspan', this.colspan);
\e[m
122 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
123 \e[32m+
\e[m
\e[32m this.normalizeWidths(table);
\e[m
124 \e[32m+
\e[m
\e[32m this.updateWidths(table);
\e[m
128 \e[36m@@ -49535,6 +49538,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
130 updateWidths : function(table)
\e[m
132 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd updateWidths");
\e[m
133 \e[32m+
\e[m
\e[32m console.log("TABLE");
\e[m
134 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
135 \e[32m+
\e[m
\e[32m console.log("COLWIDTH");
\e[m
136 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
137 for(var r = 0 ; r < table.length; r++) {
\e[m
139 for(var c = 0 ; c < table[r].length; c++) {
\e[m
140 \e[36m@@ -49543,10 +49551,16 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
143 if (this.colWidths[0] != false && table[r][c].colspan < 2) {
\e[m
144 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
145 \e[32m+
\e[m
\e[32m console.log(table[r][c].cell);
\e[m
146 var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
147 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
148 el.updateElement(el.node);
\e[m
150 \e[32m+
\e[m
\e[32m else {
\e[m
151 \e[32m+
\e[m
\e[32m console.log("CELL COLSPAN");
\e[m
152 \e[32m+
\e[m
\e[32m console.log(table[r][c]);
\e[m
153 \e[32m+
\e[m
\e[32m }
\e[m
154 table[r][c].cell = false; // done
\e[m
157 \e[1mdiff --git a/roojs-ui-debug.js b/roojs-ui-debug.js
\e[m
158 \e[1mindex 6623fbfdb0..f35b8e5a06 100644
\e[m
159 \e[1m--- a/roojs-ui-debug.js
\e[m
160 \e[1m+++ b/roojs-ui-debug.js
\e[m
161 \e[36m@@ -24784,7 +24784,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
163 toObject : function()
\e[m
168 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
169 \e[36m@@ -24926,6 +24925,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
171 mergeRight: function()
\e[m
173 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
175 // get the contents of the next cell along..
\e[m
176 var tr = this.node.closest('tr');
\e[m
177 \e[36m@@ -24951,6 +24951,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
178 this.colspan += rc.colspan;
\e[m
179 this.node.setAttribute('colspan', this.colspan);
\e[m
181 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
182 \e[32m+
\e[m
\e[32m this.normalizeWidths(table);
\e[m
183 \e[32m+
\e[m
\e[32m this.updateWidths(table);
\e[m
187 \e[36m@@ -25043,6 +25046,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
189 updateWidths : function(table)
\e[m
191 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd updateWidths");
\e[m
192 \e[32m+
\e[m
\e[32m console.log("TABLE");
\e[m
193 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
194 \e[32m+
\e[m
\e[32m console.log("COLWIDTH");
\e[m
195 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
196 for(var r = 0 ; r < table.length; r++) {
\e[m
198 for(var c = 0 ; c < table[r].length; c++) {
\e[m
199 \e[36m@@ -25051,10 +25059,16 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
202 if (this.colWidths[0] != false && table[r][c].colspan < 2) {
\e[m
203 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
204 \e[32m+
\e[m
\e[32m console.log(table[r][c].cell);
\e[m
205 var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
206 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
207 el.updateElement(el.node);
\e[m
209 \e[32m+
\e[m
\e[32m else {
\e[m
210 \e[32m+
\e[m
\e[32m console.log("CELL COLSPAN");
\e[m
211 \e[32m+
\e[m
\e[32m console.log(table[r][c]);
\e[m
212 \e[32m+
\e[m
\e[32m }
\e[m
213 table[r][c].cell = false; // done
\e[m
216 \e[1mdiff --git a/roojs-ui.js b/roojs-ui.js
\e[m
217 \e[1mindex 40ce72d195..313c6f61dc 100644
\e[m
218 \e[1m--- a/roojs-ui.js
\e[m
219 \e[1m+++ b/roojs-ui.js
\e[m
220 \e[36m@@ -1096,16 +1096,17 @@
\e[m
\e[mB().deleteColumn();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEven
\e[m
221 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=[];
\e[m
222 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}
\e[m
223 ;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'){this.colWidths[cn]=ce.style.width;if(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;
\e[m
224 \e[31m-cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){var tr=this.node.closest('tr');
\e[m
225 \e[31m-var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
226 \e[31m-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);},mergeBelow:function(){var A=this.toTableArray();
\e[m
227 \e[31m-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;
\e[m
228 \e[31m-}this.node.innerHTML=this.node.innerHTML+rc.cell.innerHTML;rc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();
\e[m
229 \e[31m-var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();
\e[m
230 \e[31m-B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
231 \e[32m+
\e[m
\e[32mcn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){console.log("htmleditor.BlockTd mergeRight");
\e[m
232 \e[32m+
\e[m
\e[32mvar tr=this.node.closest('tr');var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
233 \e[32m+
\e[m
\e[32mif(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);
\e[m
234 \e[32m+
\e[m
\e[32mthis.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];
\e[m
235 \e[32m+
\e[m
\e[32mif(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;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;
\e[m
236 \e[32m+
\e[m
\e[32m}var A=this.toTableArray();var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');
\e[m
237 \e[32m+
\e[m
\e[32mcontinue;}var B=this.node.cloneNode();B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
238 });r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}
\e[m
239 \e[31m-}},updateWidths:function(A){for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';
\e[m
240 \e[31m-el.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
241 \e[32m+
\e[m
\e[32m}},updateWidths:function(A){console.log("htmleditor.BlockTd updateWidths");console.log("TABLE");console.log(A);console.log("COLWIDTH");console.log(this.colWidths);for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;
\e[m
242 \e[32m+
\e[m
\e[32m}if(this.colWidths[0]!=false&&A[r][c].colspan<2){console.log("CELL");console.log(A[r][c].cell);var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';el.updateElement(el.node);}else{console.log("CELL COLSPAN");console.log(A[r][c]);
\e[m
243 \e[32m+
\e[m
\e[32m}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
244 var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);var t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;
\e[m
245 },this);}},shrinkColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;
\e[m
246 return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);
\e[m
247 \e[1mdiff --git a/Roo/htmleditor/BlockTd.js b/Roo/htmleditor/BlockTd.js
\e[m
248 \e[1mindex b6022caa76..71caa01101 100644
\e[m
249 \e[1m--- a/Roo/htmleditor/BlockTd.js
\e[m
250 \e[1m+++ b/Roo/htmleditor/BlockTd.js
\e[m
251 \e[36m@@ -339,7 +339,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
253 toObject : function()
\e[m
258 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
259 \e[36m@@ -481,6 +480,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
261 mergeRight: function()
\e[m
263 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
265 // get the contents of the next cell along..
\e[m
266 var tr = this.node.closest('tr');
\e[m
267 \e[36m@@ -506,6 +506,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
268 this.colspan += rc.colspan;
\e[m
269 this.node.setAttribute('colspan', this.colspan);
\e[m
271 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
272 \e[32m+
\e[m
\e[32m this.normalizeWidths(table);
\e[m
273 \e[32m+
\e[m
\e[32m this.updateWidths(table);
\e[m
277 \e[36m@@ -559,8 +562,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
280 this.redrawAllCells(table);
\e[m
284 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
285 \e[32m+
\e[m
\e[32m this.updateWidths(table);
\e[m
289 \e[36m@@ -598,6 +602,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
291 updateWidths : function(table)
\e[m
293 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd updateWidths");
\e[m
294 \e[32m+
\e[m
\e[32m console.log("TABLE");
\e[m
295 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
296 \e[32m+
\e[m
\e[32m console.log("COLWIDTH");
\e[m
297 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
298 for(var r = 0 ; r < table.length; r++) {
\e[m
300 for(var c = 0 ; c < table[r].length; c++) {
\e[m
301 \e[36m@@ -606,10 +615,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
304 if (this.colWidths[0] != false && table[r][c].colspan < 2) {
\e[m
305 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
306 \e[32m+
\e[m
\e[32m console.log(table[r][c].cell);
\e[m
307 var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
308 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
309 el.updateElement(el.node);
\e[m
311 \e[32m+
\e[m
\e[32m else {
\e[m
312 \e[32m+
\e[m
\e[32m console.log("CELL COLSPAN");
\e[m
313 \e[32m+
\e[m
\e[32m console.log(table[r][c]);
\e[m
314 \e[32m+
\e[m
\e[32m var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
315 \e[32m+
\e[m
\e[32m var width = 0;
\e[m
316 \e[32m+
\e[m
\e[32m for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
317 \e[32m+
\e[m
\e[32m width += Math.floor(this.colWidths[c + i]);
\e[m
318 \e[32m+
\e[m
\e[32m }
\e[m
319 \e[32m+
\e[m
\e[32m el.width = width +'%';
\e[m
320 \e[32m+
\e[m
\e[32m el.updateElement(el.node);
\e[m
321 \e[32m+
\e[m
\e[32m }
\e[m
322 table[r][c].cell = false; // done
\e[m
325 \e[1mdiff --git a/roojs-all.js b/roojs-all.js
\e[m
326 \e[1mindex 39a3e49f52..90a18263b2 100644
\e[m
327 \e[1m--- a/roojs-all.js
\e[m
328 \e[1m+++ b/roojs-all.js
\e[m
329 \e[36m@@ -2042,15 +2042,17 @@
\e[m
\e[mB().deleteColumn();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEven
\e[m
330 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=[];
\e[m
331 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}
\e[m
332 ;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'){this.colWidths[cn]=ce.style.width;if(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;
\e[m
333 \e[31m-cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){var tr=this.node.closest('tr');
\e[m
334 \e[31m-var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
335 \e[31m-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);},mergeBelow:function(){var A=this.toTableArray();
\e[m
336 \e[31m-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;
\e[m
337 \e[31m-}this.node.innerHTML=this.node.innerHTML+rc.cell.innerHTML;rc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();
\e[m
338 \e[31m-var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();
\e[m
339 \e[31m-B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
340 \e[31m-});r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}
\e[m
341 \e[31m-}},updateWidths:function(A){for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';
\e[m
342 \e[32m+
\e[m
\e[32mcn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){console.log("htmleditor.BlockTd mergeRight");
\e[m
343 \e[32m+
\e[m
\e[32mvar tr=this.node.closest('tr');var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
344 \e[32m+
\e[m
\e[32mif(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);
\e[m
345 \e[32m+
\e[m
\e[32mthis.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];
\e[m
346 \e[32m+
\e[m
\e[32mif(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;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;
\e[m
347 \e[32m+
\e[m
\e[32m}var A=this.toTableArray();var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');
\e[m
348 \e[32m+
\e[m
\e[32mcontinue;}var B=this.node.cloneNode();B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);var A=this.toTableArray();this.updateWidths(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');
\e[m
349 \e[32m+
\e[m
\e[32mvar C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);});r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');
\e[m
350 \e[32m+
\e[m
\e[32mC.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}}},updateWidths:function(A){console.log("htmleditor.BlockTd updateWidths");console.log("TABLE");console.log(A);console.log("COLWIDTH");
\e[m
351 \e[32m+
\e[m
\e[32mconsole.log(this.colWidths);for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){console.log("CELL");console.log(A[r][c].cell);var el=Roo.htmleditor.Block.factory(A[r][c].cell);
\e[m
352 \e[32m+
\e[m
\e[32mel.width=Math.floor(this.colWidths[c])+'%';el.updateElement(el.node);}else{console.log("CELL COLSPAN");console.log(A[r][c]);var el=Roo.htmleditor.Block.factory(A[r][c].cell);var B=0;for(var i=0;i<A[r][c].colspan;i++){B+=Math.floor(this.colWidths[c+i]);}el.width=B+'%';
\e[m
353 el.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
354 var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);var t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;
\e[m
355 },this);}},shrinkColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;
\e[m
356 \e[1mdiff --git a/roojs-debug.js b/roojs-debug.js
\e[m
357 \e[1mindex 779fa0189f..ace5837bba 100644
\e[m
358 \e[1m--- a/roojs-debug.js
\e[m
359 \e[1m+++ b/roojs-debug.js
\e[m
360 \e[36m@@ -49276,7 +49276,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
362 toObject : function()
\e[m
367 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
368 \e[36m@@ -49418,6 +49417,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
370 mergeRight: function()
\e[m
372 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
374 // get the contents of the next cell along..
\e[m
375 var tr = this.node.closest('tr');
\e[m
376 \e[36m@@ -49443,6 +49443,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
377 this.colspan += rc.colspan;
\e[m
378 this.node.setAttribute('colspan', this.colspan);
\e[m
380 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
381 \e[32m+
\e[m
\e[32m this.normalizeWidths(table);
\e[m
382 \e[32m+
\e[m
\e[32m this.updateWidths(table);
\e[m
386 \e[36m@@ -49496,8 +49499,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
389 this.redrawAllCells(table);
\e[m
393 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
394 \e[32m+
\e[m
\e[32m this.updateWidths(table);
\e[m
398 \e[36m@@ -49535,6 +49539,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
400 updateWidths : function(table)
\e[m
402 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd updateWidths");
\e[m
403 \e[32m+
\e[m
\e[32m console.log("TABLE");
\e[m
404 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
405 \e[32m+
\e[m
\e[32m console.log("COLWIDTH");
\e[m
406 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
407 for(var r = 0 ; r < table.length; r++) {
\e[m
409 for(var c = 0 ; c < table[r].length; c++) {
\e[m
410 \e[36m@@ -49543,10 +49552,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
413 if (this.colWidths[0] != false && table[r][c].colspan < 2) {
\e[m
414 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
415 \e[32m+
\e[m
\e[32m console.log(table[r][c].cell);
\e[m
416 var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
417 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
418 el.updateElement(el.node);
\e[m
420 \e[32m+
\e[m
\e[32m else {
\e[m
421 \e[32m+
\e[m
\e[32m console.log("CELL COLSPAN");
\e[m
422 \e[32m+
\e[m
\e[32m console.log(table[r][c]);
\e[m
423 \e[32m+
\e[m
\e[32m var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
424 \e[32m+
\e[m
\e[32m var width = 0;
\e[m
425 \e[32m+
\e[m
\e[32m for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
426 \e[32m+
\e[m
\e[32m width += Math.floor(this.colWidths[c + i]);
\e[m
427 \e[32m+
\e[m
\e[32m }
\e[m
428 \e[32m+
\e[m
\e[32m el.width = width +'%';
\e[m
429 \e[32m+
\e[m
\e[32m el.updateElement(el.node);
\e[m
430 \e[32m+
\e[m
\e[32m }
\e[m
431 table[r][c].cell = false; // done
\e[m
434 \e[1mdiff --git a/roojs-ui-debug.js b/roojs-ui-debug.js
\e[m
435 \e[1mindex 6623fbfdb0..e1139418df 100644
\e[m
436 \e[1m--- a/roojs-ui-debug.js
\e[m
437 \e[1m+++ b/roojs-ui-debug.js
\e[m
438 \e[36m@@ -24784,7 +24784,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
440 toObject : function()
\e[m
445 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
446 \e[36m@@ -24926,6 +24925,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
448 mergeRight: function()
\e[m
450 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
452 // get the contents of the next cell along..
\e[m
453 var tr = this.node.closest('tr');
\e[m
454 \e[36m@@ -24951,6 +24951,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
455 this.colspan += rc.colspan;
\e[m
456 this.node.setAttribute('colspan', this.colspan);
\e[m
458 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
459 \e[32m+
\e[m
\e[32m this.normalizeWidths(table);
\e[m
460 \e[32m+
\e[m
\e[32m this.updateWidths(table);
\e[m
464 \e[36m@@ -25004,8 +25007,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
467 this.redrawAllCells(table);
\e[m
471 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
472 \e[32m+
\e[m
\e[32m this.updateWidths(table);
\e[m
476 \e[36m@@ -25043,6 +25047,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
478 updateWidths : function(table)
\e[m
480 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd updateWidths");
\e[m
481 \e[32m+
\e[m
\e[32m console.log("TABLE");
\e[m
482 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
483 \e[32m+
\e[m
\e[32m console.log("COLWIDTH");
\e[m
484 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
485 for(var r = 0 ; r < table.length; r++) {
\e[m
487 for(var c = 0 ; c < table[r].length; c++) {
\e[m
488 \e[36m@@ -25051,10 +25060,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
491 if (this.colWidths[0] != false && table[r][c].colspan < 2) {
\e[m
492 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
493 \e[32m+
\e[m
\e[32m console.log(table[r][c].cell);
\e[m
494 var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
495 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
496 el.updateElement(el.node);
\e[m
498 \e[32m+
\e[m
\e[32m else {
\e[m
499 \e[32m+
\e[m
\e[32m console.log("CELL COLSPAN");
\e[m
500 \e[32m+
\e[m
\e[32m console.log(table[r][c]);
\e[m
501 \e[32m+
\e[m
\e[32m var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
502 \e[32m+
\e[m
\e[32m var width = 0;
\e[m
503 \e[32m+
\e[m
\e[32m for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
504 \e[32m+
\e[m
\e[32m width += Math.floor(this.colWidths[c + i]);
\e[m
505 \e[32m+
\e[m
\e[32m }
\e[m
506 \e[32m+
\e[m
\e[32m el.width = width +'%';
\e[m
507 \e[32m+
\e[m
\e[32m el.updateElement(el.node);
\e[m
508 \e[32m+
\e[m
\e[32m }
\e[m
509 table[r][c].cell = false; // done
\e[m
512 \e[1mdiff --git a/roojs-ui.js b/roojs-ui.js
\e[m
513 \e[1mindex 40ce72d195..cf42c68aaa 100644
\e[m
514 \e[1m--- a/roojs-ui.js
\e[m
515 \e[1m+++ b/roojs-ui.js
\e[m
516 \e[36m@@ -1096,15 +1096,17 @@
\e[m
\e[mB().deleteColumn();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEven
\e[m
517 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=[];
\e[m
518 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}
\e[m
519 ;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'){this.colWidths[cn]=ce.style.width;if(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;
\e[m
520 \e[31m-cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){var tr=this.node.closest('tr');
\e[m
521 \e[31m-var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
522 \e[31m-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);},mergeBelow:function(){var A=this.toTableArray();
\e[m
523 \e[31m-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;
\e[m
524 \e[31m-}this.node.innerHTML=this.node.innerHTML+rc.cell.innerHTML;rc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();
\e[m
525 \e[31m-var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();
\e[m
526 \e[31m-B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
527 \e[31m-});r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}
\e[m
528 \e[31m-}},updateWidths:function(A){for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';
\e[m
529 \e[32m+
\e[m
\e[32mcn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){console.log("htmleditor.BlockTd mergeRight");
\e[m
530 \e[32m+
\e[m
\e[32mvar tr=this.node.closest('tr');var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
531 \e[32m+
\e[m
\e[32mif(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);
\e[m
532 \e[32m+
\e[m
\e[32mthis.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];
\e[m
533 \e[32m+
\e[m
\e[32mif(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;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;
\e[m
534 \e[32m+
\e[m
\e[32m}var A=this.toTableArray();var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');
\e[m
535 \e[32m+
\e[m
\e[32mcontinue;}var B=this.node.cloneNode();B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);var A=this.toTableArray();this.updateWidths(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');
\e[m
536 \e[32m+
\e[m
\e[32mvar C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);});r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');
\e[m
537 \e[32m+
\e[m
\e[32mC.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}}},updateWidths:function(A){console.log("htmleditor.BlockTd updateWidths");console.log("TABLE");console.log(A);console.log("COLWIDTH");
\e[m
538 \e[32m+
\e[m
\e[32mconsole.log(this.colWidths);for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){console.log("CELL");console.log(A[r][c].cell);var el=Roo.htmleditor.Block.factory(A[r][c].cell);
\e[m
539 \e[32m+
\e[m
\e[32mel.width=Math.floor(this.colWidths[c])+'%';el.updateElement(el.node);}else{console.log("CELL COLSPAN");console.log(A[r][c]);var el=Roo.htmleditor.Block.factory(A[r][c].cell);var B=0;for(var i=0;i<A[r][c].colspan;i++){B+=Math.floor(this.colWidths[c+i]);}el.width=B+'%';
\e[m
540 el.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
541 var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);var t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;
\e[m
542 },this);}},shrinkColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;
\e[m
543 \e[1mdiff --git a/Roo/htmleditor/BlockTd.js b/Roo/htmleditor/BlockTd.js
\e[m
544 \e[1mindex b6022caa76..d86513f7ed 100644
\e[m
545 \e[1m--- a/Roo/htmleditor/BlockTd.js
\e[m
546 \e[1m+++ b/Roo/htmleditor/BlockTd.js
\e[m
547 \e[36m@@ -28,6 +28,8 @@
\e[m
549 Roo.htmleditor.BlockTd = function(cfg)
\e[m
551 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd constructor");
\e[m
552 \e[32m+
\e[m
\e[32m console.log(cfg.node);
\e[m
554 this.readElement(cfg.node);
\e[m
555 this.updateElement(cfg.node);
\e[m
556 \e[36m@@ -57,6 +59,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
558 contextMenu : function(toolbar)
\e[m
560 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlodTd contextMenu");
\e[m
561 \e[32m+
\e[m
\e[32m console.log(this.node);
\e[m
563 var cell = function() {
\e[m
564 return Roo.htmleditor.Block.factory(toolbar.tb.selectedNode);
\e[m
565 \e[36m@@ -339,7 +343,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
567 toObject : function()
\e[m
572 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
573 \e[36m@@ -407,18 +410,18 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
575 toTableArray : function()
\e[m
577 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd toTableArray ");
\e[m
579 var tab = this.node.closest('tr').closest('table');
\e[m
580 Array.from(tab.rows).forEach(function(r, ri){
\e[m
584 \e[31m- this.colWidths = [];
\e[m
585 \e[31m- var all_auto = true;
\e[m
586 Array.from(tab.rows).forEach(function(r, ri){
\e[m
589 Array.from(r.cells).forEach(function(ce, ci){
\e[m
594 \e[36m@@ -437,14 +440,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
598 \e[31m- if (typeof(this.colWidths[cn]) == 'undefined') {
\e[m
599 \e[31m- this.colWidths[cn] = ce.style.width;
\e[m
600 \e[31m- if (this.colWidths[cn] != '') {
\e[m
601 \e[31m- all_auto = false;
\e[m
606 if (c.colspan < 2 && c.rowspan < 2 ) {
\e[m
609 \e[36m@@ -465,15 +460,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
613 \e[31m- // initalize widths.?
\e[m
614 \e[31m- // either all widths or no widths..
\e[m
615 \e[31m- if (all_auto) {
\e[m
616 \e[31m- this.colWidths[0] = false; // no widths flag.
\e[m
625 \e[36m@@ -481,6 +468,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
627 mergeRight: function()
\e[m
629 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
631 // get the contents of the next cell along..
\e[m
632 var tr = this.node.closest('tr');
\e[m
633 \e[36m@@ -489,6 +477,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
634 return; // no cells on right to merge with.
\e[m
636 var table = this.toTableArray();
\e[m
637 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
639 if (typeof(table[this.cellData.row][this.cellData.col+this.cellData.colspan]) == 'undefined') {
\e[m
640 return; // nothing right?
\e[m
641 \e[36m@@ -506,6 +495,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
642 this.colspan += rc.colspan;
\e[m
643 this.node.setAttribute('colspan', this.colspan);
\e[m
645 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
646 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
647 \e[32m+
\e[m
\e[32m this.normalizeWidths(table);
\e[m
648 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
649 \e[32m+
\e[m
\e[32m // this.updateWidths(table);
\e[m
653 \e[36m@@ -560,8 +554,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
655 this.redrawAllCells(table);
\e[m
662 \e[36m@@ -610,13 +602,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
663 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
664 el.updateElement(el.node);
\e[m
666 \e[32m+
\e[m
\e[32m // else {
\e[m
667 \e[32m+
\e[m
\e[32m // var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
668 \e[32m+
\e[m
\e[32m // var width = 0;
\e[m
669 \e[32m+
\e[m
\e[32m // for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
670 \e[32m+
\e[m
\e[32m // width += Math.floor(this.colWidths[c + i]);
\e[m
671 \e[32m+
\e[m
\e[32m // }
\e[m
672 \e[32m+
\e[m
\e[32m // el.width = width +'%';
\e[m
673 \e[32m+
\e[m
\e[32m // el.updateElement(el.node);
\e[m
674 \e[32m+
\e[m
\e[32m // }
\e[m
675 table[r][c].cell = false; // done
\e[m
679 normalizeWidths : function(table)
\e[m
682 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd normalizeWidths");
\e[m
683 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
684 if (this.colWidths[0] === false) {
\e[m
685 var nw = 100.0 / this.colWidths.length;
\e[m
686 this.colWidths.forEach(function(w,i) {
\e[m
687 \e[36m@@ -663,7 +665,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
688 shrinkColumn : function()
\e[m
690 var table = this.toTableArray();
\e[m
691 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
692 this.normalizeWidths(table);
\e[m
693 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
694 var col = this.cellData.col;
\e[m
695 var nw = this.colWidths[col] * 0.8;
\e[m
697 \e[1mdiff --git a/roojs-all.js b/roojs-all.js
\e[m
698 \e[1mindex 39a3e49f52..e11d4edeff 100644
\e[m
699 \e[1m--- a/roojs-all.js
\e[m
700 \e[1m+++ b/roojs-all.js
\e[m
701 \e[36m@@ -2027,37 +2027,40 @@
\e[m
\e[mreturn;}for(var i=0;i<c.colspan;i++){B.push(c);}});return B;},deleteColumn:funct
\e[m
702 this.updateElement();},emptyCell:function(){return (new Roo.htmleditor.BlockTd({})).toObject();},removeNode:function(){return this.node;},resetWidths:function(){Array.from(this.node.getElementsByTagName('td')).forEach(function(n){var nn=Roo.htmleditor.Block.factory(n);
\e[m
703 nn.width='';nn.updateElement(n);});}})
\e[m
704 // Roo/htmleditor/BlockTd.js
\e[m
705 \e[31m-Roo.htmleditor.BlockTd=function(A){if(A.node){this.readElement(A.node);this.updateElement(A.node);}Roo.apply(this,A);};Roo.extend(Roo.htmleditor.BlockTd,Roo.htmleditor.Block,{node:false,width:'',textAlign:'left',valign:'top',colspan:1,rowspan:1,friendly_name:'Table Cell',deleteTitle:false,contextMenu:function(A){var B=function(){return Roo.htmleditor.Block.factory(A.tb.selectedNode);
\e[m
706 \e[31m-};var C=function(){return Roo.htmleditor.Block.factory(A.tb.selectedNode.closest('table'));};var lr=false;var D=function(){lr=A.editorcore.getSelection().getRangeAt(0);};var restoreSel=function(){if(lr){(function(){A.editorcore.focus();var cr=A.editorcore.getSelection();
\e[m
707 \e[31m-cr.removeAllRanges();cr.addRange(lr);A.editorcore.onEditorEvent();}).defer(10,this);}};var rooui=typeof(Roo.bootstrap)=='undefined'?Roo:Roo.bootstrap;var E=A.editorcore.syncValue;var F={};return [{xtype:'Button',text:'Edit Table',listeners:{click:function(){var t=A.tb.selectedNode.closest('table');
\e[m
708 \e[31m-A.editorcore.selectNode(t);A.editorcore.onEditorEvent();}}},{xtype:'TextItem',text:"Column Width: ",xns:rooui.Toolbar},{xtype:'Button',text:'-',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);B().shrinkColumn();E();A.editorcore.onEditorEvent();
\e[m
709 \e[31m-}},xns:rooui.Toolbar},{xtype:'Button',text:'+',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);B().growColumn();E();A.editorcore.onEditorEvent();}},xns:rooui.Toolbar},{xtype:'TextItem',text:"Vertical Align: ",xns:rooui.Toolbar},{xtype:'ComboBox',allowBlank:false,displayField:'val',editable:true,listWidth:100,triggerAction:'all',typeAhead:true,valueField:'val',width:100,name:'valign',listeners:{select:function(G,r,H){A.editorcore.selectNode(A.tb.selectedNode);
\e[m
710 \e[31m-var b=B();b.valign=r.get('val');b.updateElement();E();A.editorcore.onEditorEvent();}},xns:rooui.form,store:{xtype:'SimpleStore',data:[['top'],['middle'],['bottom']],fields:['val'],xns:Roo.data}},{xtype:'TextItem',text:"Merge Cells: ",xns:rooui.Toolbar},{xtype:'Button',text:'Right',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);
\e[m
711 \e[32m+
\e[m
\e[32mRoo.htmleditor.BlockTd=function(A){console.log("htmleditor.BlockTd constructor");console.log(A.node);if(A.node){this.readElement(A.node);this.updateElement(A.node);}Roo.apply(this,A);};Roo.extend(Roo.htmleditor.BlockTd,Roo.htmleditor.Block,{node:false,width:'',textAlign:'left',valign:'top',colspan:1,rowspan:1,friendly_name:'Table Cell',deleteTitle:false,contextMenu:function(A){console.log("htmleditor.BlodTd contextMenu");
\e[m
712 \e[32m+
\e[m
\e[32mconsole.log(this.node);var B=function(){return Roo.htmleditor.Block.factory(A.tb.selectedNode);};var C=function(){return Roo.htmleditor.Block.factory(A.tb.selectedNode.closest('table'));};var lr=false;var D=function(){lr=A.editorcore.getSelection().getRangeAt(0);
\e[m
713 \e[32m+
\e[m
\e[32m};var restoreSel=function(){if(lr){(function(){A.editorcore.focus();var cr=A.editorcore.getSelection();cr.removeAllRanges();cr.addRange(lr);A.editorcore.onEditorEvent();}).defer(10,this);}};var rooui=typeof(Roo.bootstrap)=='undefined'?Roo:Roo.bootstrap;var E=A.editorcore.syncValue;
\e[m
714 \e[32m+
\e[m
\e[32mvar F={};return [{xtype:'Button',text:'Edit Table',listeners:{click:function(){var t=A.tb.selectedNode.closest('table');A.editorcore.selectNode(t);A.editorcore.onEditorEvent();}}},{xtype:'TextItem',text:"Column Width: ",xns:rooui.Toolbar},{xtype:'Button',text:'-',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);
\e[m
715 \e[32m+
\e[m
\e[32mB().shrinkColumn();E();A.editorcore.onEditorEvent();}},xns:rooui.Toolbar},{xtype:'Button',text:'+',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);B().growColumn();E();A.editorcore.onEditorEvent();}},xns:rooui.Toolbar},{xtype:'TextItem',text:"Vertical Align: ",xns:rooui.Toolbar}
\e[m
716 \e[32m+
\e[m
\e[32m,{xtype:'ComboBox',allowBlank:false,displayField:'val',editable:true,listWidth:100,triggerAction:'all',typeAhead:true,valueField:'val',width:100,name:'valign',listeners:{select:function(G,r,H){A.editorcore.selectNode(A.tb.selectedNode);var b=B();b.valign=r.get('val');
\e[m
717 \e[32m+
\e[m
\e[32mb.updateElement();E();A.editorcore.onEditorEvent();}},xns:rooui.form,store:{xtype:'SimpleStore',data:[['top'],['middle'],['bottom']],fields:['val'],xns:Roo.data}},{xtype:'TextItem',text:"Merge Cells: ",xns:rooui.Toolbar},{xtype:'Button',text:'Right',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);
\e[m
718 B().mergeRight();E();A.editorcore.onEditorEvent();}},xns:rooui.Toolbar},{xtype:'Button',text:'Below',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);B().mergeBelow();E();A.editorcore.onEditorEvent();}},xns:rooui.Toolbar},{xtype:'TextItem',text:"| ",xns:rooui.Toolbar}
\e[m
719 ,{xtype:'Button',text:'Split',listeners:{click:function(G,e){B().split();E();A.editorcore.selectNode(A.tb.selectedNode);A.editorcore.onEditorEvent();}},xns:rooui.Toolbar},{xtype:'Fill',xns:rooui.Toolbar},{xtype:'Button',text:'Delete',xns:rooui.Toolbar,menu:{xtype:'Menu',xns:rooui.menu,items:[{xtype:'Item',html:'Column',listeners:{click:function(G,e){var t=C();
\e[m
720 B().deleteColumn();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEvent();}},xns:rooui.menu},{xtype:'Item',html:'Row',listeners:{click:function(G,e){var t=C();B().deleteRow();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEvent();}},xns:rooui.menu}
\e[m
721 ,{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();
\e[m
722 }},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}
\e[m
723 ,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'));
\e[m
724 \e[31m-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=[];
\e[m
725 \e[31m-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}
\e[m
726 \e[32m+
\e[m
\e[32mthis.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(){console.log("htmleditor.BlockTd toTableArray ");
\e[m
727 \e[32m+
\e[m
\e[32mvar 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}
\e[m
728 ;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'){this.colWidths[cn]=ce.style.width;if(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;
\e[m
729 \e[31m-cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){var tr=this.node.closest('tr');
\e[m
730 \e[31m-var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
731 \e[31m-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);},mergeBelow:function(){var A=this.toTableArray();
\e[m
732 \e[31m-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;
\e[m
733 \e[31m-}this.node.innerHTML=this.node.innerHTML+rc.cell.innerHTML;rc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();
\e[m
734 \e[31m-var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();
\e[m
735 \e[31m-B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
736 \e[31m-});r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}
\e[m
737 \e[31m-}},updateWidths:function(A){for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';
\e[m
738 \e[31m-el.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
739 \e[31m-var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);var t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;
\e[m
740 \e[31m-},this);}},shrinkColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;
\e[m
741 \e[31m-return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);
\e[m
742 \e[31m-this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;
\e[m
743 \e[31m-c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];
\e[m
744 \e[31m-if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;c.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
745 \e[32m+
\e[m
\e[32mcn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){console.log("htmleditor.BlockTd mergeRight");
\e[m
746 \e[32m+
\e[m
\e[32mvar tr=this.node.closest('tr');var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=tr.childNodes.length-1){return;}var A=this.toTableArray();console.log(A);if(typeof(A[this.cellData.row][this.cellData.col+this.cellData.colspan])=='undefined'){return;
\e[m
747 \e[32m+
\e[m
\e[32m}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);
\e[m
748 \e[32m+
\e[m
\e[32mvar A=this.toTableArray();console.log(A);this.normalizeWidths(A);console.log(this.colWidths);},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;
\e[m
749 \e[32m+
\e[m
\e[32m}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;
\e[m
750 \e[32m+
\e[m
\e[32mthis.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;
\e[m
751 \e[32m+
\e[m
\e[32mc<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);
\e[m
752 \e[32m+
\e[m
\e[32m},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);});r.parentNode.removeChild(r);});for(var r=0;
\e[m
753 \e[32m+
\e[m
\e[32mr<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}}},updateWidths:function(A){for(var r=0;r<A.length;
\e[m
754 \e[32m+
\e[m
\e[32mr++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';el.updateElement(el.node);}A[r][c].cell=false;
\e[m
755 \e[32m+
\e[m
\e[32m}}},normalizeWidths:function(A){console.log("htmleditor.BlockTd normalizeWidths");console.log(this.colWidths);if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];
\e[m
756 \e[32m+
\e[m
\e[32mthis.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);
\e[m
757 \e[32m+
\e[m
\e[32mvar t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;},this);}},shrinkColumn:function(){var A=this.toTableArray();console.log(A);this.normalizeWidths(A);console.log(this.colWidths);
\e[m
758 \e[32m+
\e[m
\e[32mvar B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();
\e[m
759 \e[32m+
\e[m
\e[32mthis.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);
\e[m
760 \e[32m+
\e[m
\e[32m},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);
\e[m
761 \e[32m+
\e[m
\e[32m}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;
\e[m
762 \e[32m+
\e[m
\e[32mc.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
763 // Roo/HtmlEditorCore.js
\e[m
764 Roo.HtmlEditorCore=function(A){Roo.HtmlEditorCore.superclass.constructor.call(this,A);this.addEvents({initialize:true,activate:true,beforesync:true,beforepush:true,sync:true,push:true,editorevent:true});this.applyBlacklists();};Roo.extend(Roo.HtmlEditorCore,Roo.Component,{owner:false,resizable:false,height:300,width:500,autoClean:true,enableBlocks:true,stylesheets:false,language:'en',allowComments:false,frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,sourceEditMode:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',clearUp:true,black:false,white:false,bodyCls:'',undoManager:false,getDocMarkup:function(){var st='';
\e[m
765 if(this.stylesheets===false){Roo.get(document.head).select('style').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);});Roo.get(document.head).select('link').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);
\e[m
766 \e[1mdiff --git a/roojs-debug.js b/roojs-debug.js
\e[m
767 \e[1mindex 779fa0189f..edb9ed778e 100644
\e[m
768 \e[1m--- a/roojs-debug.js
\e[m
769 \e[1m+++ b/roojs-debug.js
\e[m
770 \e[36m@@ -48965,6 +48965,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTable, Roo.htmleditor.Block, {
\e[m
772 Roo.htmleditor.BlockTd = function(cfg)
\e[m
774 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd constructor");
\e[m
775 \e[32m+
\e[m
\e[32m console.log(cfg.node);
\e[m
777 this.readElement(cfg.node);
\e[m
778 this.updateElement(cfg.node);
\e[m
779 \e[36m@@ -48994,6 +48996,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
781 contextMenu : function(toolbar)
\e[m
783 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlodTd contextMenu");
\e[m
784 \e[32m+
\e[m
\e[32m console.log(this.node);
\e[m
786 var cell = function() {
\e[m
787 return Roo.htmleditor.Block.factory(toolbar.tb.selectedNode);
\e[m
788 \e[36m@@ -49276,7 +49280,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
790 toObject : function()
\e[m
795 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
796 \e[36m@@ -49344,6 +49347,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
798 toTableArray : function()
\e[m
800 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd toTableArray ");
\e[m
802 var tab = this.node.closest('tr').closest('table');
\e[m
803 Array.from(tab.rows).forEach(function(r, ri){
\e[m
804 \e[36m@@ -49356,6 +49360,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
807 Array.from(r.cells).forEach(function(ce, ci){
\e[m
812 \e[36m@@ -49418,6 +49423,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
814 mergeRight: function()
\e[m
816 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
818 // get the contents of the next cell along..
\e[m
819 var tr = this.node.closest('tr');
\e[m
820 \e[36m@@ -49426,6 +49432,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
821 return; // no cells on right to merge with.
\e[m
823 var table = this.toTableArray();
\e[m
824 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
826 if (typeof(table[this.cellData.row][this.cellData.col+this.cellData.colspan]) == 'undefined') {
\e[m
827 return; // nothing right?
\e[m
828 \e[36m@@ -49443,6 +49450,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
829 this.colspan += rc.colspan;
\e[m
830 this.node.setAttribute('colspan', this.colspan);
\e[m
832 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
833 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
834 \e[32m+
\e[m
\e[32m this.normalizeWidths(table);
\e[m
835 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
836 \e[32m+
\e[m
\e[32m // this.updateWidths(table);
\e[m
840 \e[36m@@ -49497,8 +49509,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
842 this.redrawAllCells(table);
\e[m
849 \e[36m@@ -49547,13 +49557,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
850 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
851 el.updateElement(el.node);
\e[m
853 \e[32m+
\e[m
\e[32m // else {
\e[m
854 \e[32m+
\e[m
\e[32m // var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
855 \e[32m+
\e[m
\e[32m // var width = 0;
\e[m
856 \e[32m+
\e[m
\e[32m // for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
857 \e[32m+
\e[m
\e[32m // width += Math.floor(this.colWidths[c + i]);
\e[m
858 \e[32m+
\e[m
\e[32m // }
\e[m
859 \e[32m+
\e[m
\e[32m // el.width = width +'%';
\e[m
860 \e[32m+
\e[m
\e[32m // el.updateElement(el.node);
\e[m
861 \e[32m+
\e[m
\e[32m // }
\e[m
862 table[r][c].cell = false; // done
\e[m
866 normalizeWidths : function(table)
\e[m
869 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd normalizeWidths");
\e[m
870 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
871 if (this.colWidths[0] === false) {
\e[m
872 var nw = 100.0 / this.colWidths.length;
\e[m
873 this.colWidths.forEach(function(w,i) {
\e[m
874 \e[36m@@ -49600,7 +49620,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
875 shrinkColumn : function()
\e[m
877 var table = this.toTableArray();
\e[m
878 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
879 this.normalizeWidths(table);
\e[m
880 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
881 var col = this.cellData.col;
\e[m
882 var nw = this.colWidths[col] * 0.8;
\e[m
884 \e[1mdiff --git a/roojs-ui-debug.js b/roojs-ui-debug.js
\e[m
885 \e[1mindex 6623fbfdb0..d82815532c 100644
\e[m
886 \e[1m--- a/roojs-ui-debug.js
\e[m
887 \e[1m+++ b/roojs-ui-debug.js
\e[m
888 \e[36m@@ -24473,6 +24473,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTable, Roo.htmleditor.Block, {
\e[m
890 Roo.htmleditor.BlockTd = function(cfg)
\e[m
892 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd constructor");
\e[m
893 \e[32m+
\e[m
\e[32m console.log(cfg.node);
\e[m
895 this.readElement(cfg.node);
\e[m
896 this.updateElement(cfg.node);
\e[m
897 \e[36m@@ -24502,6 +24504,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
899 contextMenu : function(toolbar)
\e[m
901 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlodTd contextMenu");
\e[m
902 \e[32m+
\e[m
\e[32m console.log(this.node);
\e[m
904 var cell = function() {
\e[m
905 return Roo.htmleditor.Block.factory(toolbar.tb.selectedNode);
\e[m
906 \e[36m@@ -24784,7 +24788,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
908 toObject : function()
\e[m
913 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
914 \e[36m@@ -24852,6 +24855,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
916 toTableArray : function()
\e[m
918 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd toTableArray ");
\e[m
920 var tab = this.node.closest('tr').closest('table');
\e[m
921 Array.from(tab.rows).forEach(function(r, ri){
\e[m
922 \e[36m@@ -24864,6 +24868,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
925 Array.from(r.cells).forEach(function(ce, ci){
\e[m
930 \e[36m@@ -24926,6 +24931,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
932 mergeRight: function()
\e[m
934 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
936 // get the contents of the next cell along..
\e[m
937 var tr = this.node.closest('tr');
\e[m
938 \e[36m@@ -24934,6 +24940,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
939 return; // no cells on right to merge with.
\e[m
941 var table = this.toTableArray();
\e[m
942 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
944 if (typeof(table[this.cellData.row][this.cellData.col+this.cellData.colspan]) == 'undefined') {
\e[m
945 return; // nothing right?
\e[m
946 \e[36m@@ -24951,6 +24958,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
947 this.colspan += rc.colspan;
\e[m
948 this.node.setAttribute('colspan', this.colspan);
\e[m
950 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
951 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
952 \e[32m+
\e[m
\e[32m this.normalizeWidths(table);
\e[m
953 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
954 \e[32m+
\e[m
\e[32m // this.updateWidths(table);
\e[m
958 \e[36m@@ -25005,8 +25017,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
960 this.redrawAllCells(table);
\e[m
967 \e[36m@@ -25055,13 +25065,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
968 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
969 el.updateElement(el.node);
\e[m
971 \e[32m+
\e[m
\e[32m // else {
\e[m
972 \e[32m+
\e[m
\e[32m // var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
973 \e[32m+
\e[m
\e[32m // var width = 0;
\e[m
974 \e[32m+
\e[m
\e[32m // for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
975 \e[32m+
\e[m
\e[32m // width += Math.floor(this.colWidths[c + i]);
\e[m
976 \e[32m+
\e[m
\e[32m // }
\e[m
977 \e[32m+
\e[m
\e[32m // el.width = width +'%';
\e[m
978 \e[32m+
\e[m
\e[32m // el.updateElement(el.node);
\e[m
979 \e[32m+
\e[m
\e[32m // }
\e[m
980 table[r][c].cell = false; // done
\e[m
984 normalizeWidths : function(table)
\e[m
987 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd normalizeWidths");
\e[m
988 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
989 if (this.colWidths[0] === false) {
\e[m
990 var nw = 100.0 / this.colWidths.length;
\e[m
991 this.colWidths.forEach(function(w,i) {
\e[m
992 \e[36m@@ -25108,7 +25128,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
993 shrinkColumn : function()
\e[m
995 var table = this.toTableArray();
\e[m
996 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
997 this.normalizeWidths(table);
\e[m
998 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
999 var col = this.cellData.col;
\e[m
1000 var nw = this.colWidths[col] * 0.8;
\e[m
1002 \e[1mdiff --git a/roojs-ui.js b/roojs-ui.js
\e[m
1003 \e[1mindex 40ce72d195..b1aeca363c 100644
\e[m
1004 \e[1m--- a/roojs-ui.js
\e[m
1005 \e[1m+++ b/roojs-ui.js
\e[m
1006 \e[36m@@ -1081,37 +1081,40 @@
\e[m
\e[mreturn;}for(var i=0;i<c.colspan;i++){B.push(c);}});return B;},deleteColumn:funct
\e[m
1007 this.updateElement();},emptyCell:function(){return (new Roo.htmleditor.BlockTd({})).toObject();},removeNode:function(){return this.node;},resetWidths:function(){Array.from(this.node.getElementsByTagName('td')).forEach(function(n){var nn=Roo.htmleditor.Block.factory(n);
\e[m
1008 nn.width='';nn.updateElement(n);});}})
\e[m
1009 // Roo/htmleditor/BlockTd.js
\e[m
1010 \e[31m-Roo.htmleditor.BlockTd=function(A){if(A.node){this.readElement(A.node);this.updateElement(A.node);}Roo.apply(this,A);};Roo.extend(Roo.htmleditor.BlockTd,Roo.htmleditor.Block,{node:false,width:'',textAlign:'left',valign:'top',colspan:1,rowspan:1,friendly_name:'Table Cell',deleteTitle:false,contextMenu:function(A){var B=function(){return Roo.htmleditor.Block.factory(A.tb.selectedNode);
\e[m
1011 \e[31m-};var C=function(){return Roo.htmleditor.Block.factory(A.tb.selectedNode.closest('table'));};var lr=false;var D=function(){lr=A.editorcore.getSelection().getRangeAt(0);};var restoreSel=function(){if(lr){(function(){A.editorcore.focus();var cr=A.editorcore.getSelection();
\e[m
1012 \e[31m-cr.removeAllRanges();cr.addRange(lr);A.editorcore.onEditorEvent();}).defer(10,this);}};var rooui=typeof(Roo.bootstrap)=='undefined'?Roo:Roo.bootstrap;var E=A.editorcore.syncValue;var F={};return [{xtype:'Button',text:'Edit Table',listeners:{click:function(){var t=A.tb.selectedNode.closest('table');
\e[m
1013 \e[31m-A.editorcore.selectNode(t);A.editorcore.onEditorEvent();}}},{xtype:'TextItem',text:"Column Width: ",xns:rooui.Toolbar},{xtype:'Button',text:'-',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);B().shrinkColumn();E();A.editorcore.onEditorEvent();
\e[m
1014 \e[31m-}},xns:rooui.Toolbar},{xtype:'Button',text:'+',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);B().growColumn();E();A.editorcore.onEditorEvent();}},xns:rooui.Toolbar},{xtype:'TextItem',text:"Vertical Align: ",xns:rooui.Toolbar},{xtype:'ComboBox',allowBlank:false,displayField:'val',editable:true,listWidth:100,triggerAction:'all',typeAhead:true,valueField:'val',width:100,name:'valign',listeners:{select:function(G,r,H){A.editorcore.selectNode(A.tb.selectedNode);
\e[m
1015 \e[31m-var b=B();b.valign=r.get('val');b.updateElement();E();A.editorcore.onEditorEvent();}},xns:rooui.form,store:{xtype:'SimpleStore',data:[['top'],['middle'],['bottom']],fields:['val'],xns:Roo.data}},{xtype:'TextItem',text:"Merge Cells: ",xns:rooui.Toolbar},{xtype:'Button',text:'Right',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);
\e[m
1016 \e[32m+
\e[m
\e[32mRoo.htmleditor.BlockTd=function(A){console.log("htmleditor.BlockTd constructor");console.log(A.node);if(A.node){this.readElement(A.node);this.updateElement(A.node);}Roo.apply(this,A);};Roo.extend(Roo.htmleditor.BlockTd,Roo.htmleditor.Block,{node:false,width:'',textAlign:'left',valign:'top',colspan:1,rowspan:1,friendly_name:'Table Cell',deleteTitle:false,contextMenu:function(A){console.log("htmleditor.BlodTd contextMenu");
\e[m
1017 \e[32m+
\e[m
\e[32mconsole.log(this.node);var B=function(){return Roo.htmleditor.Block.factory(A.tb.selectedNode);};var C=function(){return Roo.htmleditor.Block.factory(A.tb.selectedNode.closest('table'));};var lr=false;var D=function(){lr=A.editorcore.getSelection().getRangeAt(0);
\e[m
1018 \e[32m+
\e[m
\e[32m};var restoreSel=function(){if(lr){(function(){A.editorcore.focus();var cr=A.editorcore.getSelection();cr.removeAllRanges();cr.addRange(lr);A.editorcore.onEditorEvent();}).defer(10,this);}};var rooui=typeof(Roo.bootstrap)=='undefined'?Roo:Roo.bootstrap;var E=A.editorcore.syncValue;
\e[m
1019 \e[32m+
\e[m
\e[32mvar F={};return [{xtype:'Button',text:'Edit Table',listeners:{click:function(){var t=A.tb.selectedNode.closest('table');A.editorcore.selectNode(t);A.editorcore.onEditorEvent();}}},{xtype:'TextItem',text:"Column Width: ",xns:rooui.Toolbar},{xtype:'Button',text:'-',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);
\e[m
1020 \e[32m+
\e[m
\e[32mB().shrinkColumn();E();A.editorcore.onEditorEvent();}},xns:rooui.Toolbar},{xtype:'Button',text:'+',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);B().growColumn();E();A.editorcore.onEditorEvent();}},xns:rooui.Toolbar},{xtype:'TextItem',text:"Vertical Align: ",xns:rooui.Toolbar}
\e[m
1021 \e[32m+
\e[m
\e[32m,{xtype:'ComboBox',allowBlank:false,displayField:'val',editable:true,listWidth:100,triggerAction:'all',typeAhead:true,valueField:'val',width:100,name:'valign',listeners:{select:function(G,r,H){A.editorcore.selectNode(A.tb.selectedNode);var b=B();b.valign=r.get('val');
\e[m
1022 \e[32m+
\e[m
\e[32mb.updateElement();E();A.editorcore.onEditorEvent();}},xns:rooui.form,store:{xtype:'SimpleStore',data:[['top'],['middle'],['bottom']],fields:['val'],xns:Roo.data}},{xtype:'TextItem',text:"Merge Cells: ",xns:rooui.Toolbar},{xtype:'Button',text:'Right',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);
\e[m
1023 B().mergeRight();E();A.editorcore.onEditorEvent();}},xns:rooui.Toolbar},{xtype:'Button',text:'Below',listeners:{click:function(G,e){A.editorcore.selectNode(A.tb.selectedNode);B().mergeBelow();E();A.editorcore.onEditorEvent();}},xns:rooui.Toolbar},{xtype:'TextItem',text:"| ",xns:rooui.Toolbar}
\e[m
1024 ,{xtype:'Button',text:'Split',listeners:{click:function(G,e){B().split();E();A.editorcore.selectNode(A.tb.selectedNode);A.editorcore.onEditorEvent();}},xns:rooui.Toolbar},{xtype:'Fill',xns:rooui.Toolbar},{xtype:'Button',text:'Delete',xns:rooui.Toolbar,menu:{xtype:'Menu',xns:rooui.menu,items:[{xtype:'Item',html:'Column',listeners:{click:function(G,e){var t=C();
\e[m
1025 B().deleteColumn();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEvent();}},xns:rooui.menu},{xtype:'Item',html:'Row',listeners:{click:function(G,e){var t=C();B().deleteRow();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEvent();}},xns:rooui.menu}
\e[m
1026 ,{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();
\e[m
1027 }},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}
\e[m
1028 ,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'));
\e[m
1029 \e[31m-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=[];
\e[m
1030 \e[31m-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}
\e[m
1031 \e[32m+
\e[m
\e[32mthis.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(){console.log("htmleditor.BlockTd toTableArray ");
\e[m
1032 \e[32m+
\e[m
\e[32mvar 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}
\e[m
1033 ;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'){this.colWidths[cn]=ce.style.width;if(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;
\e[m
1034 \e[31m-cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){var tr=this.node.closest('tr');
\e[m
1035 \e[31m-var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
1036 \e[31m-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);},mergeBelow:function(){var A=this.toTableArray();
\e[m
1037 \e[31m-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;
\e[m
1038 \e[31m-}this.node.innerHTML=this.node.innerHTML+rc.cell.innerHTML;rc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();
\e[m
1039 \e[31m-var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();
\e[m
1040 \e[31m-B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
1041 \e[31m-});r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}
\e[m
1042 \e[31m-}},updateWidths:function(A){for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';
\e[m
1043 \e[31m-el.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
1044 \e[31m-var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);var t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;
\e[m
1045 \e[31m-},this);}},shrinkColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;
\e[m
1046 \e[31m-return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);
\e[m
1047 \e[31m-this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;
\e[m
1048 \e[31m-c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];
\e[m
1049 \e[31m-if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;c.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
1050 \e[32m+
\e[m
\e[32mcn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){console.log("htmleditor.BlockTd mergeRight");
\e[m
1051 \e[32m+
\e[m
\e[32mvar tr=this.node.closest('tr');var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=tr.childNodes.length-1){return;}var A=this.toTableArray();console.log(A);if(typeof(A[this.cellData.row][this.cellData.col+this.cellData.colspan])=='undefined'){return;
\e[m
1052 \e[32m+
\e[m
\e[32m}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);
\e[m
1053 \e[32m+
\e[m
\e[32mvar A=this.toTableArray();console.log(A);this.normalizeWidths(A);console.log(this.colWidths);},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;
\e[m
1054 \e[32m+
\e[m
\e[32m}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;
\e[m
1055 \e[32m+
\e[m
\e[32mthis.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;
\e[m
1056 \e[32m+
\e[m
\e[32mc<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);
\e[m
1057 \e[32m+
\e[m
\e[32m},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);});r.parentNode.removeChild(r);});for(var r=0;
\e[m
1058 \e[32m+
\e[m
\e[32mr<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}}},updateWidths:function(A){for(var r=0;r<A.length;
\e[m
1059 \e[32m+
\e[m
\e[32mr++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';el.updateElement(el.node);}A[r][c].cell=false;
\e[m
1060 \e[32m+
\e[m
\e[32m}}},normalizeWidths:function(A){console.log("htmleditor.BlockTd normalizeWidths");console.log(this.colWidths);if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];
\e[m
1061 \e[32m+
\e[m
\e[32mthis.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);
\e[m
1062 \e[32m+
\e[m
\e[32mvar t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;},this);}},shrinkColumn:function(){var A=this.toTableArray();console.log(A);this.normalizeWidths(A);console.log(this.colWidths);
\e[m
1063 \e[32m+
\e[m
\e[32mvar B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();
\e[m
1064 \e[32m+
\e[m
\e[32mthis.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);
\e[m
1065 \e[32m+
\e[m
\e[32m},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);
\e[m
1066 \e[32m+
\e[m
\e[32m}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;
\e[m
1067 \e[32m+
\e[m
\e[32mc.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
1068 // Roo/HtmlEditorCore.js
\e[m
1069 Roo.HtmlEditorCore=function(A){Roo.HtmlEditorCore.superclass.constructor.call(this,A);this.addEvents({initialize:true,activate:true,beforesync:true,beforepush:true,sync:true,push:true,editorevent:true});this.applyBlacklists();};Roo.extend(Roo.HtmlEditorCore,Roo.Component,{owner:false,resizable:false,height:300,width:500,autoClean:true,enableBlocks:true,stylesheets:false,language:'en',allowComments:false,frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,sourceEditMode:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',clearUp:true,black:false,white:false,bodyCls:'',undoManager:false,getDocMarkup:function(){var st='';
\e[m
1070 if(this.stylesheets===false){Roo.get(document.head).select('style').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);});Roo.get(document.head).select('link').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);
\e[m
1071 \e[1mdiff --git a/Roo/htmleditor/BlockTd.js b/Roo/htmleditor/BlockTd.js
\e[m
1072 \e[1mindex b6022caa76..ccfb7b1a70 100644
\e[m
1073 \e[1m--- a/Roo/htmleditor/BlockTd.js
\e[m
1074 \e[1m+++ b/Roo/htmleditor/BlockTd.js
\e[m
1075 \e[36m@@ -339,7 +339,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1077 toObject : function()
\e[m
1082 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
1083 \e[36m@@ -407,6 +406,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1085 toTableArray : function()
\e[m
1087 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd toTableArray ");
\e[m
1089 var tab = this.node.closest('tr').closest('table');
\e[m
1090 Array.from(tab.rows).forEach(function(r, ri){
\e[m
1091 \e[36m@@ -419,6 +419,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1094 Array.from(r.cells).forEach(function(ce, ci){
\e[m
1095 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
1096 \e[32m+
\e[m
\e[32m console.log(ce);
\e[m
1100 \e[36m@@ -438,6 +440,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1103 if (typeof(this.colWidths[cn]) == 'undefined') {
\e[m
1104 \e[32m+
\e[m
\e[32m console.log("CELL WIDTH");
\e[m
1105 \e[32m+
\e[m
\e[32m console.log(ce.style.width);
\e[m
1106 this.colWidths[cn] = ce.style.width;
\e[m
1107 if (this.colWidths[cn] != '') {
\e[m
1108 all_auto = false;
\e[m
1109 \e[36m@@ -481,6 +485,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1111 mergeRight: function()
\e[m
1113 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
1115 // get the contents of the next cell along..
\e[m
1116 var tr = this.node.closest('tr');
\e[m
1117 \e[36m@@ -489,6 +494,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1118 return; // no cells on right to merge with.
\e[m
1120 var table = this.toTableArray();
\e[m
1121 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
1123 if (typeof(table[this.cellData.row][this.cellData.col+this.cellData.colspan]) == 'undefined') {
\e[m
1124 return; // nothing right?
\e[m
1125 \e[36m@@ -506,6 +512,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1126 this.colspan += rc.colspan;
\e[m
1127 this.node.setAttribute('colspan', this.colspan);
\e[m
1129 \e[32m+
\e[m
\e[32m // var table = this.toTableArray();
\e[m
1130 \e[32m+
\e[m
\e[32m // console.log(table);
\e[m
1131 \e[32m+
\e[m
\e[32m // this.normalizeWidths(table);
\e[m
1132 \e[32m+
\e[m
\e[32m // console.log(this.colWidths);
\e[m
1133 \e[32m+
\e[m
\e[32m // this.updateWidths(table);
\e[m
1137 \e[36m@@ -560,8 +571,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1139 this.redrawAllCells(table);
\e[m
1146 \e[36m@@ -610,13 +619,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1147 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
1148 el.updateElement(el.node);
\e[m
1150 \e[32m+
\e[m
\e[32m // else {
\e[m
1151 \e[32m+
\e[m
\e[32m // var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
1152 \e[32m+
\e[m
\e[32m // var width = 0;
\e[m
1153 \e[32m+
\e[m
\e[32m // for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
1154 \e[32m+
\e[m
\e[32m // width += Math.floor(this.colWidths[c + i]);
\e[m
1155 \e[32m+
\e[m
\e[32m // }
\e[m
1156 \e[32m+
\e[m
\e[32m // el.width = width +'%';
\e[m
1157 \e[32m+
\e[m
\e[32m // el.updateElement(el.node);
\e[m
1158 \e[32m+
\e[m
\e[32m // }
\e[m
1159 table[r][c].cell = false; // done
\e[m
1163 normalizeWidths : function(table)
\e[m
1166 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd normalizeWidths");
\e[m
1167 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
1168 if (this.colWidths[0] === false) {
\e[m
1169 var nw = 100.0 / this.colWidths.length;
\e[m
1170 this.colWidths.forEach(function(w,i) {
\e[m
1171 \e[36m@@ -663,7 +682,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1172 shrinkColumn : function()
\e[m
1174 var table = this.toTableArray();
\e[m
1175 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
1176 this.normalizeWidths(table);
\e[m
1177 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
1178 var col = this.cellData.col;
\e[m
1179 var nw = this.colWidths[col] * 0.8;
\e[m
1181 \e[1mdiff --git a/roojs-all.js b/roojs-all.js
\e[m
1182 \e[1mindex 39a3e49f52..5639f0ffbc 100644
\e[m
1183 \e[1m--- a/roojs-all.js
\e[m
1184 \e[1m+++ b/roojs-all.js
\e[m
1185 \e[36m@@ -2039,25 +2039,27 @@
\e[m
\e[mB().deleteColumn();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEven
\e[m
1186 ,{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();
\e[m
1187 }},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}
\e[m
1188 ,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'));
\e[m
1189 \e[31m-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=[];
\e[m
1190 \e[31m-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}
\e[m
1191 \e[31m-;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'){this.colWidths[cn]=ce.style.width;if(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;
\e[m
1192 \e[31m-cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){var tr=this.node.closest('tr');
\e[m
1193 \e[31m-var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
1194 \e[31m-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);},mergeBelow:function(){var A=this.toTableArray();
\e[m
1195 \e[31m-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;
\e[m
1196 \e[31m-}this.node.innerHTML=this.node.innerHTML+rc.cell.innerHTML;rc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();
\e[m
1197 \e[31m-var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();
\e[m
1198 \e[31m-B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
1199 \e[32m+
\e[m
\e[32mthis.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(){console.log("htmleditor.BlockTd toTableArray ");
\e[m
1200 \e[32m+
\e[m
\e[32mvar 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){console.log("CELL");
\e[m
1201 \e[32m+
\e[m
\e[32mconsole.log(ce);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'){console.log("CELL WIDTH");
\e[m
1202 \e[32m+
\e[m
\e[32mconsole.log(ce.style.width);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<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;
\e[m
1203 \e[32m+
\e[m
\e[32mi++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){console.log("htmleditor.BlockTd mergeRight");var tr=this.node.closest('tr');var i=Array.prototype.indexOf.call(tr.childNodes,this.node);
\e[m
1204 \e[32m+
\e[m
\e[32mif(i>=tr.childNodes.length-1){return;}var A=this.toTableArray();console.log(A);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;
\e[m
1205 \e[32m+
\e[m
\e[32m}this.node.innerHTML+=' '+rc.cell.innerHTML;tr.removeChild(rc.cell);this.colspan+=rc.colspan;this.node.setAttribute('colspan',this.colspan);},mergeBelow:function(){var A=this.toTableArray();if(typeof(A[this.cellData.row+this.cellData.rowspan])=='undefined'){return;
\e[m
1206 \e[32m+
\e[m
\e[32m}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;
\e[m
1207 \e[32m+
\e[m
\e[32mrc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();var cd=this.cellData;this.rowspan=1;this.colspan=1;
\e[m
1208 \e[32m+
\e[m
\e[32mfor(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();B.removeAttribute('id');B.innerHTML='';
\e[m
1209 \e[32m+
\e[m
\e[32mA[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
1210 });r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}
\e[m
1211 }},updateWidths:function(A){for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';
\e[m
1212 \e[31m-el.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
1213 \e[31m-var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);var t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;
\e[m
1214 \e[31m-},this);}},shrinkColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;
\e[m
1215 \e[31m-return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);
\e[m
1216 \e[31m-this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;
\e[m
1217 \e[31m-c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];
\e[m
1218 \e[31m-if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;c.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
1219 \e[32m+
\e[m
\e[32mel.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){console.log("htmleditor.BlockTd normalizeWidths");console.log(this.colWidths);if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;
\e[m
1220 \e[32m+
\e[m
\e[32m},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);
\e[m
1221 \e[32m+
\e[m
\e[32mvar t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;},this);}},shrinkColumn:function(){var A=this.toTableArray();console.log(A);this.normalizeWidths(A);console.log(this.colWidths);
\e[m
1222 \e[32m+
\e[m
\e[32mvar B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();
\e[m
1223 \e[32m+
\e[m
\e[32mthis.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);
\e[m
1224 \e[32m+
\e[m
\e[32m},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);
\e[m
1225 \e[32m+
\e[m
\e[32m}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;
\e[m
1226 \e[32m+
\e[m
\e[32mc.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
1227 // Roo/HtmlEditorCore.js
\e[m
1228 Roo.HtmlEditorCore=function(A){Roo.HtmlEditorCore.superclass.constructor.call(this,A);this.addEvents({initialize:true,activate:true,beforesync:true,beforepush:true,sync:true,push:true,editorevent:true});this.applyBlacklists();};Roo.extend(Roo.HtmlEditorCore,Roo.Component,{owner:false,resizable:false,height:300,width:500,autoClean:true,enableBlocks:true,stylesheets:false,language:'en',allowComments:false,frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,sourceEditMode:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',clearUp:true,black:false,white:false,bodyCls:'',undoManager:false,getDocMarkup:function(){var st='';
\e[m
1229 if(this.stylesheets===false){Roo.get(document.head).select('style').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);});Roo.get(document.head).select('link').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);
\e[m
1230 \e[1mdiff --git a/roojs-debug.js b/roojs-debug.js
\e[m
1231 \e[1mindex 779fa0189f..31445da998 100644
\e[m
1232 \e[1m--- a/roojs-debug.js
\e[m
1233 \e[1m+++ b/roojs-debug.js
\e[m
1234 \e[36m@@ -49276,7 +49276,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1236 toObject : function()
\e[m
1241 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
1242 \e[36m@@ -49344,6 +49343,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1244 toTableArray : function()
\e[m
1246 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd toTableArray ");
\e[m
1248 var tab = this.node.closest('tr').closest('table');
\e[m
1249 Array.from(tab.rows).forEach(function(r, ri){
\e[m
1250 \e[36m@@ -49356,6 +49356,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1253 Array.from(r.cells).forEach(function(ce, ci){
\e[m
1254 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
1255 \e[32m+
\e[m
\e[32m console.log(ce);
\e[m
1259 \e[36m@@ -49375,6 +49377,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1262 if (typeof(this.colWidths[cn]) == 'undefined') {
\e[m
1263 \e[32m+
\e[m
\e[32m console.log("CELL WIDTH");
\e[m
1264 \e[32m+
\e[m
\e[32m console.log(ce.style.width);
\e[m
1265 this.colWidths[cn] = ce.style.width;
\e[m
1266 if (this.colWidths[cn] != '') {
\e[m
1267 all_auto = false;
\e[m
1268 \e[36m@@ -49418,6 +49422,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1270 mergeRight: function()
\e[m
1272 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
1274 // get the contents of the next cell along..
\e[m
1275 var tr = this.node.closest('tr');
\e[m
1276 \e[36m@@ -49426,6 +49431,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1277 return; // no cells on right to merge with.
\e[m
1279 var table = this.toTableArray();
\e[m
1280 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
1282 if (typeof(table[this.cellData.row][this.cellData.col+this.cellData.colspan]) == 'undefined') {
\e[m
1283 return; // nothing right?
\e[m
1284 \e[36m@@ -49443,6 +49449,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1285 this.colspan += rc.colspan;
\e[m
1286 this.node.setAttribute('colspan', this.colspan);
\e[m
1288 \e[32m+
\e[m
\e[32m // var table = this.toTableArray();
\e[m
1289 \e[32m+
\e[m
\e[32m // console.log(table);
\e[m
1290 \e[32m+
\e[m
\e[32m // this.normalizeWidths(table);
\e[m
1291 \e[32m+
\e[m
\e[32m // console.log(this.colWidths);
\e[m
1292 \e[32m+
\e[m
\e[32m // this.updateWidths(table);
\e[m
1296 \e[36m@@ -49497,8 +49508,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1298 this.redrawAllCells(table);
\e[m
1305 \e[36m@@ -49547,13 +49556,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1306 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
1307 el.updateElement(el.node);
\e[m
1309 \e[32m+
\e[m
\e[32m // else {
\e[m
1310 \e[32m+
\e[m
\e[32m // var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
1311 \e[32m+
\e[m
\e[32m // var width = 0;
\e[m
1312 \e[32m+
\e[m
\e[32m // for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
1313 \e[32m+
\e[m
\e[32m // width += Math.floor(this.colWidths[c + i]);
\e[m
1314 \e[32m+
\e[m
\e[32m // }
\e[m
1315 \e[32m+
\e[m
\e[32m // el.width = width +'%';
\e[m
1316 \e[32m+
\e[m
\e[32m // el.updateElement(el.node);
\e[m
1317 \e[32m+
\e[m
\e[32m // }
\e[m
1318 table[r][c].cell = false; // done
\e[m
1322 normalizeWidths : function(table)
\e[m
1325 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd normalizeWidths");
\e[m
1326 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
1327 if (this.colWidths[0] === false) {
\e[m
1328 var nw = 100.0 / this.colWidths.length;
\e[m
1329 this.colWidths.forEach(function(w,i) {
\e[m
1330 \e[36m@@ -49600,7 +49619,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1331 shrinkColumn : function()
\e[m
1333 var table = this.toTableArray();
\e[m
1334 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
1335 this.normalizeWidths(table);
\e[m
1336 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
1337 var col = this.cellData.col;
\e[m
1338 var nw = this.colWidths[col] * 0.8;
\e[m
1340 \e[1mdiff --git a/roojs-ui-debug.js b/roojs-ui-debug.js
\e[m
1341 \e[1mindex 6623fbfdb0..21e46e6eb0 100644
\e[m
1342 \e[1m--- a/roojs-ui-debug.js
\e[m
1343 \e[1m+++ b/roojs-ui-debug.js
\e[m
1344 \e[36m@@ -24784,7 +24784,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1346 toObject : function()
\e[m
1351 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
1352 \e[36m@@ -24852,6 +24851,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1354 toTableArray : function()
\e[m
1356 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd toTableArray ");
\e[m
1358 var tab = this.node.closest('tr').closest('table');
\e[m
1359 Array.from(tab.rows).forEach(function(r, ri){
\e[m
1360 \e[36m@@ -24864,6 +24864,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1363 Array.from(r.cells).forEach(function(ce, ci){
\e[m
1364 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
1365 \e[32m+
\e[m
\e[32m console.log(ce);
\e[m
1369 \e[36m@@ -24883,6 +24885,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1372 if (typeof(this.colWidths[cn]) == 'undefined') {
\e[m
1373 \e[32m+
\e[m
\e[32m console.log("CELL WIDTH");
\e[m
1374 \e[32m+
\e[m
\e[32m console.log(ce.style.width);
\e[m
1375 this.colWidths[cn] = ce.style.width;
\e[m
1376 if (this.colWidths[cn] != '') {
\e[m
1377 all_auto = false;
\e[m
1378 \e[36m@@ -24926,6 +24930,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1380 mergeRight: function()
\e[m
1382 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
1384 // get the contents of the next cell along..
\e[m
1385 var tr = this.node.closest('tr');
\e[m
1386 \e[36m@@ -24934,6 +24939,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1387 return; // no cells on right to merge with.
\e[m
1389 var table = this.toTableArray();
\e[m
1390 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
1392 if (typeof(table[this.cellData.row][this.cellData.col+this.cellData.colspan]) == 'undefined') {
\e[m
1393 return; // nothing right?
\e[m
1394 \e[36m@@ -24951,6 +24957,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1395 this.colspan += rc.colspan;
\e[m
1396 this.node.setAttribute('colspan', this.colspan);
\e[m
1398 \e[32m+
\e[m
\e[32m // var table = this.toTableArray();
\e[m
1399 \e[32m+
\e[m
\e[32m // console.log(table);
\e[m
1400 \e[32m+
\e[m
\e[32m // this.normalizeWidths(table);
\e[m
1401 \e[32m+
\e[m
\e[32m // console.log(this.colWidths);
\e[m
1402 \e[32m+
\e[m
\e[32m // this.updateWidths(table);
\e[m
1406 \e[36m@@ -25005,8 +25016,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1408 this.redrawAllCells(table);
\e[m
1415 \e[36m@@ -25055,13 +25064,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1416 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
1417 el.updateElement(el.node);
\e[m
1419 \e[32m+
\e[m
\e[32m // else {
\e[m
1420 \e[32m+
\e[m
\e[32m // var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
1421 \e[32m+
\e[m
\e[32m // var width = 0;
\e[m
1422 \e[32m+
\e[m
\e[32m // for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
1423 \e[32m+
\e[m
\e[32m // width += Math.floor(this.colWidths[c + i]);
\e[m
1424 \e[32m+
\e[m
\e[32m // }
\e[m
1425 \e[32m+
\e[m
\e[32m // el.width = width +'%';
\e[m
1426 \e[32m+
\e[m
\e[32m // el.updateElement(el.node);
\e[m
1427 \e[32m+
\e[m
\e[32m // }
\e[m
1428 table[r][c].cell = false; // done
\e[m
1432 normalizeWidths : function(table)
\e[m
1435 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd normalizeWidths");
\e[m
1436 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
1437 if (this.colWidths[0] === false) {
\e[m
1438 var nw = 100.0 / this.colWidths.length;
\e[m
1439 this.colWidths.forEach(function(w,i) {
\e[m
1440 \e[36m@@ -25108,7 +25127,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1441 shrinkColumn : function()
\e[m
1443 var table = this.toTableArray();
\e[m
1444 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
1445 this.normalizeWidths(table);
\e[m
1446 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
1447 var col = this.cellData.col;
\e[m
1448 var nw = this.colWidths[col] * 0.8;
\e[m
1450 \e[1mdiff --git a/roojs-ui.js b/roojs-ui.js
\e[m
1451 \e[1mindex 40ce72d195..800ac1bd02 100644
\e[m
1452 \e[1m--- a/roojs-ui.js
\e[m
1453 \e[1m+++ b/roojs-ui.js
\e[m
1454 \e[36m@@ -1093,25 +1093,27 @@
\e[m
\e[mB().deleteColumn();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEven
\e[m
1455 ,{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();
\e[m
1456 }},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}
\e[m
1457 ,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'));
\e[m
1458 \e[31m-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=[];
\e[m
1459 \e[31m-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}
\e[m
1460 \e[31m-;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'){this.colWidths[cn]=ce.style.width;if(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;
\e[m
1461 \e[31m-cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){var tr=this.node.closest('tr');
\e[m
1462 \e[31m-var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
1463 \e[31m-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);},mergeBelow:function(){var A=this.toTableArray();
\e[m
1464 \e[31m-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;
\e[m
1465 \e[31m-}this.node.innerHTML=this.node.innerHTML+rc.cell.innerHTML;rc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();
\e[m
1466 \e[31m-var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();
\e[m
1467 \e[31m-B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
1468 \e[32m+
\e[m
\e[32mthis.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(){console.log("htmleditor.BlockTd toTableArray ");
\e[m
1469 \e[32m+
\e[m
\e[32mvar 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){console.log("CELL");
\e[m
1470 \e[32m+
\e[m
\e[32mconsole.log(ce);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'){console.log("CELL WIDTH");
\e[m
1471 \e[32m+
\e[m
\e[32mconsole.log(ce.style.width);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<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;
\e[m
1472 \e[32m+
\e[m
\e[32mi++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){console.log("htmleditor.BlockTd mergeRight");var tr=this.node.closest('tr');var i=Array.prototype.indexOf.call(tr.childNodes,this.node);
\e[m
1473 \e[32m+
\e[m
\e[32mif(i>=tr.childNodes.length-1){return;}var A=this.toTableArray();console.log(A);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;
\e[m
1474 \e[32m+
\e[m
\e[32m}this.node.innerHTML+=' '+rc.cell.innerHTML;tr.removeChild(rc.cell);this.colspan+=rc.colspan;this.node.setAttribute('colspan',this.colspan);},mergeBelow:function(){var A=this.toTableArray();if(typeof(A[this.cellData.row+this.cellData.rowspan])=='undefined'){return;
\e[m
1475 \e[32m+
\e[m
\e[32m}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;
\e[m
1476 \e[32m+
\e[m
\e[32mrc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();var cd=this.cellData;this.rowspan=1;this.colspan=1;
\e[m
1477 \e[32m+
\e[m
\e[32mfor(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();B.removeAttribute('id');B.innerHTML='';
\e[m
1478 \e[32m+
\e[m
\e[32mA[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
1479 });r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}
\e[m
1480 }},updateWidths:function(A){for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';
\e[m
1481 \e[31m-el.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
1482 \e[31m-var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);var t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;
\e[m
1483 \e[31m-},this);}},shrinkColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;
\e[m
1484 \e[31m-return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);
\e[m
1485 \e[31m-this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;
\e[m
1486 \e[31m-c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];
\e[m
1487 \e[31m-if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;c.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
1488 \e[32m+
\e[m
\e[32mel.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){console.log("htmleditor.BlockTd normalizeWidths");console.log(this.colWidths);if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;
\e[m
1489 \e[32m+
\e[m
\e[32m},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);
\e[m
1490 \e[32m+
\e[m
\e[32mvar t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;},this);}},shrinkColumn:function(){var A=this.toTableArray();console.log(A);this.normalizeWidths(A);console.log(this.colWidths);
\e[m
1491 \e[32m+
\e[m
\e[32mvar B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();
\e[m
1492 \e[32m+
\e[m
\e[32mthis.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);
\e[m
1493 \e[32m+
\e[m
\e[32m},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);
\e[m
1494 \e[32m+
\e[m
\e[32m}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;
\e[m
1495 \e[32m+
\e[m
\e[32mc.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
1496 // Roo/HtmlEditorCore.js
\e[m
1497 Roo.HtmlEditorCore=function(A){Roo.HtmlEditorCore.superclass.constructor.call(this,A);this.addEvents({initialize:true,activate:true,beforesync:true,beforepush:true,sync:true,push:true,editorevent:true});this.applyBlacklists();};Roo.extend(Roo.HtmlEditorCore,Roo.Component,{owner:false,resizable:false,height:300,width:500,autoClean:true,enableBlocks:true,stylesheets:false,language:'en',allowComments:false,frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,sourceEditMode:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',clearUp:true,black:false,white:false,bodyCls:'',undoManager:false,getDocMarkup:function(){var st='';
\e[m
1498 if(this.stylesheets===false){Roo.get(document.head).select('style').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);});Roo.get(document.head).select('link').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);
\e[m
1499 \e[1mdiff --git a/Roo/htmleditor/BlockTd.js b/Roo/htmleditor/BlockTd.js
\e[m
1500 \e[1mindex b6022caa76..8be02436d9 100644
\e[m
1501 \e[1m--- a/Roo/htmleditor/BlockTd.js
\e[m
1502 \e[1m+++ b/Roo/htmleditor/BlockTd.js
\e[m
1503 \e[36m@@ -339,7 +339,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1505 toObject : function()
\e[m
1510 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
1511 \e[36m@@ -407,6 +406,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1513 toTableArray : function()
\e[m
1515 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd toTableArray ");
\e[m
1517 var tab = this.node.closest('tr').closest('table');
\e[m
1518 Array.from(tab.rows).forEach(function(r, ri){
\e[m
1519 \e[36m@@ -419,6 +419,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1522 Array.from(r.cells).forEach(function(ce, ci){
\e[m
1523 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
1524 \e[32m+
\e[m
\e[32m console.log(ce);
\e[m
1528 \e[36m@@ -437,7 +439,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1532 \e[31m- if (typeof(this.colWidths[cn]) == 'undefined') {
\e[m
1533 \e[32m+
\e[m
\e[32m if (typeof(this.colWidths[cn]) == 'undefined' && c.colspan < 2 && c.rowspan < 2) {
\e[m
1534 this.colWidths[cn] = ce.style.width;
\e[m
1535 if (this.colWidths[cn] != '') {
\e[m
1536 all_auto = false;
\e[m
1537 \e[36m@@ -481,6 +483,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1539 mergeRight: function()
\e[m
1541 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
1543 // get the contents of the next cell along..
\e[m
1544 var tr = this.node.closest('tr');
\e[m
1545 \e[36m@@ -489,6 +492,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1546 return; // no cells on right to merge with.
\e[m
1548 var table = this.toTableArray();
\e[m
1549 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
1551 if (typeof(table[this.cellData.row][this.cellData.col+this.cellData.colspan]) == 'undefined') {
\e[m
1552 return; // nothing right?
\e[m
1553 \e[36m@@ -506,6 +510,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1554 this.colspan += rc.colspan;
\e[m
1555 this.node.setAttribute('colspan', this.colspan);
\e[m
1557 \e[32m+
\e[m
\e[32m // var table = this.toTableArray();
\e[m
1558 \e[32m+
\e[m
\e[32m // console.log(table);
\e[m
1559 \e[32m+
\e[m
\e[32m // this.normalizeWidths(table);
\e[m
1560 \e[32m+
\e[m
\e[32m // console.log(this.colWidths);
\e[m
1561 \e[32m+
\e[m
\e[32m // this.updateWidths(table);
\e[m
1565 \e[36m@@ -560,8 +569,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1567 this.redrawAllCells(table);
\e[m
1574 \e[36m@@ -610,13 +617,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1575 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
1576 el.updateElement(el.node);
\e[m
1578 \e[32m+
\e[m
\e[32m // else {
\e[m
1579 \e[32m+
\e[m
\e[32m // var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
1580 \e[32m+
\e[m
\e[32m // var width = 0;
\e[m
1581 \e[32m+
\e[m
\e[32m // for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
1582 \e[32m+
\e[m
\e[32m // width += Math.floor(this.colWidths[c + i]);
\e[m
1583 \e[32m+
\e[m
\e[32m // }
\e[m
1584 \e[32m+
\e[m
\e[32m // el.width = width +'%';
\e[m
1585 \e[32m+
\e[m
\e[32m // el.updateElement(el.node);
\e[m
1586 \e[32m+
\e[m
\e[32m // }
\e[m
1587 table[r][c].cell = false; // done
\e[m
1591 normalizeWidths : function(table)
\e[m
1594 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd normalizeWidths");
\e[m
1595 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
1596 if (this.colWidths[0] === false) {
\e[m
1597 var nw = 100.0 / this.colWidths.length;
\e[m
1598 this.colWidths.forEach(function(w,i) {
\e[m
1599 \e[36m@@ -663,7 +680,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1600 shrinkColumn : function()
\e[m
1602 var table = this.toTableArray();
\e[m
1603 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
1604 this.normalizeWidths(table);
\e[m
1605 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
1606 var col = this.cellData.col;
\e[m
1607 var nw = this.colWidths[col] * 0.8;
\e[m
1609 \e[1mdiff --git a/roojs-all.js b/roojs-all.js
\e[m
1610 \e[1mindex 39a3e49f52..27fa6d7a7b 100644
\e[m
1611 \e[1m--- a/roojs-all.js
\e[m
1612 \e[1m+++ b/roojs-all.js
\e[m
1613 \e[36m@@ -2039,25 +2039,27 @@
\e[m
\e[mB().deleteColumn();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEven
\e[m
1614 ,{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();
\e[m
1615 }},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}
\e[m
1616 ,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'));
\e[m
1617 \e[31m-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=[];
\e[m
1618 \e[31m-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}
\e[m
1619 \e[31m-;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'){this.colWidths[cn]=ce.style.width;if(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;
\e[m
1620 \e[31m-cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){var tr=this.node.closest('tr');
\e[m
1621 \e[31m-var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
1622 \e[31m-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);},mergeBelow:function(){var A=this.toTableArray();
\e[m
1623 \e[31m-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;
\e[m
1624 \e[31m-}this.node.innerHTML=this.node.innerHTML+rc.cell.innerHTML;rc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();
\e[m
1625 \e[31m-var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();
\e[m
1626 \e[31m-B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
1627 \e[31m-});r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}
\e[m
1628 \e[31m-}},updateWidths:function(A){for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';
\e[m
1629 \e[31m-el.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
1630 \e[31m-var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);var t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;
\e[m
1631 \e[31m-},this);}},shrinkColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;
\e[m
1632 \e[31m-return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);
\e[m
1633 \e[31m-this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;
\e[m
1634 \e[31m-c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];
\e[m
1635 \e[31m-if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;c.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
1636 \e[32m+
\e[m
\e[32mthis.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(){console.log("htmleditor.BlockTd toTableArray ");
\e[m
1637 \e[32m+
\e[m
\e[32mvar 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){console.log("CELL");
\e[m
1638 \e[32m+
\e[m
\e[32mconsole.log(ce);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&&c.rowspan<2){this.colWidths[cn]=ce.style.width;
\e[m
1639 \e[32m+
\e[m
\e[32mif(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);
\e[m
1640 \e[32m+
\e[m
\e[32mif(C){this.colWidths[0]=false;}return A;},mergeRight:function(){console.log("htmleditor.BlockTd mergeRight");var tr=this.node.closest('tr');var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=tr.childNodes.length-1){return;}var A=this.toTableArray();
\e[m
1641 \e[32m+
\e[m
\e[32mconsole.log(A);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;
\e[m
1642 \e[32m+
\e[m
\e[32mtr.removeChild(rc.cell);this.colspan+=rc.colspan;this.node.setAttribute('colspan',this.colspan);},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;
\e[m
1643 \e[32m+
\e[m
\e[32m}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;
\e[m
1644 \e[32m+
\e[m
\e[32mthis.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;
\e[m
1645 \e[32m+
\e[m
\e[32mc<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);
\e[m
1646 \e[32m+
\e[m
\e[32m},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);});r.parentNode.removeChild(r);});for(var r=0;
\e[m
1647 \e[32m+
\e[m
\e[32mr<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}}},updateWidths:function(A){for(var r=0;r<A.length;
\e[m
1648 \e[32m+
\e[m
\e[32mr++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';el.updateElement(el.node);}A[r][c].cell=false;
\e[m
1649 \e[32m+
\e[m
\e[32m}}},normalizeWidths:function(A){console.log("htmleditor.BlockTd normalizeWidths");console.log(this.colWidths);if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];
\e[m
1650 \e[32m+
\e[m
\e[32mthis.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);
\e[m
1651 \e[32m+
\e[m
\e[32mvar t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;},this);}},shrinkColumn:function(){var A=this.toTableArray();console.log(A);this.normalizeWidths(A);console.log(this.colWidths);
\e[m
1652 \e[32m+
\e[m
\e[32mvar B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();
\e[m
1653 \e[32m+
\e[m
\e[32mthis.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);
\e[m
1654 \e[32m+
\e[m
\e[32m},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);
\e[m
1655 \e[32m+
\e[m
\e[32m}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;
\e[m
1656 \e[32m+
\e[m
\e[32mc.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
1657 // Roo/HtmlEditorCore.js
\e[m
1658 Roo.HtmlEditorCore=function(A){Roo.HtmlEditorCore.superclass.constructor.call(this,A);this.addEvents({initialize:true,activate:true,beforesync:true,beforepush:true,sync:true,push:true,editorevent:true});this.applyBlacklists();};Roo.extend(Roo.HtmlEditorCore,Roo.Component,{owner:false,resizable:false,height:300,width:500,autoClean:true,enableBlocks:true,stylesheets:false,language:'en',allowComments:false,frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,sourceEditMode:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',clearUp:true,black:false,white:false,bodyCls:'',undoManager:false,getDocMarkup:function(){var st='';
\e[m
1659 if(this.stylesheets===false){Roo.get(document.head).select('style').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);});Roo.get(document.head).select('link').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);
\e[m
1660 \e[1mdiff --git a/roojs-debug.js b/roojs-debug.js
\e[m
1661 \e[1mindex 779fa0189f..f3f1ee678e 100644
\e[m
1662 \e[1m--- a/roojs-debug.js
\e[m
1663 \e[1m+++ b/roojs-debug.js
\e[m
1664 \e[36m@@ -49276,7 +49276,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1666 toObject : function()
\e[m
1671 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
1672 \e[36m@@ -49344,6 +49343,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1674 toTableArray : function()
\e[m
1676 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd toTableArray ");
\e[m
1678 var tab = this.node.closest('tr').closest('table');
\e[m
1679 Array.from(tab.rows).forEach(function(r, ri){
\e[m
1680 \e[36m@@ -49356,6 +49356,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1683 Array.from(r.cells).forEach(function(ce, ci){
\e[m
1684 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
1685 \e[32m+
\e[m
\e[32m console.log(ce);
\e[m
1689 \e[36m@@ -49374,7 +49376,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1693 \e[31m- if (typeof(this.colWidths[cn]) == 'undefined') {
\e[m
1694 \e[32m+
\e[m
\e[32m if (typeof(this.colWidths[cn]) == 'undefined' && c.colspan < 2 && c.rowspan < 2) {
\e[m
1695 this.colWidths[cn] = ce.style.width;
\e[m
1696 if (this.colWidths[cn] != '') {
\e[m
1697 all_auto = false;
\e[m
1698 \e[36m@@ -49418,6 +49420,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1700 mergeRight: function()
\e[m
1702 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
1704 // get the contents of the next cell along..
\e[m
1705 var tr = this.node.closest('tr');
\e[m
1706 \e[36m@@ -49426,6 +49429,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1707 return; // no cells on right to merge with.
\e[m
1709 var table = this.toTableArray();
\e[m
1710 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
1712 if (typeof(table[this.cellData.row][this.cellData.col+this.cellData.colspan]) == 'undefined') {
\e[m
1713 return; // nothing right?
\e[m
1714 \e[36m@@ -49443,6 +49447,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1715 this.colspan += rc.colspan;
\e[m
1716 this.node.setAttribute('colspan', this.colspan);
\e[m
1718 \e[32m+
\e[m
\e[32m // var table = this.toTableArray();
\e[m
1719 \e[32m+
\e[m
\e[32m // console.log(table);
\e[m
1720 \e[32m+
\e[m
\e[32m // this.normalizeWidths(table);
\e[m
1721 \e[32m+
\e[m
\e[32m // console.log(this.colWidths);
\e[m
1722 \e[32m+
\e[m
\e[32m // this.updateWidths(table);
\e[m
1726 \e[36m@@ -49497,8 +49506,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1728 this.redrawAllCells(table);
\e[m
1735 \e[36m@@ -49547,13 +49554,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1736 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
1737 el.updateElement(el.node);
\e[m
1739 \e[32m+
\e[m
\e[32m // else {
\e[m
1740 \e[32m+
\e[m
\e[32m // var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
1741 \e[32m+
\e[m
\e[32m // var width = 0;
\e[m
1742 \e[32m+
\e[m
\e[32m // for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
1743 \e[32m+
\e[m
\e[32m // width += Math.floor(this.colWidths[c + i]);
\e[m
1744 \e[32m+
\e[m
\e[32m // }
\e[m
1745 \e[32m+
\e[m
\e[32m // el.width = width +'%';
\e[m
1746 \e[32m+
\e[m
\e[32m // el.updateElement(el.node);
\e[m
1747 \e[32m+
\e[m
\e[32m // }
\e[m
1748 table[r][c].cell = false; // done
\e[m
1752 normalizeWidths : function(table)
\e[m
1755 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd normalizeWidths");
\e[m
1756 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
1757 if (this.colWidths[0] === false) {
\e[m
1758 var nw = 100.0 / this.colWidths.length;
\e[m
1759 this.colWidths.forEach(function(w,i) {
\e[m
1760 \e[36m@@ -49600,7 +49617,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1761 shrinkColumn : function()
\e[m
1763 var table = this.toTableArray();
\e[m
1764 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
1765 this.normalizeWidths(table);
\e[m
1766 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
1767 var col = this.cellData.col;
\e[m
1768 var nw = this.colWidths[col] * 0.8;
\e[m
1770 \e[1mdiff --git a/roojs-ui-debug.js b/roojs-ui-debug.js
\e[m
1771 \e[1mindex 6623fbfdb0..caaefa5960 100644
\e[m
1772 \e[1m--- a/roojs-ui-debug.js
\e[m
1773 \e[1m+++ b/roojs-ui-debug.js
\e[m
1774 \e[36m@@ -24784,7 +24784,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1776 toObject : function()
\e[m
1781 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
1782 \e[36m@@ -24852,6 +24851,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1784 toTableArray : function()
\e[m
1786 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd toTableArray ");
\e[m
1788 var tab = this.node.closest('tr').closest('table');
\e[m
1789 Array.from(tab.rows).forEach(function(r, ri){
\e[m
1790 \e[36m@@ -24864,6 +24864,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1793 Array.from(r.cells).forEach(function(ce, ci){
\e[m
1794 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
1795 \e[32m+
\e[m
\e[32m console.log(ce);
\e[m
1799 \e[36m@@ -24882,7 +24884,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1803 \e[31m- if (typeof(this.colWidths[cn]) == 'undefined') {
\e[m
1804 \e[32m+
\e[m
\e[32m if (typeof(this.colWidths[cn]) == 'undefined' && c.colspan < 2 && c.rowspan < 2) {
\e[m
1805 this.colWidths[cn] = ce.style.width;
\e[m
1806 if (this.colWidths[cn] != '') {
\e[m
1807 all_auto = false;
\e[m
1808 \e[36m@@ -24926,6 +24928,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1810 mergeRight: function()
\e[m
1812 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
1814 // get the contents of the next cell along..
\e[m
1815 var tr = this.node.closest('tr');
\e[m
1816 \e[36m@@ -24934,6 +24937,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1817 return; // no cells on right to merge with.
\e[m
1819 var table = this.toTableArray();
\e[m
1820 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
1822 if (typeof(table[this.cellData.row][this.cellData.col+this.cellData.colspan]) == 'undefined') {
\e[m
1823 return; // nothing right?
\e[m
1824 \e[36m@@ -24951,6 +24955,11 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1825 this.colspan += rc.colspan;
\e[m
1826 this.node.setAttribute('colspan', this.colspan);
\e[m
1828 \e[32m+
\e[m
\e[32m // var table = this.toTableArray();
\e[m
1829 \e[32m+
\e[m
\e[32m // console.log(table);
\e[m
1830 \e[32m+
\e[m
\e[32m // this.normalizeWidths(table);
\e[m
1831 \e[32m+
\e[m
\e[32m // console.log(this.colWidths);
\e[m
1832 \e[32m+
\e[m
\e[32m // this.updateWidths(table);
\e[m
1836 \e[36m@@ -25005,8 +25014,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1838 this.redrawAllCells(table);
\e[m
1845 \e[36m@@ -25055,13 +25062,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1846 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
1847 el.updateElement(el.node);
\e[m
1849 \e[32m+
\e[m
\e[32m // else {
\e[m
1850 \e[32m+
\e[m
\e[32m // var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
1851 \e[32m+
\e[m
\e[32m // var width = 0;
\e[m
1852 \e[32m+
\e[m
\e[32m // for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
1853 \e[32m+
\e[m
\e[32m // width += Math.floor(this.colWidths[c + i]);
\e[m
1854 \e[32m+
\e[m
\e[32m // }
\e[m
1855 \e[32m+
\e[m
\e[32m // el.width = width +'%';
\e[m
1856 \e[32m+
\e[m
\e[32m // el.updateElement(el.node);
\e[m
1857 \e[32m+
\e[m
\e[32m // }
\e[m
1858 table[r][c].cell = false; // done
\e[m
1862 normalizeWidths : function(table)
\e[m
1865 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd normalizeWidths");
\e[m
1866 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
1867 if (this.colWidths[0] === false) {
\e[m
1868 var nw = 100.0 / this.colWidths.length;
\e[m
1869 this.colWidths.forEach(function(w,i) {
\e[m
1870 \e[36m@@ -25108,7 +25125,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1871 shrinkColumn : function()
\e[m
1873 var table = this.toTableArray();
\e[m
1874 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
1875 this.normalizeWidths(table);
\e[m
1876 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
1877 var col = this.cellData.col;
\e[m
1878 var nw = this.colWidths[col] * 0.8;
\e[m
1880 \e[1mdiff --git a/roojs-ui.js b/roojs-ui.js
\e[m
1881 \e[1mindex 40ce72d195..adcd2fab96 100644
\e[m
1882 \e[1m--- a/roojs-ui.js
\e[m
1883 \e[1m+++ b/roojs-ui.js
\e[m
1884 \e[36m@@ -1093,25 +1093,27 @@
\e[m
\e[mB().deleteColumn();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEven
\e[m
1885 ,{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();
\e[m
1886 }},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}
\e[m
1887 ,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'));
\e[m
1888 \e[31m-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=[];
\e[m
1889 \e[31m-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}
\e[m
1890 \e[31m-;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'){this.colWidths[cn]=ce.style.width;if(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;
\e[m
1891 \e[31m-cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){var tr=this.node.closest('tr');
\e[m
1892 \e[31m-var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
1893 \e[31m-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);},mergeBelow:function(){var A=this.toTableArray();
\e[m
1894 \e[31m-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;
\e[m
1895 \e[31m-}this.node.innerHTML=this.node.innerHTML+rc.cell.innerHTML;rc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();
\e[m
1896 \e[31m-var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();
\e[m
1897 \e[31m-B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
1898 \e[31m-});r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}
\e[m
1899 \e[31m-}},updateWidths:function(A){for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';
\e[m
1900 \e[31m-el.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
1901 \e[31m-var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);var t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;
\e[m
1902 \e[31m-},this);}},shrinkColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;
\e[m
1903 \e[31m-return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);
\e[m
1904 \e[31m-this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;
\e[m
1905 \e[31m-c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];
\e[m
1906 \e[31m-if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;c.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
1907 \e[32m+
\e[m
\e[32mthis.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(){console.log("htmleditor.BlockTd toTableArray ");
\e[m
1908 \e[32m+
\e[m
\e[32mvar 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){console.log("CELL");
\e[m
1909 \e[32m+
\e[m
\e[32mconsole.log(ce);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&&c.rowspan<2){this.colWidths[cn]=ce.style.width;
\e[m
1910 \e[32m+
\e[m
\e[32mif(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);
\e[m
1911 \e[32m+
\e[m
\e[32mif(C){this.colWidths[0]=false;}return A;},mergeRight:function(){console.log("htmleditor.BlockTd mergeRight");var tr=this.node.closest('tr');var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=tr.childNodes.length-1){return;}var A=this.toTableArray();
\e[m
1912 \e[32m+
\e[m
\e[32mconsole.log(A);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;
\e[m
1913 \e[32m+
\e[m
\e[32mtr.removeChild(rc.cell);this.colspan+=rc.colspan;this.node.setAttribute('colspan',this.colspan);},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;
\e[m
1914 \e[32m+
\e[m
\e[32m}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;
\e[m
1915 \e[32m+
\e[m
\e[32mthis.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;
\e[m
1916 \e[32m+
\e[m
\e[32mc<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);
\e[m
1917 \e[32m+
\e[m
\e[32m},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);});r.parentNode.removeChild(r);});for(var r=0;
\e[m
1918 \e[32m+
\e[m
\e[32mr<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}}},updateWidths:function(A){for(var r=0;r<A.length;
\e[m
1919 \e[32m+
\e[m
\e[32mr++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';el.updateElement(el.node);}A[r][c].cell=false;
\e[m
1920 \e[32m+
\e[m
\e[32m}}},normalizeWidths:function(A){console.log("htmleditor.BlockTd normalizeWidths");console.log(this.colWidths);if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];
\e[m
1921 \e[32m+
\e[m
\e[32mthis.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);
\e[m
1922 \e[32m+
\e[m
\e[32mvar t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;},this);}},shrinkColumn:function(){var A=this.toTableArray();console.log(A);this.normalizeWidths(A);console.log(this.colWidths);
\e[m
1923 \e[32m+
\e[m
\e[32mvar B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();
\e[m
1924 \e[32m+
\e[m
\e[32mthis.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);
\e[m
1925 \e[32m+
\e[m
\e[32m},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);
\e[m
1926 \e[32m+
\e[m
\e[32m}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;
\e[m
1927 \e[32m+
\e[m
\e[32mc.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
1928 // Roo/HtmlEditorCore.js
\e[m
1929 Roo.HtmlEditorCore=function(A){Roo.HtmlEditorCore.superclass.constructor.call(this,A);this.addEvents({initialize:true,activate:true,beforesync:true,beforepush:true,sync:true,push:true,editorevent:true});this.applyBlacklists();};Roo.extend(Roo.HtmlEditorCore,Roo.Component,{owner:false,resizable:false,height:300,width:500,autoClean:true,enableBlocks:true,stylesheets:false,language:'en',allowComments:false,frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,sourceEditMode:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',clearUp:true,black:false,white:false,bodyCls:'',undoManager:false,getDocMarkup:function(){var st='';
\e[m
1930 if(this.stylesheets===false){Roo.get(document.head).select('style').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);});Roo.get(document.head).select('link').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);
\e[m
1931 \e[1mdiff --git a/Roo/htmleditor/BlockTd.js b/Roo/htmleditor/BlockTd.js
\e[m
1932 \e[1mindex b6022caa76..90a7df25ad 100644
\e[m
1933 \e[1m--- a/Roo/htmleditor/BlockTd.js
\e[m
1934 \e[1m+++ b/Roo/htmleditor/BlockTd.js
\e[m
1935 \e[36m@@ -339,7 +339,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1937 toObject : function()
\e[m
1942 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
1943 \e[36m@@ -407,6 +406,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1945 toTableArray : function()
\e[m
1947 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd toTableArray ");
\e[m
1949 var tab = this.node.closest('tr').closest('table');
\e[m
1950 Array.from(tab.rows).forEach(function(r, ri){
\e[m
1951 \e[36m@@ -419,6 +419,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1954 Array.from(r.cells).forEach(function(ce, ci){
\e[m
1955 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
1956 \e[32m+
\e[m
\e[32m console.log(ce);
\e[m
1960 \e[36m@@ -437,7 +439,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1964 \e[31m- if (typeof(this.colWidths[cn]) == 'undefined') {
\e[m
1965 \e[32m+
\e[m
\e[32m if (typeof(this.colWidths[cn]) == 'undefined' && c.colspan < 2 && c.rowspan < 2) {
\e[m
1966 this.colWidths[cn] = ce.style.width;
\e[m
1967 if (this.colWidths[cn] != '') {
\e[m
1968 all_auto = false;
\e[m
1969 \e[36m@@ -481,6 +483,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1971 mergeRight: function()
\e[m
1973 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
1975 // get the contents of the next cell along..
\e[m
1976 var tr = this.node.closest('tr');
\e[m
1977 \e[36m@@ -489,6 +492,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1978 return; // no cells on right to merge with.
\e[m
1980 var table = this.toTableArray();
\e[m
1981 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
1983 if (typeof(table[this.cellData.row][this.cellData.col+this.cellData.colspan]) == 'undefined') {
\e[m
1984 return; // nothing right?
\e[m
1985 \e[36m@@ -506,6 +510,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1986 this.colspan += rc.colspan;
\e[m
1987 this.node.setAttribute('colspan', this.colspan);
\e[m
1989 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
1990 \e[32m+
\e[m
\e[32m this.normalizeWidths(table);
\e[m
1991 \e[32m+
\e[m
\e[32m this.updateWidths(table);
\e[m
1995 \e[36m@@ -560,8 +567,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
1997 this.redrawAllCells(table);
\e[m
2004 \e[36m@@ -610,13 +615,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2005 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
2006 el.updateElement(el.node);
\e[m
2008 \e[32m+
\e[m
\e[32m if (this.colWidths[0] != false && table[r][c].colspan > 1) {
\e[m
2009 \e[32m+
\e[m
\e[32m var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
2010 \e[32m+
\e[m
\e[32m var width = 0;
\e[m
2011 \e[32m+
\e[m
\e[32m for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
2012 \e[32m+
\e[m
\e[32m width += Math.floor(this.colWidths[c + i]);
\e[m
2013 \e[32m+
\e[m
\e[32m }
\e[m
2014 \e[32m+
\e[m
\e[32m el.width = width +'%';
\e[m
2015 \e[32m+
\e[m
\e[32m el.updateElement(el.node);
\e[m
2016 \e[32m+
\e[m
\e[32m }
\e[m
2017 table[r][c].cell = false; // done
\e[m
2021 normalizeWidths : function(table)
\e[m
2024 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd normalizeWidths");
\e[m
2025 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
2026 if (this.colWidths[0] === false) {
\e[m
2027 var nw = 100.0 / this.colWidths.length;
\e[m
2028 this.colWidths.forEach(function(w,i) {
\e[m
2029 \e[36m@@ -663,7 +678,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2030 shrinkColumn : function()
\e[m
2032 var table = this.toTableArray();
\e[m
2033 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
2034 this.normalizeWidths(table);
\e[m
2035 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
2036 var col = this.cellData.col;
\e[m
2037 var nw = this.colWidths[col] * 0.8;
\e[m
2039 \e[1mdiff --git a/roojs-all.js b/roojs-all.js
\e[m
2040 \e[1mindex 39a3e49f52..44dd3d9f7d 100644
\e[m
2041 \e[1m--- a/roojs-all.js
\e[m
2042 \e[1m+++ b/roojs-all.js
\e[m
2043 \e[36m@@ -2039,25 +2039,28 @@
\e[m
\e[mB().deleteColumn();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEven
\e[m
2044 ,{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();
\e[m
2045 }},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}
\e[m
2046 ,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'));
\e[m
2047 \e[31m-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=[];
\e[m
2048 \e[31m-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}
\e[m
2049 \e[31m-;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'){this.colWidths[cn]=ce.style.width;if(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;
\e[m
2050 \e[31m-cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){var tr=this.node.closest('tr');
\e[m
2051 \e[31m-var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
2052 \e[31m-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);},mergeBelow:function(){var A=this.toTableArray();
\e[m
2053 \e[31m-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;
\e[m
2054 \e[31m-}this.node.innerHTML=this.node.innerHTML+rc.cell.innerHTML;rc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();
\e[m
2055 \e[31m-var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();
\e[m
2056 \e[31m-B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
2057 \e[32m+
\e[m
\e[32mthis.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(){console.log("htmleditor.BlockTd toTableArray ");
\e[m
2058 \e[32m+
\e[m
\e[32mvar 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){console.log("CELL");
\e[m
2059 \e[32m+
\e[m
\e[32mconsole.log(ce);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&&c.rowspan<2){this.colWidths[cn]=ce.style.width;
\e[m
2060 \e[32m+
\e[m
\e[32mif(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);
\e[m
2061 \e[32m+
\e[m
\e[32mif(C){this.colWidths[0]=false;}return A;},mergeRight:function(){console.log("htmleditor.BlockTd mergeRight");var tr=this.node.closest('tr');var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=tr.childNodes.length-1){return;}var A=this.toTableArray();
\e[m
2062 \e[32m+
\e[m
\e[32mconsole.log(A);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;
\e[m
2063 \e[32m+
\e[m
\e[32mtr.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;
\e[m
2064 \e[32m+
\e[m
\e[32m}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;
\e[m
2065 \e[32m+
\e[m
\e[32mrc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();var cd=this.cellData;this.rowspan=1;this.colspan=1;
\e[m
2066 \e[32m+
\e[m
\e[32mfor(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();B.removeAttribute('id');B.innerHTML='';
\e[m
2067 \e[32m+
\e[m
\e[32mA[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
2068 });r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}
\e[m
2069 }},updateWidths:function(A){for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';
\e[m
2070 \e[31m-el.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
2071 \e[31m-var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);var t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;
\e[m
2072 \e[31m-},this);}},shrinkColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;
\e[m
2073 \e[31m-return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);
\e[m
2074 \e[31m-this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;
\e[m
2075 \e[31m-c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];
\e[m
2076 \e[31m-if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;c.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
2077 \e[32m+
\e[m
\e[32mel.updateElement(el.node);}if(this.colWidths[0]!=false&&A[r][c].colspan>1){var el=Roo.htmleditor.Block.factory(A[r][c].cell);var B=0;for(var i=0;i<A[r][c].colspan;i++){B+=Math.floor(this.colWidths[c+i]);}el.width=B+'%';el.updateElement(el.node);}A[r][c].cell=false;
\e[m
2078 \e[32m+
\e[m
\e[32m}}},normalizeWidths:function(A){console.log("htmleditor.BlockTd normalizeWidths");console.log(this.colWidths);if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];
\e[m
2079 \e[32m+
\e[m
\e[32mthis.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);
\e[m
2080 \e[32m+
\e[m
\e[32mvar t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;},this);}},shrinkColumn:function(){var A=this.toTableArray();console.log(A);this.normalizeWidths(A);console.log(this.colWidths);
\e[m
2081 \e[32m+
\e[m
\e[32mvar B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();
\e[m
2082 \e[32m+
\e[m
\e[32mthis.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);
\e[m
2083 \e[32m+
\e[m
\e[32m},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);
\e[m
2084 \e[32m+
\e[m
\e[32m}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;
\e[m
2085 \e[32m+
\e[m
\e[32mc.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
2086 // Roo/HtmlEditorCore.js
\e[m
2087 Roo.HtmlEditorCore=function(A){Roo.HtmlEditorCore.superclass.constructor.call(this,A);this.addEvents({initialize:true,activate:true,beforesync:true,beforepush:true,sync:true,push:true,editorevent:true});this.applyBlacklists();};Roo.extend(Roo.HtmlEditorCore,Roo.Component,{owner:false,resizable:false,height:300,width:500,autoClean:true,enableBlocks:true,stylesheets:false,language:'en',allowComments:false,frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,sourceEditMode:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',clearUp:true,black:false,white:false,bodyCls:'',undoManager:false,getDocMarkup:function(){var st='';
\e[m
2088 if(this.stylesheets===false){Roo.get(document.head).select('style').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);});Roo.get(document.head).select('link').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);
\e[m
2089 \e[1mdiff --git a/roojs-debug.js b/roojs-debug.js
\e[m
2090 \e[1mindex 779fa0189f..ed0e0542c0 100644
\e[m
2091 \e[1m--- a/roojs-debug.js
\e[m
2092 \e[1m+++ b/roojs-debug.js
\e[m
2093 \e[36m@@ -49276,7 +49276,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2095 toObject : function()
\e[m
2100 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
2101 \e[36m@@ -49344,6 +49343,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2103 toTableArray : function()
\e[m
2105 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd toTableArray ");
\e[m
2107 var tab = this.node.closest('tr').closest('table');
\e[m
2108 Array.from(tab.rows).forEach(function(r, ri){
\e[m
2109 \e[36m@@ -49356,6 +49356,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2112 Array.from(r.cells).forEach(function(ce, ci){
\e[m
2113 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
2114 \e[32m+
\e[m
\e[32m console.log(ce);
\e[m
2118 \e[36m@@ -49374,7 +49376,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2122 \e[31m- if (typeof(this.colWidths[cn]) == 'undefined') {
\e[m
2123 \e[32m+
\e[m
\e[32m if (typeof(this.colWidths[cn]) == 'undefined' && c.colspan < 2 && c.rowspan < 2) {
\e[m
2124 this.colWidths[cn] = ce.style.width;
\e[m
2125 if (this.colWidths[cn] != '') {
\e[m
2126 all_auto = false;
\e[m
2127 \e[36m@@ -49418,6 +49420,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2129 mergeRight: function()
\e[m
2131 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
2133 // get the contents of the next cell along..
\e[m
2134 var tr = this.node.closest('tr');
\e[m
2135 \e[36m@@ -49426,6 +49429,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2136 return; // no cells on right to merge with.
\e[m
2138 var table = this.toTableArray();
\e[m
2139 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
2141 if (typeof(table[this.cellData.row][this.cellData.col+this.cellData.colspan]) == 'undefined') {
\e[m
2142 return; // nothing right?
\e[m
2143 \e[36m@@ -49443,6 +49447,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2144 this.colspan += rc.colspan;
\e[m
2145 this.node.setAttribute('colspan', this.colspan);
\e[m
2147 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
2148 \e[32m+
\e[m
\e[32m this.normalizeWidths(table);
\e[m
2149 \e[32m+
\e[m
\e[32m this.updateWidths(table);
\e[m
2153 \e[36m@@ -49497,8 +49504,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2155 this.redrawAllCells(table);
\e[m
2162 \e[36m@@ -49547,13 +49552,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2163 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
2164 el.updateElement(el.node);
\e[m
2166 \e[32m+
\e[m
\e[32m if (this.colWidths[0] != false && table[r][c].colspan > 1) {
\e[m
2167 \e[32m+
\e[m
\e[32m var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
2168 \e[32m+
\e[m
\e[32m var width = 0;
\e[m
2169 \e[32m+
\e[m
\e[32m for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
2170 \e[32m+
\e[m
\e[32m width += Math.floor(this.colWidths[c + i]);
\e[m
2171 \e[32m+
\e[m
\e[32m }
\e[m
2172 \e[32m+
\e[m
\e[32m el.width = width +'%';
\e[m
2173 \e[32m+
\e[m
\e[32m el.updateElement(el.node);
\e[m
2174 \e[32m+
\e[m
\e[32m }
\e[m
2175 table[r][c].cell = false; // done
\e[m
2179 normalizeWidths : function(table)
\e[m
2182 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd normalizeWidths");
\e[m
2183 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
2184 if (this.colWidths[0] === false) {
\e[m
2185 var nw = 100.0 / this.colWidths.length;
\e[m
2186 this.colWidths.forEach(function(w,i) {
\e[m
2187 \e[36m@@ -49600,7 +49615,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2188 shrinkColumn : function()
\e[m
2190 var table = this.toTableArray();
\e[m
2191 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
2192 this.normalizeWidths(table);
\e[m
2193 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
2194 var col = this.cellData.col;
\e[m
2195 var nw = this.colWidths[col] * 0.8;
\e[m
2197 \e[1mdiff --git a/roojs-ui-debug.js b/roojs-ui-debug.js
\e[m
2198 \e[1mindex 6623fbfdb0..3301c8a150 100644
\e[m
2199 \e[1m--- a/roojs-ui-debug.js
\e[m
2200 \e[1m+++ b/roojs-ui-debug.js
\e[m
2201 \e[36m@@ -24784,7 +24784,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2203 toObject : function()
\e[m
2208 contenteditable : 'true', // this stops cell selection from picking the table.
\e[m
2209 \e[36m@@ -24852,6 +24851,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2211 toTableArray : function()
\e[m
2213 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd toTableArray ");
\e[m
2215 var tab = this.node.closest('tr').closest('table');
\e[m
2216 Array.from(tab.rows).forEach(function(r, ri){
\e[m
2217 \e[36m@@ -24864,6 +24864,8 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2220 Array.from(r.cells).forEach(function(ce, ci){
\e[m
2221 \e[32m+
\e[m
\e[32m console.log("CELL");
\e[m
2222 \e[32m+
\e[m
\e[32m console.log(ce);
\e[m
2226 \e[36m@@ -24882,7 +24884,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2230 \e[31m- if (typeof(this.colWidths[cn]) == 'undefined') {
\e[m
2231 \e[32m+
\e[m
\e[32m if (typeof(this.colWidths[cn]) == 'undefined' && c.colspan < 2 && c.rowspan < 2) {
\e[m
2232 this.colWidths[cn] = ce.style.width;
\e[m
2233 if (this.colWidths[cn] != '') {
\e[m
2234 all_auto = false;
\e[m
2235 \e[36m@@ -24926,6 +24928,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2237 mergeRight: function()
\e[m
2239 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd mergeRight");
\e[m
2241 // get the contents of the next cell along..
\e[m
2242 var tr = this.node.closest('tr');
\e[m
2243 \e[36m@@ -24934,6 +24937,7 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2244 return; // no cells on right to merge with.
\e[m
2246 var table = this.toTableArray();
\e[m
2247 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
2249 if (typeof(table[this.cellData.row][this.cellData.col+this.cellData.colspan]) == 'undefined') {
\e[m
2250 return; // nothing right?
\e[m
2251 \e[36m@@ -24951,6 +24955,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2252 this.colspan += rc.colspan;
\e[m
2253 this.node.setAttribute('colspan', this.colspan);
\e[m
2255 \e[32m+
\e[m
\e[32m var table = this.toTableArray();
\e[m
2256 \e[32m+
\e[m
\e[32m this.normalizeWidths(table);
\e[m
2257 \e[32m+
\e[m
\e[32m this.updateWidths(table);
\e[m
2261 \e[36m@@ -25005,8 +25012,6 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2263 this.redrawAllCells(table);
\e[m
2270 \e[36m@@ -25055,13 +25060,23 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2271 el.width = Math.floor(this.colWidths[c]) +'%';
\e[m
2272 el.updateElement(el.node);
\e[m
2274 \e[32m+
\e[m
\e[32m if (this.colWidths[0] != false && table[r][c].colspan > 1) {
\e[m
2275 \e[32m+
\e[m
\e[32m var el = Roo.htmleditor.Block.factory(table[r][c].cell);
\e[m
2276 \e[32m+
\e[m
\e[32m var width = 0;
\e[m
2277 \e[32m+
\e[m
\e[32m for(var i = 0; i < table[r][c].colspan; i ++) {
\e[m
2278 \e[32m+
\e[m
\e[32m width += Math.floor(this.colWidths[c + i]);
\e[m
2279 \e[32m+
\e[m
\e[32m }
\e[m
2280 \e[32m+
\e[m
\e[32m el.width = width +'%';
\e[m
2281 \e[32m+
\e[m
\e[32m el.updateElement(el.node);
\e[m
2282 \e[32m+
\e[m
\e[32m }
\e[m
2283 table[r][c].cell = false; // done
\e[m
2287 normalizeWidths : function(table)
\e[m
2290 \e[32m+
\e[m
\e[32m console.log("htmleditor.BlockTd normalizeWidths");
\e[m
2291 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
2292 if (this.colWidths[0] === false) {
\e[m
2293 var nw = 100.0 / this.colWidths.length;
\e[m
2294 this.colWidths.forEach(function(w,i) {
\e[m
2295 \e[36m@@ -25108,7 +25123,9 @@
\e[m
\e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
\e[m
2296 shrinkColumn : function()
\e[m
2298 var table = this.toTableArray();
\e[m
2299 \e[32m+
\e[m
\e[32m console.log(table);
\e[m
2300 this.normalizeWidths(table);
\e[m
2301 \e[32m+
\e[m
\e[32m console.log(this.colWidths);
\e[m
2302 var col = this.cellData.col;
\e[m
2303 var nw = this.colWidths[col] * 0.8;
\e[m
2305 \e[1mdiff --git a/roojs-ui.js b/roojs-ui.js
\e[m
2306 \e[1mindex 40ce72d195..6212babf17 100644
\e[m
2307 \e[1m--- a/roojs-ui.js
\e[m
2308 \e[1m+++ b/roojs-ui.js
\e[m
2309 \e[36m@@ -1093,25 +1093,28 @@
\e[m
\e[mB().deleteColumn();E();A.editorcore.selectNode(t.node);A.editorcore.onEditorEven
\e[m
2310 ,{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();
\e[m
2311 }},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}
\e[m
2312 ,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'));
\e[m
2313 \e[31m-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=[];
\e[m
2314 \e[31m-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}
\e[m
2315 \e[31m-;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'){this.colWidths[cn]=ce.style.width;if(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;
\e[m
2316 \e[31m-cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);if(C){this.colWidths[0]=false;}return A;},mergeRight:function(){var tr=this.node.closest('tr');
\e[m
2317 \e[31m-var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=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];
\e[m
2318 \e[31m-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);},mergeBelow:function(){var A=this.toTableArray();
\e[m
2319 \e[31m-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;
\e[m
2320 \e[31m-}this.node.innerHTML=this.node.innerHTML+rc.cell.innerHTML;rc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();
\e[m
2321 \e[31m-var cd=this.cellData;this.rowspan=1;this.colspan=1;for(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();
\e[m
2322 \e[31m-B.removeAttribute('id');B.innerHTML='';A[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
2323 \e[32m+
\e[m
\e[32mthis.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(){console.log("htmleditor.BlockTd toTableArray ");
\e[m
2324 \e[32m+
\e[m
\e[32mvar 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){console.log("CELL");
\e[m
2325 \e[32m+
\e[m
\e[32mconsole.log(ce);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&&c.rowspan<2){this.colWidths[cn]=ce.style.width;
\e[m
2326 \e[32m+
\e[m
\e[32mif(this.colWidths[cn]!=''){C=false;}}if(c.colspan<2&&c.rowspan<2){A[rn][cn]=c;cn++;return;}for(var j=0;j<c.rowspan;j++){if(typeof(A[rn+j])=='undefined'){continue;}A[rn+j][cn]=c;for(var i=0;i<c.colspan;i++){A[rn+j][cn+i]=c;}}cn+=c.colspan;},this);rn++;},this);
\e[m
2327 \e[32m+
\e[m
\e[32mif(C){this.colWidths[0]=false;}return A;},mergeRight:function(){console.log("htmleditor.BlockTd mergeRight");var tr=this.node.closest('tr');var i=Array.prototype.indexOf.call(tr.childNodes,this.node);if(i>=tr.childNodes.length-1){return;}var A=this.toTableArray();
\e[m
2328 \e[32m+
\e[m
\e[32mconsole.log(A);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;
\e[m
2329 \e[32m+
\e[m
\e[32mtr.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;
\e[m
2330 \e[32m+
\e[m
\e[32m}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;
\e[m
2331 \e[32m+
\e[m
\e[32mrc.cell.parentNode.removeChild(rc.cell);this.rowspan+=rc.rowspan;this.node.setAttribute('rowspan',this.rowspan);},split:function(){if(this.node.rowSpan<2&&this.node.colSpan<2){return;}var A=this.toTableArray();var cd=this.cellData;this.rowspan=1;this.colspan=1;
\e[m
2332 \e[32m+
\e[m
\e[32mfor(var r=cd.row;r<cd.row+cd.rowspan;r++){for(var c=cd.col;c<cd.col+cd.colspan;c++){if(r==cd.row&&c==cd.col){this.node.removeAttribute('rowspan');this.node.removeAttribute('colspan');continue;}var B=this.node.cloneNode();B.removeAttribute('id');B.innerHTML='';
\e[m
2333 \e[32m+
\e[m
\e[32mA[r][c]={cell:B,col:c,row:r,colspan:1,rowspan:1};}}this.redrawAllCells(A);},redrawAllCells:function(A){var B=this.node.closest('tr').closest('table');var C=B.rows[0].parentNode;Array.from(B.rows).forEach(function(r,ri){Array.from(r.cells).forEach(function(ce,ci){ce.parentNode.removeChild(ce);
\e[m
2334 });r.parentNode.removeChild(r);});for(var r=0;r<A.length;r++){var re=B.rows[r];var re=B.ownerDocument.createElement('tr');C.appendChild(re);for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}re.appendChild(A[r][c].cell);A[r][c].cell=false;}
\e[m
2335 }},updateWidths:function(A){for(var r=0;r<A.length;r++){for(var c=0;c<A[r].length;c++){if(A[r][c].cell===false){continue;}if(this.colWidths[0]!=false&&A[r][c].colspan<2){var el=Roo.htmleditor.Block.factory(A[r][c].cell);el.width=Math.floor(this.colWidths[c])+'%';
\e[m
2336 \e[31m-el.updateElement(el.node);}A[r][c].cell=false;}}},normalizeWidths:function(A){if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];this.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
\e[m
2337 \e[31m-var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);var t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;
\e[m
2338 \e[31m-},this);}},shrinkColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;
\e[m
2339 \e[31m-return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();this.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);
\e[m
2340 \e[31m-this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;
\e[m
2341 \e[31m-c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];
\e[m
2342 \e[31m-if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;c.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
2343 \e[32m+
\e[m
\e[32mel.updateElement(el.node);}if(this.colWidths[0]!=false&&A[r][c].colspan>1){var el=Roo.htmleditor.Block.factory(A[r][c].cell);var B=0;for(var i=0;i<A[r][c].colspan;i++){B+=Math.floor(this.colWidths[c+i]);}el.width=B+'%';el.updateElement(el.node);}A[r][c].cell=false;
\e[m
2344 \e[32m+
\e[m
\e[32m}}},normalizeWidths:function(A){console.log("htmleditor.BlockTd normalizeWidths");console.log(this.colWidths);if(this.colWidths[0]===false){var nw=100.0/this.colWidths.length;this.colWidths.forEach(function(w,i){this.colWidths[i]=nw;},this);return;}var t=0,B=[];
\e[m
2345 \e[32m+
\e[m
\e[32mthis.colWidths.forEach(function(w,i){this.colWidths[i]=this.colWidths[i]==''?0:(this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;var D=this.colWidths[i];if(D>0){t+=D;return;}B.push(i);},this);var nc=this.colWidths.length;if(B.length){var C=(nc-B.length)/(1.0*nc);
\e[m
2346 \e[32m+
\e[m
\e[32mvar t=C*t;var ew=(100-t)/(1.0*B.length);this.colWidths.forEach(function(w,i){if(w>0){this.colWidths[i]=w*C;return;}this.colWidths[i]=ew;},this);}},shrinkColumn:function(){var A=this.toTableArray();console.log(A);this.normalizeWidths(A);console.log(this.colWidths);
\e[m
2347 \e[32m+
\e[m
\e[32mvar B=this.cellData.col;var nw=this.colWidths[B]*0.8;if(nw<5){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]+=C},this);this.updateWidths(A);},growColumn:function(){var A=this.toTableArray();
\e[m
2348 \e[32m+
\e[m
\e[32mthis.normalizeWidths(A);var B=this.cellData.col;var nw=this.colWidths[B]*1.2;if(nw>90){return;}var C=(this.colWidths[B]*0.2)/(this.colWidths.length-1);this.colWidths.forEach(function(w,i){if(i==B){this.colWidths[i]=nw;return;}this.colWidths[i]-=C},this);this.updateWidths(A);
\e[m
2349 \e[32m+
\e[m
\e[32m},deleteRow:function(){var A=this.toTableArray();for(var i=0;i<A[this.cellData.row].length;i++){var c=A[this.cellData.row][i];if(c.row!=this.cellData.row){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);continue;}if(c.rowspan>1){c.rowspan--;c.cell.setAttribute('rowspan',c.rowspan);
\e[m
2350 \e[32m+
\e[m
\e[32m}}A.splice(this.cellData.row,1);this.redrawAllCells(A);},deleteColumn:function(){var A=this.toTableArray();for(var i=0;i<A.length;i++){var c=A[i][this.cellData.col];if(c.col!=this.cellData.col){A[i][this.cellData.col].colspan--;}else if(c.colspan>1){c.colspan--;
\e[m
2351 \e[32m+
\e[m
\e[32mc.cell.setAttribute('colspan',c.colspan);}A[i].splice(this.cellData.col,1);}this.redrawAllCells(A);}})
\e[m
2352 // Roo/HtmlEditorCore.js
\e[m
2353 Roo.HtmlEditorCore=function(A){Roo.HtmlEditorCore.superclass.constructor.call(this,A);this.addEvents({initialize:true,activate:true,beforesync:true,beforepush:true,sync:true,push:true,editorevent:true});this.applyBlacklists();};Roo.extend(Roo.HtmlEditorCore,Roo.Component,{owner:false,resizable:false,height:300,width:500,autoClean:true,enableBlocks:true,stylesheets:false,language:'en',allowComments:false,frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,sourceEditMode:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',clearUp:true,black:false,white:false,bodyCls:'',undoManager:false,getDocMarkup:function(){var st='';
\e[m
2354 if(this.stylesheets===false){Roo.get(document.head).select('style').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);});Roo.get(document.head).select('link').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);
\e[m