X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=_source%2Fplugins%2Ftable%2Fdialogs%2Ftable.js;h=4675a0c6289f89ad0d218f392f8b8f5258cbbf1e;hb=c6e377a02b54abc07129d72b632763c727476a15;hp=2c02aa2dbba44d8e60c3d0395822adb8c539faff;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/plugins/table/dialogs/table.js b/_source/plugins/table/dialogs/table.js index 2c02aa2..4675a0c 100644 --- a/_source/plugins/table/dialogs/table.js +++ b/_source/plugins/table/dialogs/table.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -68,6 +68,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }, onOk : function() { + if ( this._.selectedElement ) + { + var selection = editor.getSelection(), + bms = editor.getSelection().createBookmarks(); + } + var table = this._.selectedElement || makeElement( 'table' ), me = this, data = {}; @@ -97,7 +103,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } } - // Modify the table headers. Depends on havint rows and cols generated + // Modify the table headers. Depends on having rows and cols generated // correctly so it can't be done in commit functions. // Should we make a ? @@ -115,8 +121,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( th.type == CKEDITOR.NODE_ELEMENT ) { th.renameNode( 'th' ); - if ( !i ) - th.setAttribute( 'scope', 'col' ); + th.setAttribute( 'scope', 'col' ); } } thead.append( theRow.remove() ); @@ -149,24 +154,24 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Should we make all first cells in a row TH? if ( !this.hasColumnHeaders && ( headers == 'col' || headers == 'both' ) ) { - for( row = 0 ; row < table.$.rows.length ; row++ ) + for ( row = 0 ; row < table.$.rows.length ; row++ ) { newCell = new CKEDITOR.dom.element( table.$.rows[ row ].cells[ 0 ] ); newCell.renameNode( 'th' ); - newCell.setAttribute( 'scope', 'col' ); + newCell.setAttribute( 'scope', 'row' ); } } // Should we make all first TH-cells in a row make TD? If 'yes' we do it the other way round :-) if ( ( this.hasColumnHeaders ) && !( headers == 'col' || headers == 'both' ) ) { - for( i = 0 ; i < table.$.rows.length ; i++ ) + for ( i = 0 ; i < table.$.rows.length ; i++ ) { row = new CKEDITOR.dom.element( table.$.rows[i] ); if ( row.getParent().getName() == 'tbody' ) { newCell = new CKEDITOR.dom.element( row.$.cells[0] ); - newCell.renameNode( 'td'); + newCell.renameNode( 'td' ); newCell.removeAttribute( 'scope' ); } } @@ -175,22 +180,28 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Set the width and height. var styles = []; if ( info.txtHeight ) - styles.push( 'height:' + info.txtHeight + 'px' ); + table.setStyle( 'height', CKEDITOR.tools.cssLength( info.txtHeight ) ); + else + table.removeStyle( 'height' ); + if ( info.txtWidth ) { var type = info.cmbWidthType || 'pixels'; - styles.push( 'width:' + info.txtWidth + ( type == 'pixels' ? 'px' : '%' ) ); + table.setStyle( 'width', info.txtWidth + ( type == 'pixels' ? 'px' : '%' ) ); } - styles = styles.join( ';' ); - if ( styles ) - table.$.style.cssText = styles; else + table.removeStyle( 'width' ); + + if ( !table.getAttribute( 'style' ) ) table.removeAttribute( 'style' ); } // Insert the table element if we're creating one. if ( !this._.selectedElement ) editor.insertElement( table ); + // Properly restore the selection inside table. (#4822) + else + selection.selectBookmarks( bms ); return true; }, @@ -369,6 +380,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var widthMatch = widthPattern.exec( selectedTable.$.style.width ); if ( widthMatch ) this.setValue( widthMatch[1] ); + else + this.setValue( '' ); }, commit : commitValue },