tinymce.full.js
function fixTableCellSelection() {
        function tableCellSelected(ed, rng, n, currentCell) {
          // The decision of when a table cell is selected is somewhat involved.  The fact that this code is
          // required is actually a pointer to the root cause of this bug. A cell is selected when the start
          // and end offsets are 0, the start container is a text, and the selection node is either a TR (most cases)
          // or the parent of the table (in the case of the selection containing the last cell of a table).
          var TEXT_NODE = 3, table = ed.dom.getParent(rng.startContainer, 'TABLE');
          var tableParent, allOfCellSelected, tableCellSelection;

          if (table) {
            tableParent = table.parentNode;
          }

          allOfCellSelected = rng.startContainer.nodeType == TEXT_NODE &&
            rng.startOffset === 0 &&
            rng.endOffset === 0 &&
            currentCell &&
            (n.nodeName == "TR" || n == tableParent);

          tableCellSelection = (n.nodeName == "TD" || n.nodeName == "TH") && !currentCell;

          return allOfCellSelected || tableCellSelection;
        }

        function fixSelection() {
          var rng = editor.selection.getRng();
          var n = editor.selection.getNode();
          var currentCell = editor.dom.getParent(rng.startContainer, 'TD,TH');

          if (!tableCellSelected(editor, rng, n, currentCell)) {
            return;
          }

          if (!currentCell) {
            currentCell = n;
          }

          // Get the very last node inside the table cell
          var end = currentCell.lastChild;
          while (end.lastChild) {
            end = end.lastChild;
          }

          // Select the entire table cell. Nothing outside of the table cell should be selected.
          if (end.nodeType == 3) {
            rng.setEnd(end, end.data.length);
            editor.selection.setRng(rng);
          }
        }

        editor.on('KeyDown', function () {
          fixSelection();
        });

        editor.on('MouseDown', function (e) {
          if (e.button != 2) {
            fixSelection();
          }
        });
      }
function fixTableCellSelection() {
        function tableCellSelected(ed, rng, n, currentCell) {
          // The decision of when a table cell is selected is somewhat involved.  The fact that this code is
          // required is actually a pointer to the root cause of this bug. A cell is selected when the start
          // and end offsets are 0, the start container is a text, and the selection node is either a TR (most cases)
          // or the parent of the table (in the case of the selection containing the last cell of a table).
          var TEXT_NODE = 3, table = ed.dom.getParent(rng.startContainer, 'TABLE');
          var tableParent, allOfCellSelected, tableCellSelection;

          if (table) {
            tableParent = table.parentNode;
          }

          allOfCellSelected = rng.startContainer.nodeType == TEXT_NODE &&
            rng.startOffset === 0 &&
            rng.endOffset === 0 &&
            currentCell &&
            (n.nodeName == "TR" || n == tableParent);

          tableCellSelection = (n.nodeName == "TD" || n.nodeName == "TH") && !currentCell;

          return allOfCellSelected || tableCellSelection;
        }

        function fixSelection() {
          var rng = editor.selection.getRng();
          var n = editor.selection.getNode();
          var currentCell = editor.dom.getParent(rng.startContainer, 'TD,TH');

          if (!tableCellSelected(editor, rng, n, currentCell)) {
            return;
          }

          if (!currentCell) {
            currentCell = n;
          }

          // Get the very last node inside the table cell
          var end = currentCell.lastChild;
          while (end.lastChild) {
            end = end.lastChild;
          }

          // Select the entire table cell. Nothing outside of the table cell should be selected.
          if (end.nodeType == 3) {
            rng.setEnd(end, end.data.length);
            editor.selection.setRng(rng);
          }
        }

        editor.on('KeyDown', function () {
          fixSelection();
        });

        editor.on('MouseDown', function (e) {
          if (e.button != 2) {
            fixSelection();
          }
        });
      }
function fixTableCellSelection ( ) { function tableCellSelected ( ed , rng , n , currentCell ) { // The decision of when a table cell is selected is somewhat involved.  The fact that this code is // required is actually a pointer to the root cause of this bug. A cell is selected when the start // and end offsets are 0, the start container is a text, and the selection node is either a TR (most cases) // or the parent of the table (in the case of the selection containing the last cell of a table). var TEXT_NODE = 3 , table = ed . dom . getParent ( rng . startContainer , 'TABLE' ) ; var tableParent , allOfCellSelected , tableCellSelection ; if ( table ) { tableParent = table . parentNode ; } allOfCellSelected = rng . startContainer . nodeType == TEXT_NODE && rng . startOffset === 0 && rng . endOffset === 0 && currentCell && ( n . nodeName == "TR" || n == tableParent ) ; tableCellSelection = ( n . nodeName == "TD" || n . nodeName == "TH" ) && ! currentCell ; return allOfCellSelected || tableCellSelection ; } function fixSelection ( ) { var rng = editor . selection . getRng ( ) ; var n = editor . selection . getNode ( ) ; var currentCell = editor . dom . getParent ( rng . startContainer , 'TD,TH' ) ; if ( ! tableCellSelected ( editor , rng , n , currentCell ) ) { return ; } if ( ! currentCell ) { currentCell = n ; } // Get the very last node inside the table cell var end = currentCell . lastChild ; while ( end . lastChild ) { end = end . lastChild ; } // Select the entire table cell. Nothing outside of the table cell should be selected. if ( end . nodeType == 3 ) { rng . setEnd ( end , end . data . length ) ; editor . selection . setRng ( rng ) ; } } editor . on ( 'KeyDown' , function ( ) { fixSelection ( ) ; } ) ; editor . on ( 'MouseDown' , function ( e ) { if ( e . button != 2 ) { fixSelection ( ) ; } } ) ; }
this nasty hack is here to work around some WebKit selection bugs.
this nasty hack is here to work around some WebKit selection bugs .