| | |
| | | endX = startX + (cols - 1); |
| | | endY = startY + (rows - 1); |
| | | } else { |
| | | startPos = endPos = null; |
| | | |
| | | // Calculate start/end pos by checking for selected cells in grid works better with context menu |
| | | each(grid, function(row, y) { |
| | | each(row, function(cell, x) { |
| | | if (isCellSelected(cell)) { |
| | | if (!startPos) { |
| | | startPos = {x: x, y: y}; |
| | | } |
| | | |
| | | endPos = {x: x, y: y}; |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | // Use selection |
| | | startX = startPos.x; |
| | | startY = startPos.y; |
| | |
| | | else |
| | | dom.insertAfter(row, targetRow); |
| | | }); |
| | | |
| | | // Remove current selection |
| | | dom.removeClass(dom.select('td.mceSelected,th.mceSelected'), 'mceSelected'); |
| | | }; |
| | | |
| | | function getPos(target) { |
| | |
| | | for (last = ed.getBody().lastChild; last && last.nodeType == 3 && !last.nodeValue.length; last = last.previousSibling) ; |
| | | |
| | | if (last && last.nodeName == 'TABLE') |
| | | ed.dom.add(ed.getBody(), 'p', null, '<br mce_bogus="1" />'); |
| | | ed.dom.add(ed.getBody(), 'p', null, '<br data-mce-bogus="1" />'); |
| | | }; |
| | | |
| | | // Fixes an bug where it's impossible to place the caret before a table in Gecko |
| | |
| | | ed.onPreProcess.add(function(ed, o) { |
| | | var last = o.node.lastChild; |
| | | |
| | | if (last && last.childNodes.length == 1 && last.firstChild.nodeName == 'BR') |
| | | if (last && last.childNodes.length == 1 && last.firstChild.nodeName == 'BR' && last.previousSibling && last.previousSibling.nodeName == "TABLE") |
| | | ed.dom.remove(last); |
| | | }); |
| | | |