From 4ca54f1ee3069302df3c10cf9073ef26e4b752ba Mon Sep 17 00:00:00 2001 From: Karol Dawidziuk Date: Tue, 14 Jun 2022 16:29:48 +0200 Subject: [PATCH 1/7] Set higher priority to invoke command before undo plugin --- plugins/tableselection/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tableselection/plugin.js b/plugins/tableselection/plugin.js index acf0820fa17..f6a046ebe3b 100644 --- a/plugins/tableselection/plugin.js +++ b/plugins/tableselection/plugin.js @@ -922,7 +922,7 @@ if ( CKEDITOR.tools.array.indexOf( cmds, evt.data.name ) !== -1 ) { callback( editor, evt.data ); } - } ); + }, null, null, 9 ); } /** From 989cce27286bd8a02ac85b660d18b03b313d5584 Mon Sep 17 00:00:00 2001 From: Karol Dawidziuk Date: Tue, 14 Jun 2022 16:31:59 +0200 Subject: [PATCH 2/7] Add unit test --- tests/plugins/tabletools/tabletools.html | 45 ++++++++++++++++++++++++ tests/plugins/tabletools/tabletools.js | 27 ++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/tests/plugins/tabletools/tabletools.html b/tests/plugins/tabletools/tabletools.html index 15d0ef1241b..e9f45e59210 100644 --- a/tests/plugins/tabletools/tabletools.html +++ b/tests/plugins/tabletools/tabletools.html @@ -1585,4 +1585,49 @@ + +
diff --git a/tests/plugins/tabletools/tabletools.js b/tests/plugins/tabletools/tabletools.js index 05ae8da51b2..fce96c71818 100644 --- a/tests/plugins/tabletools/tabletools.js +++ b/tests/plugins/tabletools/tabletools.js @@ -262,6 +262,33 @@ bot.setHtmlWithSelection( source ); assert.beautified.html( expected, bot.getData( true ) ); } ); + }, + + 'test merge cells with a rowspan should create undo step': function() { + + bender.editorBot.create( { + name: 'editor_merge_rowspanned_cells', + config: { + plugins: 'undo,table,tableselection' + } + }, function( bot ) { + bender.tools.ignoreUnsupportedEnvironment( 'tableselection' ); + + var editor = bot.editor; + + bender.tools.testInputOut( 'merge-rowspanned-cells', function( source, expected ) { + bot.setHtmlWithSelection( source ); + bot.execCommand( 'cellMerge' ); + + var output = bot.getData( true ), + undo = editor.getCommand( 'undo' ); + + output = output.replace( /\u00a0/g, ' ' ); + + assert.areSame( bender.tools.compatHtml( expected ), output ); + assert.isTrue( undo.state === CKEDITOR.TRISTATE_OFF ); + } ); + } ); } } ); } )(); From 80a58379d2181eca451699c6c051eeefd9c5fadd Mon Sep 17 00:00:00 2001 From: Karol Dawidziuk Date: Tue, 14 Jun 2022 16:32:13 +0200 Subject: [PATCH 3/7] Add manual test --- .../plugins/tabletools/manual/mergecells.html | 30 +++++++++++++++++++ tests/plugins/tabletools/manual/mergecells.md | 11 +++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/plugins/tabletools/manual/mergecells.html create mode 100644 tests/plugins/tabletools/manual/mergecells.md diff --git a/tests/plugins/tabletools/manual/mergecells.html b/tests/plugins/tabletools/manual/mergecells.html new file mode 100644 index 00000000000..d002b5ceed6 --- /dev/null +++ b/tests/plugins/tabletools/manual/mergecells.html @@ -0,0 +1,30 @@ +
+ + + + + + + + + + + + + + + + + + + + + +
   
  1
 1
 1
+
+ + diff --git a/tests/plugins/tabletools/manual/mergecells.md b/tests/plugins/tabletools/manual/mergecells.md new file mode 100644 index 00000000000..61bb8efe018 --- /dev/null +++ b/tests/plugins/tabletools/manual/mergecells.md @@ -0,0 +1,11 @@ +@bender-tags: 4.19.1, bug, 4284 +@bender-ui: collapsed +@bender-ckeditor-plugins: wysiwygarea, toolbar, undo, tableselection + +1. Open console. +2. Select column with a rowspanned cell and cells containing `1` character. +3. Open context menu and choose "Cell" -> "Merge cells" option. + +**Expected:** Cells are merged, undo step is created and there is error in the console. + +**Unexpected:** Cells are merged, an error is thrown and no undo step is created. From 8b8fc260afefda69f8424c0e050dd08a9c8801ef Mon Sep 17 00:00:00 2001 From: Karol Dawidziuk Date: Wed, 22 Jun 2022 08:31:22 +0200 Subject: [PATCH 4/7] Add comment with issue reference --- plugins/tableselection/plugin.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/tableselection/plugin.js b/plugins/tableselection/plugin.js index f6a046ebe3b..4c553323235 100644 --- a/plugins/tableselection/plugin.js +++ b/plugins/tableselection/plugin.js @@ -921,7 +921,10 @@ editor.on( 'afterCommandExec', function( evt ) { if ( CKEDITOR.tools.array.indexOf( cmds, evt.data.name ) !== -1 ) { callback( editor, evt.data ); + } + // This listener is connected with undo plugin listener and require a higher priority + // than the listener in undo plugin to create a correct undo step (#4284). }, null, null, 9 ); } From dbf396bc488e36a2e1e17e91c511f8277ec6ccd9 Mon Sep 17 00:00:00 2001 From: Karol Dawidziuk Date: Wed, 22 Jun 2022 08:31:53 +0200 Subject: [PATCH 5/7] Remove unnecessary code --- tests/plugins/tabletools/tabletools.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/plugins/tabletools/tabletools.js b/tests/plugins/tabletools/tabletools.js index fce96c71818..0d51ddd4b74 100644 --- a/tests/plugins/tabletools/tabletools.js +++ b/tests/plugins/tabletools/tabletools.js @@ -265,7 +265,6 @@ }, 'test merge cells with a rowspan should create undo step': function() { - bender.editorBot.create( { name: 'editor_merge_rowspanned_cells', config: { @@ -283,8 +282,6 @@ var output = bot.getData( true ), undo = editor.getCommand( 'undo' ); - output = output.replace( /\u00a0/g, ' ' ); - assert.areSame( bender.tools.compatHtml( expected ), output ); assert.isTrue( undo.state === CKEDITOR.TRISTATE_OFF ); } ); From f83325ae094b430b45d5ebcb4da743fc33adb351 Mon Sep 17 00:00:00 2001 From: Karol Dawidziuk Date: Wed, 22 Jun 2022 08:32:33 +0200 Subject: [PATCH 6/7] Ignore manual mergecells test on mobile devices --- tests/plugins/tabletools/manual/mergecells.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/plugins/tabletools/manual/mergecells.html b/tests/plugins/tabletools/manual/mergecells.html index d002b5ceed6..5f6ee6d505f 100644 --- a/tests/plugins/tabletools/manual/mergecells.html +++ b/tests/plugins/tabletools/manual/mergecells.html @@ -24,6 +24,10 @@