2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
8 function removeRawAttribute( $node, attr )
\r
10 if ( CKEDITOR.env.ie )
\r
11 $node.removeAttribute( attr );
\r
13 delete $node[ attr ];
\r
16 var cellNodeRegex = /^(?:td|th)$/;
\r
18 function getSelectedCells( selection )
\r
20 // Walker will try to split text nodes, which will make the current selection
\r
21 // invalid. So save bookmarks before doing anything.
\r
22 var bookmarks = selection.createBookmarks();
\r
24 var ranges = selection.getRanges();
\r
28 function moveOutOfCellGuard( node )
\r
30 // Apply to the first cell only.
\r
31 if ( retval.length > 0 )
\r
34 // If we are exiting from the first </td>, then the td should definitely be
\r
36 if ( node.type == CKEDITOR.NODE_ELEMENT && cellNodeRegex.test( node.getName() )
\r
37 && !node.getCustomData( 'selected_cell' ) )
\r
39 CKEDITOR.dom.element.setMarker( database, node, 'selected_cell', true );
\r
40 retval.push( node );
\r
44 for ( var i = 0 ; i < ranges.length ; i++ )
\r
46 var range = ranges[ i ];
\r
48 if ( range.collapsed )
\r
50 // Walker does not handle collapsed ranges yet - fall back to old API.
\r
51 var startNode = range.getCommonAncestor();
\r
52 var nearestCell = startNode.getAscendant( 'td', true ) || startNode.getAscendant( 'th', true );
\r
54 retval.push( nearestCell );
\r
58 var walker = new CKEDITOR.dom.walker( range );
\r
60 walker.guard = moveOutOfCellGuard;
\r
62 while ( ( node = walker.next() ) )
\r
64 // If may be possible for us to have a range like this:
\r
65 // <td>^1</td><td>^2</td>
\r
66 // The 2nd td shouldn't be included.
\r
68 // So we have to take care to include a td we've entered only when we've
\r
69 // walked into its children.
\r
71 var parent = node.getParent();
\r
72 if ( parent && cellNodeRegex.test( parent.getName() ) && !parent.getCustomData( 'selected_cell' ) )
\r
74 CKEDITOR.dom.element.setMarker( database, parent, 'selected_cell', true );
\r
75 retval.push( parent );
\r
81 CKEDITOR.dom.element.clearAllMarkers( database );
\r
83 // Restore selection position.
\r
84 selection.selectBookmarks( bookmarks );
\r
89 function clearRow( $tr )
\r
91 // Get the array of row's cells.
\r
92 var $cells = $tr.cells;
\r
95 for ( var i = 0 ; i < $cells.length ; i++ )
\r
97 $cells[ i ].innerHTML = '';
\r
99 if ( !CKEDITOR.env.ie )
\r
100 ( new CKEDITOR.dom.element( $cells[ i ] ) ).appendBogus();
\r
104 function insertRow( selection, insertBefore )
\r
106 // Get the row where the selection is placed in.
\r
107 var row = selection.getStartElement().getAscendant( 'tr' );
\r
111 // Create a clone of the row.
\r
112 var newRow = row.clone( true );
\r
114 // Insert the new row before of it.
\r
115 newRow.insertBefore( row );
\r
117 // Clean one of the rows to produce the illusion of inserting an empty row
\r
118 // before or after.
\r
119 clearRow( insertBefore ? newRow.$ : row.$ );
\r
122 function deleteRows( selectionOrRow )
\r
124 if ( selectionOrRow instanceof CKEDITOR.dom.selection )
\r
126 var cells = getSelectedCells( selectionOrRow ),
\r
127 cellsCount = cells.length,
\r
133 // Queue up the rows - it's possible and likely that we have duplicates.
\r
134 for ( var i = 0 ; i < cellsCount ; i++ )
\r
136 var row = cells[ i ].getParent(),
\r
137 rowIndex = row.$.rowIndex;
\r
139 !i && ( previousRowIndex = rowIndex - 1 );
\r
140 rowsToDelete[ rowIndex ] = row;
\r
141 i == cellsCount - 1 && ( nextRowIndex = rowIndex + 1 );
\r
144 var table = row.getAscendant( 'table' ),
\r
145 rows = table.$.rows,
\r
146 rowCount = rows.length;
\r
148 // Where to put the cursor after rows been deleted?
\r
149 // 1. Into next sibling row if any;
\r
150 // 2. Into previous sibling row if any;
\r
151 // 3. Into table's parent element if it's the very last row.
\r
152 cursorPosition = new CKEDITOR.dom.element(
\r
153 nextRowIndex < rowCount && table.$.rows[ nextRowIndex ] ||
\r
154 previousRowIndex > 0 && table.$.rows[ previousRowIndex ] ||
\r
155 table.$.parentNode );
\r
157 for ( i = rowsToDelete.length ; i >= 0 ; i-- )
\r
159 if ( rowsToDelete[ i ] )
\r
160 deleteRows( rowsToDelete[ i ] );
\r
163 return cursorPosition;
\r
165 else if ( selectionOrRow instanceof CKEDITOR.dom.element )
\r
167 table = selectionOrRow.getAscendant( 'table' );
\r
169 if ( table.$.rows.length == 1 )
\r
172 selectionOrRow.remove();
\r
178 function insertColumn( selection, insertBefore )
\r
180 // Get the cell where the selection is placed in.
\r
181 var startElement = selection.getStartElement();
\r
182 var cell = startElement.getAscendant( 'td', true ) || startElement.getAscendant( 'th', true );
\r
187 // Get the cell's table.
\r
188 var table = cell.getAscendant( 'table' );
\r
189 var cellIndex = cell.$.cellIndex;
\r
191 // Loop through all rows available in the table.
\r
192 for ( var i = 0 ; i < table.$.rows.length ; i++ )
\r
194 var $row = table.$.rows[ i ];
\r
196 // If the row doesn't have enough cells, ignore it.
\r
197 if ( $row.cells.length < ( cellIndex + 1 ) )
\r
200 cell = new CKEDITOR.dom.element( $row.cells[ cellIndex ].cloneNode( false ) );
\r
202 if ( !CKEDITOR.env.ie )
\r
203 cell.appendBogus();
\r
205 // Get back the currently selected cell.
\r
206 var baseCell = new CKEDITOR.dom.element( $row.cells[ cellIndex ] );
\r
207 if ( insertBefore )
\r
208 cell.insertBefore( baseCell );
\r
210 cell.insertAfter( baseCell );
\r
214 function deleteColumns( selectionOrCell )
\r
216 if ( selectionOrCell instanceof CKEDITOR.dom.selection )
\r
218 var colsToDelete = getSelectedCells( selectionOrCell );
\r
219 for ( var i = colsToDelete.length ; i >= 0 ; i-- )
\r
221 if ( colsToDelete[ i ] )
\r
222 deleteColumns( colsToDelete[ i ] );
\r
225 else if ( selectionOrCell instanceof CKEDITOR.dom.element )
\r
227 // Get the cell's table.
\r
228 var table = selectionOrCell.getAscendant( 'table' );
\r
230 // Get the cell index.
\r
231 var cellIndex = selectionOrCell.$.cellIndex;
\r
234 * Loop through all rows from down to up, coz it's possible that some rows
\r
237 for ( i = table.$.rows.length - 1 ; i >= 0 ; i-- )
\r
240 var row = new CKEDITOR.dom.element( table.$.rows[ i ] );
\r
242 // If the cell to be removed is the first one and the row has just one cell.
\r
243 if ( !cellIndex && row.$.cells.length == 1 )
\r
249 // Else, just delete the cell.
\r
250 if ( row.$.cells[ cellIndex ] )
\r
251 row.$.removeChild( row.$.cells[ cellIndex ] );
\r
256 function insertCell( selection, insertBefore )
\r
258 var startElement = selection.getStartElement();
\r
259 var cell = startElement.getAscendant( 'td', true ) || startElement.getAscendant( 'th', true );
\r
264 // Create the new cell element to be added.
\r
265 var newCell = cell.clone();
\r
266 if ( !CKEDITOR.env.ie )
\r
267 newCell.appendBogus();
\r
269 if ( insertBefore )
\r
270 newCell.insertBefore( cell );
\r
272 newCell.insertAfter( cell );
\r
275 function deleteCells( selectionOrCell )
\r
277 if ( selectionOrCell instanceof CKEDITOR.dom.selection )
\r
279 var cellsToDelete = getSelectedCells( selectionOrCell );
\r
280 for ( var i = cellsToDelete.length - 1 ; i >= 0 ; i-- )
\r
281 deleteCells( cellsToDelete[ i ] );
\r
283 else if ( selectionOrCell instanceof CKEDITOR.dom.element )
\r
285 if ( selectionOrCell.getParent().getChildCount() == 1 )
\r
286 selectionOrCell.getParent().remove();
\r
288 selectionOrCell.remove();
\r
292 // Remove filler at end and empty spaces around the cell content.
\r
293 function trimCell( cell )
\r
295 var bogus = cell.getBogus();
\r
296 bogus && bogus.remove();
\r
300 function placeCursorInCell( cell, placeAtEnd )
\r
302 var range = new CKEDITOR.dom.range( cell.getDocument() );
\r
303 if ( !range[ 'moveToElementEdit' + ( placeAtEnd ? 'End' : 'Start' ) ]( cell ) )
\r
305 range.selectNodeContents( cell );
\r
306 range.collapse( placeAtEnd ? false : true );
\r
308 range.select( true );
\r
311 function buildTableMap( table )
\r
314 var aRows = table.$.rows ;
\r
316 // Row and Column counters.
\r
321 for ( var i = 0 ; i < aRows.length ; i++ )
\r
324 !aMap[r] && ( aMap[r] = [] );
\r
328 for ( var j = 0 ; j < aRows[i].cells.length ; j++ )
\r
330 var oCell = aRows[i].cells[j] ;
\r
333 while ( aMap[r][c] )
\r
336 var iColSpan = isNaN( oCell.colSpan ) ? 1 : oCell.colSpan ;
\r
337 var iRowSpan = isNaN( oCell.rowSpan ) ? 1 : oCell.rowSpan ;
\r
339 for ( var rs = 0 ; rs < iRowSpan ; rs++ )
\r
341 if ( !aMap[r + rs] )
\r
342 aMap[r + rs] = new Array() ;
\r
344 for ( var cs = 0 ; cs < iColSpan ; cs++ )
\r
346 aMap[r + rs][c + cs] = aRows[i].cells[j] ;
\r
350 c += iColSpan - 1 ;
\r
356 function cellInRow( tableMap, rowIndex, cell )
\r
358 var oRow = tableMap[ rowIndex ];
\r
359 if ( typeof cell == 'undefined' )
\r
362 for ( var c = 0 ; oRow && c < oRow.length ; c++ )
\r
364 if ( cell.is && oRow[c] == cell.$ )
\r
366 else if ( c == cell )
\r
367 return new CKEDITOR.dom.element( oRow[ c ] );
\r
369 return cell.is ? -1 : null;
\r
372 function cellInCol( tableMap, colIndex, cell )
\r
375 for ( var r = 0; r < tableMap.length; r++ )
\r
377 var row = tableMap[ r ];
\r
378 if ( typeof cell == 'undefined' )
\r
379 oCol.push( row[ colIndex ] );
\r
380 else if ( cell.is && row[ colIndex ] == cell.$ )
\r
382 else if ( r == cell )
\r
383 return new CKEDITOR.dom.element( row[ colIndex ] );
\r
386 return ( typeof cell == 'undefined' )? oCol : cell.is ? -1 : null;
\r
389 function mergeCells( selection, mergeDirection, isDetect )
\r
391 var cells = getSelectedCells( selection );
\r
393 // Invalid merge request if:
\r
394 // 1. In batch mode despite that less than two selected.
\r
395 // 2. In solo mode while not exactly only one selected.
\r
396 // 3. Cells distributed in different table groups (e.g. from both thead and tbody).
\r
397 var commonAncestor;
\r
398 if ( ( mergeDirection ? cells.length != 1 : cells.length < 2 )
\r
399 || ( commonAncestor = selection.getCommonAncestor() )
\r
400 && commonAncestor.type == CKEDITOR.NODE_ELEMENT
\r
401 && commonAncestor.is( 'table' ) )
\r
407 firstCell = cells[ 0 ],
\r
408 table = firstCell.getAscendant( 'table' ),
\r
409 map = buildTableMap( table ),
\r
410 mapHeight = map.length,
\r
411 mapWidth = map[ 0 ].length,
\r
412 startRow = firstCell.getParent().$.rowIndex,
\r
413 startColumn = cellInRow( map, startRow, firstCell );
\r
415 if ( mergeDirection )
\r
421 map[ mergeDirection == 'up' ?
\r
423 mergeDirection == 'down' ? ( startRow + 1 ) : startRow ] [
\r
424 mergeDirection == 'left' ?
\r
425 ( startColumn - 1 ):
\r
426 mergeDirection == 'right' ? ( startColumn + 1 ) : startColumn ];
\r
434 // 1. No cell could be merged.
\r
435 // 2. Same cell actually.
\r
436 if ( !targetCell || firstCell.$ == targetCell )
\r
439 // Sort in map order regardless of the DOM sequence.
\r
440 cells[ ( mergeDirection == 'up' || mergeDirection == 'left' ) ?
\r
441 'unshift' : 'push' ]( new CKEDITOR.dom.element( targetCell ) );
\r
444 // Start from here are merging way ignorance (merge up/right, batch merge).
\r
445 var doc = firstCell.getDocument(),
\r
446 lastRowIndex = startRow,
\r
449 // Use a documentFragment as buffer when appending cell contents.
\r
450 frag = !isDetect && new CKEDITOR.dom.documentFragment( doc ),
\r
453 for ( var i = 0; i < cells.length; i++ )
\r
457 var tr = cell.getParent(),
\r
458 cellFirstChild = cell.getFirst(),
\r
459 colSpan = cell.$.colSpan,
\r
460 rowSpan = cell.$.rowSpan,
\r
461 rowIndex = tr.$.rowIndex,
\r
462 colIndex = cellInRow( map, rowIndex, cell );
\r
464 // Accumulated the actual places taken by all selected cells.
\r
465 dimension += colSpan * rowSpan;
\r
466 // Accumulated the maximum virtual spans from column and row.
\r
467 totalColSpan = Math.max( totalColSpan, colIndex - startColumn + colSpan ) ;
\r
468 totalRowSpan = Math.max( totalRowSpan, rowIndex - startRow + rowSpan );
\r
472 // Trim all cell fillers and check to remove empty cells.
\r
473 if ( trimCell( cell ), cell.getChildren().count() )
\r
475 // Merge vertically cells as two separated paragraphs.
\r
476 if ( rowIndex != lastRowIndex
\r
478 && !( cellFirstChild.isBlockBoundary
\r
479 && cellFirstChild.isBlockBoundary( { br : 1 } ) ) )
\r
481 var last = frag.getLast( CKEDITOR.dom.walker.whitespaces( true ) );
\r
482 if ( last && !( last.is && last.is( 'br' ) ) )
\r
483 frag.append( new CKEDITOR.dom.element( 'br' ) );
\r
486 cell.moveChildren( frag );
\r
488 i ? cell.remove() : cell.setHtml( '' );
\r
490 lastRowIndex = rowIndex;
\r
495 frag.moveChildren( firstCell );
\r
497 if ( !CKEDITOR.env.ie )
\r
498 firstCell.appendBogus();
\r
500 if ( totalColSpan >= mapWidth )
\r
501 firstCell.removeAttribute( 'rowSpan' );
\r
503 firstCell.$.rowSpan = totalRowSpan;
\r
505 if ( totalRowSpan >= mapHeight )
\r
506 firstCell.removeAttribute( 'colSpan' );
\r
508 firstCell.$.colSpan = totalColSpan;
\r
510 // Swip empty <tr> left at the end of table due to the merging.
\r
511 var trs = new CKEDITOR.dom.nodeList( table.$.rows ),
\r
512 count = trs.count();
\r
514 for ( i = count - 1; i >= 0; i-- )
\r
516 var tailTr = trs.getItem( i );
\r
517 if ( !tailTr.$.cells.length )
\r
527 // Be able to merge cells only if actual dimension of selected
\r
528 // cells equals to the caculated rectangle.
\r
530 return ( totalRowSpan * totalColSpan ) == dimension;
\r
533 function verticalSplitCell ( selection, isDetect )
\r
535 var cells = getSelectedCells( selection );
\r
536 if ( cells.length > 1 )
\r
538 else if ( isDetect )
\r
541 var cell = cells[ 0 ],
\r
542 tr = cell.getParent(),
\r
543 table = tr.getAscendant( 'table' ),
\r
544 map = buildTableMap( table ),
\r
545 rowIndex = tr.$.rowIndex,
\r
546 colIndex = cellInRow( map, rowIndex, cell ),
\r
547 rowSpan = cell.$.rowSpan,
\r
555 newRowSpan = Math.ceil( rowSpan / 2 );
\r
556 newCellRowSpan = Math.floor( rowSpan / 2 );
\r
557 newRowIndex = rowIndex + newRowSpan;
\r
558 var newCellTr = new CKEDITOR.dom.element( table.$.rows[ newRowIndex ] ),
\r
559 newCellRow = cellInRow( map, newRowIndex ),
\r
562 newCell = cell.clone();
\r
564 // Figure out where to insert the new cell by checking the vitual row.
\r
565 for ( var c = 0; c < newCellRow.length; c++ )
\r
567 candidateCell = newCellRow[ c ];
\r
568 // Catch first cell actually following the column.
\r
569 if ( candidateCell.parentNode == newCellTr.$
\r
572 newCell.insertBefore( new CKEDITOR.dom.element( candidateCell ) );
\r
576 candidateCell = null;
\r
579 // The destination row is empty, append at will.
\r
580 if ( !candidateCell )
\r
581 newCellTr.append( newCell, true );
\r
585 newCellRowSpan = newRowSpan = 1;
\r
587 newCellTr = tr.clone();
\r
588 newCellTr.insertAfter( tr );
\r
589 newCellTr.append( newCell = cell.clone() );
\r
591 var cellsInSameRow = cellInRow( map, rowIndex );
\r
592 for ( var i = 0; i < cellsInSameRow.length; i++ )
\r
593 cellsInSameRow[ i ].rowSpan++;
\r
596 if ( !CKEDITOR.env.ie )
\r
597 newCell.appendBogus();
\r
599 cell.$.rowSpan = newRowSpan;
\r
600 newCell.$.rowSpan = newCellRowSpan;
\r
601 if ( newRowSpan == 1 )
\r
602 cell.removeAttribute( 'rowSpan' );
\r
603 if ( newCellRowSpan == 1 )
\r
604 newCell.removeAttribute( 'rowSpan' );
\r
609 function horizontalSplitCell( selection, isDetect )
\r
611 var cells = getSelectedCells( selection );
\r
612 if ( cells.length > 1 )
\r
614 else if ( isDetect )
\r
617 var cell = cells[ 0 ],
\r
618 tr = cell.getParent(),
\r
619 table = tr.getAscendant( 'table' ),
\r
620 map = buildTableMap( table ),
\r
621 rowIndex = tr.$.rowIndex,
\r
622 colIndex = cellInRow( map, rowIndex, cell ),
\r
623 colSpan = cell.$.colSpan,
\r
630 newColSpan = Math.ceil( colSpan / 2 );
\r
631 newCellColSpan = Math.floor( colSpan / 2 );
\r
635 newCellColSpan = newColSpan = 1;
\r
636 var cellsInSameCol = cellInCol( map, colIndex );
\r
637 for ( var i = 0; i < cellsInSameCol.length; i++ )
\r
638 cellsInSameCol[ i ].colSpan++;
\r
640 newCell = cell.clone();
\r
641 newCell.insertAfter( cell );
\r
642 if ( !CKEDITOR.env.ie )
\r
643 newCell.appendBogus();
\r
645 cell.$.colSpan = newColSpan;
\r
646 newCell.$.colSpan = newCellColSpan;
\r
647 if ( newColSpan == 1 )
\r
648 cell.removeAttribute( 'colSpan' );
\r
649 if ( newCellColSpan == 1 )
\r
650 newCell.removeAttribute( 'colSpan' );
\r
654 // Context menu on table caption incorrect (#3834)
\r
655 var contextMenuTags = { thead : 1, tbody : 1, tfoot : 1, td : 1, tr : 1, th : 1 };
\r
657 CKEDITOR.plugins.tabletools =
\r
659 init : function( editor )
\r
661 var lang = editor.lang.table;
\r
663 editor.addCommand( 'cellProperties', new CKEDITOR.dialogCommand( 'cellProperties' ) );
\r
664 CKEDITOR.dialog.add( 'cellProperties', this.path + 'dialogs/tableCell.js' );
\r
666 editor.addCommand( 'tableDelete',
\r
668 exec : function( editor )
\r
670 var selection = editor.getSelection();
\r
671 var startElement = selection && selection.getStartElement();
\r
672 var table = startElement && startElement.getAscendant( 'table', true );
\r
677 // Maintain the selection point at where the table was deleted.
\r
678 selection.selectElement( table );
\r
679 var range = selection.getRanges()[0];
\r
681 selection.selectRanges( [ range ] );
\r
683 // If the table's parent has only one child, remove it as well.
\r
684 if ( table.getParent().getChildCount() == 1 )
\r
685 table.getParent().remove();
\r
691 editor.addCommand( 'rowDelete',
\r
693 exec : function( editor )
\r
695 var selection = editor.getSelection();
\r
696 placeCursorInCell( deleteRows( selection ) );
\r
700 editor.addCommand( 'rowInsertBefore',
\r
702 exec : function( editor )
\r
704 var selection = editor.getSelection();
\r
705 insertRow( selection, true );
\r
709 editor.addCommand( 'rowInsertAfter',
\r
711 exec : function( editor )
\r
713 var selection = editor.getSelection();
\r
714 insertRow( selection );
\r
718 editor.addCommand( 'columnDelete',
\r
720 exec : function( editor )
\r
722 var selection = editor.getSelection();
\r
723 deleteColumns( selection );
\r
727 editor.addCommand( 'columnInsertBefore',
\r
729 exec : function( editor )
\r
731 var selection = editor.getSelection();
\r
732 insertColumn( selection, true );
\r
736 editor.addCommand( 'columnInsertAfter',
\r
738 exec : function( editor )
\r
740 var selection = editor.getSelection();
\r
741 insertColumn( selection );
\r
745 editor.addCommand( 'cellDelete',
\r
747 exec : function( editor )
\r
749 var selection = editor.getSelection();
\r
750 deleteCells( selection );
\r
754 editor.addCommand( 'cellMerge',
\r
756 exec : function( editor )
\r
758 placeCursorInCell( mergeCells( editor.getSelection() ), true );
\r
762 editor.addCommand( 'cellMergeRight',
\r
764 exec : function( editor )
\r
766 placeCursorInCell( mergeCells( editor.getSelection(), 'right' ), true );
\r
770 editor.addCommand( 'cellMergeDown',
\r
772 exec : function( editor )
\r
774 placeCursorInCell( mergeCells( editor.getSelection(), 'down' ), true );
\r
778 editor.addCommand( 'cellVerticalSplit',
\r
780 exec : function( editor )
\r
782 placeCursorInCell( verticalSplitCell( editor.getSelection() ) );
\r
786 editor.addCommand( 'cellHorizontalSplit',
\r
788 exec : function( editor )
\r
790 placeCursorInCell( horizontalSplitCell( editor.getSelection() ) );
\r
794 editor.addCommand( 'cellInsertBefore',
\r
796 exec : function( editor )
\r
798 var selection = editor.getSelection();
\r
799 insertCell( selection, true );
\r
803 editor.addCommand( 'cellInsertAfter',
\r
805 exec : function( editor )
\r
807 var selection = editor.getSelection();
\r
808 insertCell( selection );
\r
812 // If the "menu" plugin is loaded, register the menu items.
\r
813 if ( editor.addMenuItems )
\r
815 editor.addMenuItems(
\r
819 label : lang.cell.menu,
\r
820 group : 'tablecell',
\r
822 getItems : function()
\r
824 var selection = editor.getSelection(),
\r
825 cells = getSelectedCells( selection );
\r
827 tablecell_insertBefore : CKEDITOR.TRISTATE_OFF,
\r
828 tablecell_insertAfter : CKEDITOR.TRISTATE_OFF,
\r
829 tablecell_delete : CKEDITOR.TRISTATE_OFF,
\r
830 tablecell_merge : mergeCells( selection, null, true ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
\r
831 tablecell_merge_right : mergeCells( selection, 'right', true ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
\r
832 tablecell_merge_down : mergeCells( selection, 'down', true ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
\r
833 tablecell_split_vertical : verticalSplitCell( selection, true ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
\r
834 tablecell_split_horizontal : horizontalSplitCell( selection, true ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
\r
835 tablecell_properties : cells.length > 0 ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED
\r
840 tablecell_insertBefore :
\r
842 label : lang.cell.insertBefore,
\r
843 group : 'tablecell',
\r
844 command : 'cellInsertBefore',
\r
848 tablecell_insertAfter :
\r
850 label : lang.cell.insertAfter,
\r
851 group : 'tablecell',
\r
852 command : 'cellInsertAfter',
\r
858 label : lang.cell.deleteCell,
\r
859 group : 'tablecell',
\r
860 command : 'cellDelete',
\r
866 label : lang.cell.merge,
\r
867 group : 'tablecell',
\r
868 command : 'cellMerge',
\r
872 tablecell_merge_right :
\r
874 label : lang.cell.mergeRight,
\r
875 group : 'tablecell',
\r
876 command : 'cellMergeRight',
\r
880 tablecell_merge_down :
\r
882 label : lang.cell.mergeDown,
\r
883 group : 'tablecell',
\r
884 command : 'cellMergeDown',
\r
888 tablecell_split_horizontal :
\r
890 label : lang.cell.splitHorizontal,
\r
891 group : 'tablecell',
\r
892 command : 'cellHorizontalSplit',
\r
896 tablecell_split_vertical :
\r
898 label : lang.cell.splitVertical,
\r
899 group : 'tablecell',
\r
900 command : 'cellVerticalSplit',
\r
904 tablecell_properties :
\r
906 label : lang.cell.title,
\r
907 group : 'tablecellproperties',
\r
908 command : 'cellProperties',
\r
914 label : lang.row.menu,
\r
915 group : 'tablerow',
\r
917 getItems : function()
\r
920 tablerow_insertBefore : CKEDITOR.TRISTATE_OFF,
\r
921 tablerow_insertAfter : CKEDITOR.TRISTATE_OFF,
\r
922 tablerow_delete : CKEDITOR.TRISTATE_OFF
\r
927 tablerow_insertBefore :
\r
929 label : lang.row.insertBefore,
\r
930 group : 'tablerow',
\r
931 command : 'rowInsertBefore',
\r
935 tablerow_insertAfter :
\r
937 label : lang.row.insertAfter,
\r
938 group : 'tablerow',
\r
939 command : 'rowInsertAfter',
\r
945 label : lang.row.deleteRow,
\r
946 group : 'tablerow',
\r
947 command : 'rowDelete',
\r
953 label : lang.column.menu,
\r
954 group : 'tablecolumn',
\r
956 getItems : function()
\r
959 tablecolumn_insertBefore : CKEDITOR.TRISTATE_OFF,
\r
960 tablecolumn_insertAfter : CKEDITOR.TRISTATE_OFF,
\r
961 tablecolumn_delete : CKEDITOR.TRISTATE_OFF
\r
966 tablecolumn_insertBefore :
\r
968 label : lang.column.insertBefore,
\r
969 group : 'tablecolumn',
\r
970 command : 'columnInsertBefore',
\r
974 tablecolumn_insertAfter :
\r
976 label : lang.column.insertAfter,
\r
977 group : 'tablecolumn',
\r
978 command : 'columnInsertAfter',
\r
982 tablecolumn_delete :
\r
984 label : lang.column.deleteColumn,
\r
985 group : 'tablecolumn',
\r
986 command : 'columnDelete',
\r
992 // If the "contextmenu" plugin is laoded, register the listeners.
\r
993 if ( editor.contextMenu )
\r
995 editor.contextMenu.addListener( function( element, selection )
\r
1002 if ( element.getName() in contextMenuTags )
\r
1005 tablecell : CKEDITOR.TRISTATE_OFF,
\r
1006 tablerow : CKEDITOR.TRISTATE_OFF,
\r
1007 tablecolumn : CKEDITOR.TRISTATE_OFF
\r
1010 element = element.getParent();
\r
1018 getSelectedCells : getSelectedCells
\r
1021 CKEDITOR.plugins.add( 'tabletools', CKEDITOR.plugins.tabletools );
\r