Skip to content
Permalink
Browse files

Merge branch 't/13388'

  • Loading branch information...
oleq committed Aug 12, 2015
2 parents f23ff0c + 5eda40f commit 730e54bb7c72f2fb1cd9c3f5bfb8f2670061e688
@@ -20,6 +20,7 @@ Fixed Issues:
* [#13465](http://dev.ckeditor.com/ticket/13465): Fixed: Error is thrown and widget is lost when drag&drop if it is the only content of the editor.
* [#13414](http://dev.ckeditor.com/ticket/13414): Fixed: Content auto paragraphing in a nested editable despite editor configuration.
* [#13429](http://dev.ckeditor.com/ticket/13429): Fixed: Wrong selection after content insertion by [Auto Embed](http://ckeditor.com/addon/autoembed) plugin.
* [#13388](http://dev.ckeditor.com/ticket/13388): Fixed: [Table Resize](http://ckeditor.com/addon/tableresize) integration with [Undo](http://ckeditor.com/addon/undo) is broken.

Other Changes:

@@ -210,7 +210,8 @@

function resizeColumn() {
var rtl = pillar.rtl,
cellsCount = rtl ? rightSideCells.length : leftSideCells.length;
cellsCount = rtl ? rightSideCells.length : leftSideCells.length,
cellsSaved = 0;

// Perform the actual resize to table cells, only for those by side of the pillar.
for ( var i = 0; i < cellsCount; i++ ) {
@@ -227,6 +228,12 @@
// If we're in the last cell, we need to resize the table as well
if ( tableWidth )
table.setStyle( 'width', pxUnit( tableWidth + sizeShift * ( rtl ? -1 : 1 ) ) );

// Cells resizing is asynchronous-y, so we have to use syncing
// to save snapshot only after all cells are resized. (#13388)
if ( ++cellsSaved == cellsCount ) {
editor.fire( 'saveSnapshot' );
}
}, 0, this, [
leftCell, leftCell && getWidth( leftCell ),
rightCell, rightCell && getWidth( rightCell ),
@@ -239,6 +246,8 @@
function onMouseDown( evt ) {
cancel( evt );

// Save editor's state before we do any magic with cells. (#13388)
editor.fire( 'saveSnapshot' );
resizeStart();

document.on( 'mouseup', onMouseUp, this );
@@ -0,0 +1,6 @@
<div id="editor">
</div>

<script>
CKEDITOR.replace( 'editor' );
</script>
@@ -0,0 +1,16 @@
@bender-ui: collapsed
@bender-tags: tc, 4.5.3, 13388
@bender-ckeditor-plugins: wysiwygarea, toolbar, table, tableresize, basicstyles, undo

1. Insert a table.
2. Type `1`.
3. Click in a focused cell.
4. Resize the left column.
5. Type `2`.
6. Resize the left column.
7. Type `3`.
8. Resize the whole table.

**Expected**: There should be 7 undo steps available. One for each action.

**Unexpected**: When undoing, a number is removed AND column changes size.
@@ -37,3 +37,13 @@ <h1>Foo</h1>
</tr>
</tbody>
</table>

<textarea id="undo">
&lt;table border="1"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
</textarea>
@@ -1,5 +1,5 @@
/* bender-tags: editor,unit */
/* bender-ckeditor-plugins: stylesheetparser,tableresize,wysiwygarea */
/* bender-ckeditor-plugins: stylesheetparser,tableresize,wysiwygarea,undo */

'use strict';

@@ -97,6 +97,9 @@ bender.editors = {
intable: {
name: 'intable',
creator: 'inline'
},
undo: {
name: 'undo'
}
};

@@ -186,5 +189,45 @@ bender.test( {
editor.editable().fire( 'mousemove', evt );

assert.isNull( wrapperTable.getCustomData( '_cke_table_pillars' ) );
},

// #13388.
'test undo/redo table resize': function() {
var editor = this.editors.undo,
doc = editor.document,
insideTable = doc.getElementsByTag( 'table' ).getItem( 0 );

init( insideTable, editor );

insideTable.findOne( 'td' ).setHtml( 'foo' );

resize( insideTable, function() {
resume( function() {
var table;

// Step 1: undo table resizing.
editor.execCommand( 'undo' );
table = doc.findOne( 'table' );
this.assertIsNotTouched( table, 'insideTable' );
// Contents of table cell should remain not undone.
assert.isInnerHtmlMatching( 'foo@', table.findOne( 'td' ).getHtml() );

// Step 2: undo text insert.
editor.execCommand( 'undo' );
// Bogus elements may be present.
assert.isInnerHtmlMatching( '@', doc.findOne( 'td' ).getHtml() );

// Get back to the "final" state with redo commands.
// Redo text insert.
editor.execCommand( 'redo' );
// Redo table resize.
editor.execCommand( 'redo' );

// Table should be resized.
this.assertIsResized( doc.findOne( 'table' ), 'insideTable' );
} );
} );

wait();
}
} );

0 comments on commit 730e54b

Please sign in to comment.
You can’t perform that action at this time.