fix html editor column width and merge
[roojs1] / -core.js roojs-ui.js > roojs-all.js
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
6       */\e[m
7      toObject : function()\e[m
8      {\e[m
9 \e[31m-        \e[m
10          var ret = {\e[m
11              tag : 'td',\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
14      \e[m
15      mergeRight: function()\e[m
16      {\e[m
17 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
18           \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
24  \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
28      },\e[m
29      \e[m
30      \e[m
31 \e[36m@@ -598,6 +601,11 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
32      },\e[m
33      updateWidths : function(table)\e[m
34      {\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
41             \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
44                  }\e[m
45                  \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
52                  }\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
65              }\e[m
66          }\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:"&nbsp;"};},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
103       */\e[m
104      toObject : function()\e[m
105      {\e[m
106 \e[31m-        \e[m
107          var ret = {\e[m
108              tag : 'td',\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
111      \e[m
112      mergeRight: function()\e[m
113      {\e[m
114 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
115           \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
121  \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
125      },\e[m
126      \e[m
127      \e[m
128 \e[36m@@ -49535,6 +49538,11 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
129      },\e[m
130      updateWidths : function(table)\e[m
131      {\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
138             \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
141                  }\e[m
142                  \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
149                  }\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
155              }\e[m
156          }\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
162       */\e[m
163      toObject : function()\e[m
164      {\e[m
165 \e[31m-        \e[m
166          var ret = {\e[m
167              tag : 'td',\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
170      \e[m
171      mergeRight: function()\e[m
172      {\e[m
173 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
174           \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
180  \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
184      },\e[m
185      \e[m
186      \e[m
187 \e[36m@@ -25043,6 +25046,11 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
188      },\e[m
189      updateWidths : function(table)\e[m
190      {\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
197             \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
200                  }\e[m
201                  \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
208                  }\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
214              }\e[m
215          }\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:"&nbsp;"};},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
252       */\e[m
253      toObject : function()\e[m
254      {\e[m
255 \e[31m-        \e[m
256          var ret = {\e[m
257              tag : 'td',\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
260      \e[m
261      mergeRight: function()\e[m
262      {\e[m
263 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
264           \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
270  \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
274      },\e[m
275      \e[m
276      \e[m
277 \e[36m@@ -559,8 +562,9 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
278              \e[m
279          }\e[m
280          this.redrawAllCells(table);\e[m
281 \e[31m-        \e[m
282 \e[31m-         \e[m
283 \e[32m+\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
286          \e[m
287      },\e[m
288      \e[m
289 \e[36m@@ -598,6 +602,11 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
290      },\e[m
291      updateWidths : function(table)\e[m
292      {\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
299             \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
302                  }\e[m
303                  \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
310                  }\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
323              }\e[m
324          }\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:"&nbsp;"};},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
361       */\e[m
362      toObject : function()\e[m
363      {\e[m
364 \e[31m-        \e[m
365          var ret = {\e[m
366              tag : 'td',\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
369      \e[m
370      mergeRight: function()\e[m
371      {\e[m
372 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
373           \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
379  \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
383      },\e[m
384      \e[m
385      \e[m
386 \e[36m@@ -49496,8 +49499,9 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
387              \e[m
388          }\e[m
389          this.redrawAllCells(table);\e[m
390 \e[31m-        \e[m
391 \e[31m-         \e[m
392 \e[32m+\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
395          \e[m
396      },\e[m
397      \e[m
398 \e[36m@@ -49535,6 +49539,11 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
399      },\e[m
400      updateWidths : function(table)\e[m
401      {\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
408             \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
411                  }\e[m
412                  \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
419                  }\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
432              }\e[m
433          }\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
439       */\e[m
440      toObject : function()\e[m
441      {\e[m
442 \e[31m-        \e[m
443          var ret = {\e[m
444              tag : 'td',\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
447      \e[m
448      mergeRight: function()\e[m
449      {\e[m
450 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
451           \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
457  \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
461      },\e[m
462      \e[m
463      \e[m
464 \e[36m@@ -25004,8 +25007,9 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
465              \e[m
466          }\e[m
467          this.redrawAllCells(table);\e[m
468 \e[31m-        \e[m
469 \e[31m-         \e[m
470 \e[32m+\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
473          \e[m
474      },\e[m
475      \e[m
476 \e[36m@@ -25043,6 +25047,11 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
477      },\e[m
478      updateWidths : function(table)\e[m
479      {\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
486             \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
489                  }\e[m
490                  \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
497                  }\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
510              }\e[m
511          }\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:"&nbsp;"};},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
548  \e[m
549  Roo.htmleditor.BlockTd = function(cfg)\e[m
550  {\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
553      if (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
557      \e[m
558      contextMenu : function(toolbar)\e[m
559      {\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
562          \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
566       */\e[m
567      toObject : function()\e[m
568      {\e[m
569 \e[31m-        \e[m
570          var ret = {\e[m
571              tag : 'td',\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
574      \e[m
575      toTableArray  : function()\e[m
576      {\e[m
577 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd toTableArray ");\e[m
578          var ret = [];\e[m
579          var tab = this.node.closest('tr').closest('table');\e[m
580          Array.from(tab.rows).forEach(function(r, ri){\e[m
581              ret[ri] = [];\e[m
582          });\e[m
583          var rn = 0;\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
587              \e[m
588              var cn = 0;\e[m
589              Array.from(r.cells).forEach(function(ce, ci){\e[m
590 \e[32m+\e[m
591                  var c =  {\e[m
592                      cell : ce,\e[m
593                      row : rn,\e[m
594 \e[36m@@ -437,14 +440,6 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
595                      c.col = cn;\e[m
596                  }\e[m
597                  \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
602 \e[31m-                    }\e[m
603 \e[31m-                }\e[m
604 \e[31m-                \e[m
605 \e[31m-                \e[m
606                  if (c.colspan < 2 && c.rowspan < 2 ) {\e[m
607                      ret[rn][cn] = c;\e[m
608                      cn++;\e[m
609 \e[36m@@ -465,15 +460,7 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
610              rn++;\e[m
611          }, this);\e[m
612          \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
617 \e[31m-        }\e[m
618 \e[31m-        \e[m
619 \e[31m-        \e[m
620          return ret;\e[m
621 \e[31m-        \e[m
622      },\e[m
623      \e[m
624      \e[m
625 \e[36m@@ -481,6 +468,7 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
626      \e[m
627      mergeRight: function()\e[m
628      {\e[m
629 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
630           \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
635          }\e[m
636          var table = this.toTableArray();\e[m
637 \e[32m+\e[m\e[32m        console.log(table);\e[m
638          \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
644  \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
650      },\e[m
651      \e[m
652      \e[m
653 \e[36m@@ -560,8 +554,6 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
654          }\e[m
655          this.redrawAllCells(table);\e[m
656          \e[m
657 \e[31m-         \e[m
658 \e[31m-        \e[m
659      },\e[m
660      \e[m
661      \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
665                  }\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
676              }\e[m
677          }\e[m
678      },\e[m
679      normalizeWidths : function(table)\e[m
680      {\e[m
681 \e[31m-    \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
689      {\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
696          if (nw < 5) {\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:"&nbsp;"};},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:"&nbsp;"};},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
771  \e[m
772  Roo.htmleditor.BlockTd = function(cfg)\e[m
773  {\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
776      if (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
780      \e[m
781      contextMenu : function(toolbar)\e[m
782      {\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
785          \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
789       */\e[m
790      toObject : function()\e[m
791      {\e[m
792 \e[31m-        \e[m
793          var ret = {\e[m
794              tag : 'td',\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
797      \e[m
798      toTableArray  : function()\e[m
799      {\e[m
800 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd toTableArray ");\e[m
801          var ret = [];\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
805              \e[m
806              var cn = 0;\e[m
807              Array.from(r.cells).forEach(function(ce, ci){\e[m
808 \e[32m+\e[m
809                  var c =  {\e[m
810                      cell : ce,\e[m
811                      row : rn,\e[m
812 \e[36m@@ -49418,6 +49423,7 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
813      \e[m
814      mergeRight: function()\e[m
815      {\e[m
816 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
817           \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
822          }\e[m
823          var table = this.toTableArray();\e[m
824 \e[32m+\e[m\e[32m        console.log(table);\e[m
825          \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
831  \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
837      },\e[m
838      \e[m
839      \e[m
840 \e[36m@@ -49497,8 +49509,6 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
841          }\e[m
842          this.redrawAllCells(table);\e[m
843          \e[m
844 \e[31m-         \e[m
845 \e[31m-        \e[m
846      },\e[m
847      \e[m
848      \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
852                  }\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
863              }\e[m
864          }\e[m
865      },\e[m
866      normalizeWidths : function(table)\e[m
867      {\e[m
868 \e[31m-    \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
876      {\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
883          if (nw < 5) {\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
889  \e[m
890  Roo.htmleditor.BlockTd = function(cfg)\e[m
891  {\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
894      if (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
898      \e[m
899      contextMenu : function(toolbar)\e[m
900      {\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
903          \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
907       */\e[m
908      toObject : function()\e[m
909      {\e[m
910 \e[31m-        \e[m
911          var ret = {\e[m
912              tag : 'td',\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
915      \e[m
916      toTableArray  : function()\e[m
917      {\e[m
918 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd toTableArray ");\e[m
919          var ret = [];\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
923              \e[m
924              var cn = 0;\e[m
925              Array.from(r.cells).forEach(function(ce, ci){\e[m
926 \e[32m+\e[m
927                  var c =  {\e[m
928                      cell : ce,\e[m
929                      row : rn,\e[m
930 \e[36m@@ -24926,6 +24931,7 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
931      \e[m
932      mergeRight: function()\e[m
933      {\e[m
934 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
935           \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
940          }\e[m
941          var table = this.toTableArray();\e[m
942 \e[32m+\e[m\e[32m        console.log(table);\e[m
943          \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
949  \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
955      },\e[m
956      \e[m
957      \e[m
958 \e[36m@@ -25005,8 +25017,6 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
959          }\e[m
960          this.redrawAllCells(table);\e[m
961          \e[m
962 \e[31m-         \e[m
963 \e[31m-        \e[m
964      },\e[m
965      \e[m
966      \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
970                  }\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
981              }\e[m
982          }\e[m
983      },\e[m
984      normalizeWidths : function(table)\e[m
985      {\e[m
986 \e[31m-    \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
994      {\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
1001          if (nw < 5) {\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:"&nbsp;"};},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:"&nbsp;"};},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
1076       */\e[m
1077      toObject : function()\e[m
1078      {\e[m
1079 \e[31m-        \e[m
1080          var ret = {\e[m
1081              tag : 'td',\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
1084      \e[m
1085      toTableArray  : function()\e[m
1086      {\e[m
1087 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd toTableArray ");\e[m
1088          var ret = [];\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
1092              \e[m
1093              var cn = 0;\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
1097                  var c =  {\e[m
1098                      cell : ce,\e[m
1099                      row : rn,\e[m
1100 \e[36m@@ -438,6 +440,8 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1101                  }\e[m
1102                  \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
1110      \e[m
1111      mergeRight: function()\e[m
1112      {\e[m
1113 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
1114           \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
1119          }\e[m
1120          var table = this.toTableArray();\e[m
1121 \e[32m+\e[m\e[32m        console.log(table);\e[m
1122          \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
1128  \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
1134      },\e[m
1135      \e[m
1136      \e[m
1137 \e[36m@@ -560,8 +571,6 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1138          }\e[m
1139          this.redrawAllCells(table);\e[m
1140          \e[m
1141 \e[31m-         \e[m
1142 \e[31m-        \e[m
1143      },\e[m
1144      \e[m
1145      \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
1149                  }\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
1160              }\e[m
1161          }\e[m
1162      },\e[m
1163      normalizeWidths : function(table)\e[m
1164      {\e[m
1165 \e[31m-    \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
1173      {\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
1180          if (nw < 5) {\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:"&nbsp;"};},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:"&nbsp;"};},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
1235       */\e[m
1236      toObject : function()\e[m
1237      {\e[m
1238 \e[31m-        \e[m
1239          var ret = {\e[m
1240              tag : 'td',\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
1243      \e[m
1244      toTableArray  : function()\e[m
1245      {\e[m
1246 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd toTableArray ");\e[m
1247          var ret = [];\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
1251              \e[m
1252              var cn = 0;\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
1256                  var c =  {\e[m
1257                      cell : ce,\e[m
1258                      row : rn,\e[m
1259 \e[36m@@ -49375,6 +49377,8 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1260                  }\e[m
1261                  \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
1269      \e[m
1270      mergeRight: function()\e[m
1271      {\e[m
1272 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
1273           \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
1278          }\e[m
1279          var table = this.toTableArray();\e[m
1280 \e[32m+\e[m\e[32m        console.log(table);\e[m
1281          \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
1287  \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
1293      },\e[m
1294      \e[m
1295      \e[m
1296 \e[36m@@ -49497,8 +49508,6 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1297          }\e[m
1298          this.redrawAllCells(table);\e[m
1299          \e[m
1300 \e[31m-         \e[m
1301 \e[31m-        \e[m
1302      },\e[m
1303      \e[m
1304      \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
1308                  }\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
1319              }\e[m
1320          }\e[m
1321      },\e[m
1322      normalizeWidths : function(table)\e[m
1323      {\e[m
1324 \e[31m-    \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
1332      {\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
1339          if (nw < 5) {\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
1345       */\e[m
1346      toObject : function()\e[m
1347      {\e[m
1348 \e[31m-        \e[m
1349          var ret = {\e[m
1350              tag : 'td',\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
1353      \e[m
1354      toTableArray  : function()\e[m
1355      {\e[m
1356 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd toTableArray ");\e[m
1357          var ret = [];\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
1361              \e[m
1362              var cn = 0;\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
1366                  var c =  {\e[m
1367                      cell : ce,\e[m
1368                      row : rn,\e[m
1369 \e[36m@@ -24883,6 +24885,8 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1370                  }\e[m
1371                  \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
1379      \e[m
1380      mergeRight: function()\e[m
1381      {\e[m
1382 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
1383           \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
1388          }\e[m
1389          var table = this.toTableArray();\e[m
1390 \e[32m+\e[m\e[32m        console.log(table);\e[m
1391          \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
1397  \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
1403      },\e[m
1404      \e[m
1405      \e[m
1406 \e[36m@@ -25005,8 +25016,6 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1407          }\e[m
1408          this.redrawAllCells(table);\e[m
1409          \e[m
1410 \e[31m-         \e[m
1411 \e[31m-        \e[m
1412      },\e[m
1413      \e[m
1414      \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
1418                  }\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
1429              }\e[m
1430          }\e[m
1431      },\e[m
1432      normalizeWidths : function(table)\e[m
1433      {\e[m
1434 \e[31m-    \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
1442      {\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
1449          if (nw < 5) {\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:"&nbsp;"};},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:"&nbsp;"};},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
1504       */\e[m
1505      toObject : function()\e[m
1506      {\e[m
1507 \e[31m-        \e[m
1508          var ret = {\e[m
1509              tag : 'td',\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
1512      \e[m
1513      toTableArray  : function()\e[m
1514      {\e[m
1515 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd toTableArray ");\e[m
1516          var ret = [];\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
1520              \e[m
1521              var cn = 0;\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
1525                  var c =  {\e[m
1526                      cell : ce,\e[m
1527                      row : rn,\e[m
1528 \e[36m@@ -437,7 +439,7 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1529                      c.col = cn;\e[m
1530                  }\e[m
1531                  \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
1538      \e[m
1539      mergeRight: function()\e[m
1540      {\e[m
1541 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
1542           \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
1547          }\e[m
1548          var table = this.toTableArray();\e[m
1549 \e[32m+\e[m\e[32m        console.log(table);\e[m
1550          \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
1556  \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
1562      },\e[m
1563      \e[m
1564      \e[m
1565 \e[36m@@ -560,8 +569,6 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1566          }\e[m
1567          this.redrawAllCells(table);\e[m
1568          \e[m
1569 \e[31m-         \e[m
1570 \e[31m-        \e[m
1571      },\e[m
1572      \e[m
1573      \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
1577                  }\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
1588              }\e[m
1589          }\e[m
1590      },\e[m
1591      normalizeWidths : function(table)\e[m
1592      {\e[m
1593 \e[31m-    \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
1601      {\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
1608          if (nw < 5) {\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:"&nbsp;"};},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:"&nbsp;"};},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
1665       */\e[m
1666      toObject : function()\e[m
1667      {\e[m
1668 \e[31m-        \e[m
1669          var ret = {\e[m
1670              tag : 'td',\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
1673      \e[m
1674      toTableArray  : function()\e[m
1675      {\e[m
1676 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd toTableArray ");\e[m
1677          var ret = [];\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
1681              \e[m
1682              var cn = 0;\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
1686                  var c =  {\e[m
1687                      cell : ce,\e[m
1688                      row : rn,\e[m
1689 \e[36m@@ -49374,7 +49376,7 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1690                      c.col = cn;\e[m
1691                  }\e[m
1692                  \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
1699      \e[m
1700      mergeRight: function()\e[m
1701      {\e[m
1702 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
1703           \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
1708          }\e[m
1709          var table = this.toTableArray();\e[m
1710 \e[32m+\e[m\e[32m        console.log(table);\e[m
1711          \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
1717  \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
1723      },\e[m
1724      \e[m
1725      \e[m
1726 \e[36m@@ -49497,8 +49506,6 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1727          }\e[m
1728          this.redrawAllCells(table);\e[m
1729          \e[m
1730 \e[31m-         \e[m
1731 \e[31m-        \e[m
1732      },\e[m
1733      \e[m
1734      \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
1738                  }\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
1749              }\e[m
1750          }\e[m
1751      },\e[m
1752      normalizeWidths : function(table)\e[m
1753      {\e[m
1754 \e[31m-    \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
1762      {\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
1769          if (nw < 5) {\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
1775       */\e[m
1776      toObject : function()\e[m
1777      {\e[m
1778 \e[31m-        \e[m
1779          var ret = {\e[m
1780              tag : 'td',\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
1783      \e[m
1784      toTableArray  : function()\e[m
1785      {\e[m
1786 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd toTableArray ");\e[m
1787          var ret = [];\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
1791              \e[m
1792              var cn = 0;\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
1796                  var c =  {\e[m
1797                      cell : ce,\e[m
1798                      row : rn,\e[m
1799 \e[36m@@ -24882,7 +24884,7 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1800                      c.col = cn;\e[m
1801                  }\e[m
1802                  \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
1809      \e[m
1810      mergeRight: function()\e[m
1811      {\e[m
1812 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
1813           \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
1818          }\e[m
1819          var table = this.toTableArray();\e[m
1820 \e[32m+\e[m\e[32m        console.log(table);\e[m
1821          \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
1827  \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
1833      },\e[m
1834      \e[m
1835      \e[m
1836 \e[36m@@ -25005,8 +25014,6 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1837          }\e[m
1838          this.redrawAllCells(table);\e[m
1839          \e[m
1840 \e[31m-         \e[m
1841 \e[31m-        \e[m
1842      },\e[m
1843      \e[m
1844      \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
1848                  }\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
1859              }\e[m
1860          }\e[m
1861      },\e[m
1862      normalizeWidths : function(table)\e[m
1863      {\e[m
1864 \e[31m-    \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
1872      {\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
1879          if (nw < 5) {\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:"&nbsp;"};},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:"&nbsp;"};},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
1936       */\e[m
1937      toObject : function()\e[m
1938      {\e[m
1939 \e[31m-        \e[m
1940          var ret = {\e[m
1941              tag : 'td',\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
1944      \e[m
1945      toTableArray  : function()\e[m
1946      {\e[m
1947 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd toTableArray ");\e[m
1948          var ret = [];\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
1952              \e[m
1953              var cn = 0;\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
1957                  var c =  {\e[m
1958                      cell : ce,\e[m
1959                      row : rn,\e[m
1960 \e[36m@@ -437,7 +439,7 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1961                      c.col = cn;\e[m
1962                  }\e[m
1963                  \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
1970      \e[m
1971      mergeRight: function()\e[m
1972      {\e[m
1973 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
1974           \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
1979          }\e[m
1980          var table = this.toTableArray();\e[m
1981 \e[32m+\e[m\e[32m        console.log(table);\e[m
1982          \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
1988  \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
1992      },\e[m
1993      \e[m
1994      \e[m
1995 \e[36m@@ -560,8 +567,6 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
1996          }\e[m
1997          this.redrawAllCells(table);\e[m
1998          \e[m
1999 \e[31m-         \e[m
2000 \e[31m-        \e[m
2001      },\e[m
2002      \e[m
2003      \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
2007                  }\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
2018              }\e[m
2019          }\e[m
2020      },\e[m
2021      normalizeWidths : function(table)\e[m
2022      {\e[m
2023 \e[31m-    \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
2031      {\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
2038          if (nw < 5) {\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:"&nbsp;"};},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:"&nbsp;"};},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
2094       */\e[m
2095      toObject : function()\e[m
2096      {\e[m
2097 \e[31m-        \e[m
2098          var ret = {\e[m
2099              tag : 'td',\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
2102      \e[m
2103      toTableArray  : function()\e[m
2104      {\e[m
2105 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd toTableArray ");\e[m
2106          var ret = [];\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
2110              \e[m
2111              var cn = 0;\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
2115                  var c =  {\e[m
2116                      cell : ce,\e[m
2117                      row : rn,\e[m
2118 \e[36m@@ -49374,7 +49376,7 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
2119                      c.col = cn;\e[m
2120                  }\e[m
2121                  \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
2128      \e[m
2129      mergeRight: function()\e[m
2130      {\e[m
2131 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
2132           \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
2137          }\e[m
2138          var table = this.toTableArray();\e[m
2139 \e[32m+\e[m\e[32m        console.log(table);\e[m
2140          \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
2146  \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
2150      },\e[m
2151      \e[m
2152      \e[m
2153 \e[36m@@ -49497,8 +49504,6 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
2154          }\e[m
2155          this.redrawAllCells(table);\e[m
2156          \e[m
2157 \e[31m-         \e[m
2158 \e[31m-        \e[m
2159      },\e[m
2160      \e[m
2161      \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
2165                  }\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
2176              }\e[m
2177          }\e[m
2178      },\e[m
2179      normalizeWidths : function(table)\e[m
2180      {\e[m
2181 \e[31m-    \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
2189      {\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
2196          if (nw < 5) {\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
2202       */\e[m
2203      toObject : function()\e[m
2204      {\e[m
2205 \e[31m-        \e[m
2206          var ret = {\e[m
2207              tag : 'td',\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
2210      \e[m
2211      toTableArray  : function()\e[m
2212      {\e[m
2213 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd toTableArray ");\e[m
2214          var ret = [];\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
2218              \e[m
2219              var cn = 0;\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
2223                  var c =  {\e[m
2224                      cell : ce,\e[m
2225                      row : rn,\e[m
2226 \e[36m@@ -24882,7 +24884,7 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
2227                      c.col = cn;\e[m
2228                  }\e[m
2229                  \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
2236      \e[m
2237      mergeRight: function()\e[m
2238      {\e[m
2239 \e[32m+\e[m\e[32m        console.log("htmleditor.BlockTd mergeRight");\e[m
2240           \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
2245          }\e[m
2246          var table = this.toTableArray();\e[m
2247 \e[32m+\e[m\e[32m        console.log(table);\e[m
2248          \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
2254  \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
2258      },\e[m
2259      \e[m
2260      \e[m
2261 \e[36m@@ -25005,8 +25012,6 @@\e[m \e[mRoo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {\e[m
2262          }\e[m
2263          this.redrawAllCells(table);\e[m
2264          \e[m
2265 \e[31m-         \e[m
2266 \e[31m-        \e[m
2267      },\e[m
2268      \e[m
2269      \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
2273                  }\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
2284              }\e[m
2285          }\e[m
2286      },\e[m
2287      normalizeWidths : function(table)\e[m
2288      {\e[m
2289 \e[31m-    \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
2297      {\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
2304          if (nw < 5) {\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:"&nbsp;"};},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:"&nbsp;"};},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