Ticket #9944: tabletools_insertcell.js

File tabletools_insertcell.js, 763 bytes (added by Michiel Overeem, 11 years ago)

corrected insertCell function

Line 
1    function insertCell(selection, insertBefore)
2    {
3      var startElement = selection.getStartElement();
4      var tableElement = startElement.getAscendant('table', 0);
5
6      if(!tableElement)
7        return;
8
9      var cell = startElement.getAscendant('td', 1);
10
11      if(cell.getAscendant('table', 0).$ != tableElement.$)
12      {
13        cell = startElement.getAscendant('th', 1);
14      }
15
16      if(!cell || cell.getAscendant('table', 0).$ != tableElement.$)
17        return;
18
19      // Create the new cell element to be added.
20      var newCell = cell.clone();
21      if(!CKEDITOR.env.ie)
22        newCell.appendBogus();
23
24      if(insertBefore)
25        newCell.insertBefore(cell);
26      else
27        newCell.insertAfter(cell);
28    }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy