From 822686fe4bb90f7a03be7d5a7c23d2f1c64498b0 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Wed, 30 Jan 2019 15:53:38 +0100 Subject: [PATCH 01/25] Add manual tests for copyformatting undo bug. --- .../copyformatting/manual/undointegration.html | 18 ++++++++++++++++++ .../copyformatting/manual/undointegration.md | 5 +++++ 2 files changed, 23 insertions(+) create mode 100644 tests/plugins/copyformatting/manual/undointegration.html create mode 100644 tests/plugins/copyformatting/manual/undointegration.md diff --git a/tests/plugins/copyformatting/manual/undointegration.html b/tests/plugins/copyformatting/manual/undointegration.html new file mode 100644 index 00000000000..efcec3a344d --- /dev/null +++ b/tests/plugins/copyformatting/manual/undointegration.html @@ -0,0 +1,18 @@ +

First editor

+ +
+

Apollo 11 was the spaceflight that landed the first humans, Americans Neil Armstrong and Buzz Aldrin, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.

+
+ +

Second editor

+ +
+

Apollo 11 was the spaceflight that landed the first humans, Americans Neil Armstrong and Buzz Aldrin, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.

+
+ + diff --git a/tests/plugins/copyformatting/manual/undointegration.md b/tests/plugins/copyformatting/manual/undointegration.md new file mode 100644 index 00000000000..abe0819a5eb --- /dev/null +++ b/tests/plugins/copyformatting/manual/undointegration.md @@ -0,0 +1,5 @@ +@bender-ui: collapsed +@bender-tags: bug, copyformatting, 4.11.3, trac16675 +@bender-ckeditor-plugins: copyformatting, toolbar, wysiwygarea, undo, basicstyles + +1. Play with undo From d66b1ec20cabac908c09119792d4e6d24bc82889 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Wed, 30 Jan 2019 16:35:23 +0100 Subject: [PATCH 02/25] Add fix to not refresh snapshot when there is no selected format. --- plugins/copyformatting/plugin.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/copyformatting/plugin.js b/plugins/copyformatting/plugin.js index fb9188a5d76..2e19da49eed 100644 --- a/plugins/copyformatting/plugin.js +++ b/plugins/copyformatting/plugin.js @@ -98,17 +98,16 @@ // clicking the whole document messes the focus. mouseupHost = editable.isInline() ? editable : editor.document, copyFormattingButton = editor.ui.get( 'CopyFormatting' ), - copyFormattingButtonEl; + copyFormattingButtonEl, + cmd = editor.getCommand( 'copyFormatting' ); editable.attachListener( mouseupHost, 'mouseup', function( evt ) { - if ( getMouseButton( evt ) === CKEDITOR.MOUSE_BUTTON_LEFT ) { + if ( getMouseButton( evt ) === CKEDITOR.MOUSE_BUTTON_LEFT && cmd.state === CKEDITOR.TRISTATE_ON ) { editor.execCommand( 'applyFormatting' ); } } ); editable.attachListener( CKEDITOR.document, 'mouseup', function( evt ) { - var cmd = editor.getCommand( 'copyFormatting' ); - if ( getMouseButton( evt ) === CKEDITOR.MOUSE_BUTTON_LEFT && cmd.state === CKEDITOR.TRISTATE_ON && !editable.contains( evt.data.getTarget() ) ) { editor.execCommand( 'copyFormatting' ); From 71bf1c6e31a6fc56fae0c1dc7450903dc341e781 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Tue, 5 Feb 2019 16:10:52 +0100 Subject: [PATCH 03/25] Correct manual test description, add unit test. --- .../copyformatting/manual/undointegration.md | 10 ++++- .../plugins/copyformatting/undointegration.js | 45 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/plugins/copyformatting/undointegration.js diff --git a/tests/plugins/copyformatting/manual/undointegration.md b/tests/plugins/copyformatting/manual/undointegration.md index abe0819a5eb..626aad2285b 100644 --- a/tests/plugins/copyformatting/manual/undointegration.md +++ b/tests/plugins/copyformatting/manual/undointegration.md @@ -2,4 +2,12 @@ @bender-tags: bug, copyformatting, 4.11.3, trac16675 @bender-ckeditor-plugins: copyformatting, toolbar, wysiwygarea, undo, basicstyles -1. Play with undo +## Test both editors +1. Add some content to editor (e.g. new line), to "avctivate" undo step. +2. Start to click around editor to change selection inside editor (20-25 times). Selection have to differ between adjacent steps. + +### Expected: +Undo UI button is active. + +### Unexpected: +Undo UI became disabled. diff --git a/tests/plugins/copyformatting/undointegration.js b/tests/plugins/copyformatting/undointegration.js new file mode 100644 index 00000000000..219a4283f85 --- /dev/null +++ b/tests/plugins/copyformatting/undointegration.js @@ -0,0 +1,45 @@ +/* bender-tags: copyformatting */ +/* bender-ckeditor-plugins: wysiwygarea, toolbar, copyformatting, undo */ +/* bender-include: _helpers/tools.js*/ + +( function() { + 'use strict'; + + bender.editor = { + config: { + allowedcontent: true + } + }; + + bender.test( { + 'test undo integration': function() { + var editor = this.editor, + bot = this.editorBot, + sel = editor.getSelection(), + el1, + el2; + + assert.areSame( 0, editor.undoManager.index, 'There shouldn\'t be any undo steps.' ); + + bot.setHtmlWithSelection( '

foo []bar baz

' ); + editor.insertText( '1' ); + + assert.areSame( 1, editor.undoManager.index, 'There should be only 1 undo step.' ); + + el1 = editor.editable().findOne( '#one' ); + el2 = editor.editable().findOne( '#two' ); + + for ( var i = 0; i < editor.undoManager.limit; i++ ) { + sel.selectElement( i % 2 ? el1 : el2 ); + editor.document.fire( 'mouseup', new CKEDITOR.dom.event( { + button: CKEDITOR.MOUSE_BUTTON_LEFT + } ) ); + } + + assert.areSame( 1, editor.undoManager.index, 'There shouldn\'t be new undo steps.' ); + assert.isTrue( editor.undoManager.undoable(), 'Editor should has possibility to undo.' ); + + } + } ); + +} )(); From ede079b32a604a879f49f93abd04e14644d6e264 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Tue, 5 Feb 2019 16:13:07 +0100 Subject: [PATCH 04/25] Add changelog entry. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index fcec6485e69..dc8162015c0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ Fixed Issues: * [#2756](https://github.com/ckeditor/ckeditor-dev/issues/2756): Fixed: The [Auto Link](https://ckeditor.com/cke4/addon/autolink) plugin causes an error when typing in [Source Editing Mode](https://ckeditor.com/docs/ckeditor4/latest/guide/dev_sourcearea.html). * [#1986](https://github.com/ckeditor/ckeditor-dev/issues/1986): Fixed: Cell Properties dialog from [Table Tools](https://ckeditor.com/cke4/addon/tabletools) plugin shows styles that are not allowed through [`config.allowedContent`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-allowedContent). * [#2565](https://github.com/ckeditor/ckeditor-dev/issues/2565): [IE, Edge] Fixed: Buttons in the [Editor Toolbar](https://ckeditor.com/cke4/addon/toolbar) are activated by clicking them with right mouse button. +* [#2780](https://github.com/ckeditor/ckeditor-dev/issues/2721): Fixed: Undo steps disappears after multiple change of selection. ## CKEditor 4.11.2 From 91c50956723022224d34284e91f085bd80a27957 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Mon, 11 Feb 2019 09:53:22 +0100 Subject: [PATCH 05/25] Add issue reference, correct spelling mistake. --- tests/plugins/copyformatting/manual/undointegration.md | 4 ++-- tests/plugins/copyformatting/undointegration.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/plugins/copyformatting/manual/undointegration.md b/tests/plugins/copyformatting/manual/undointegration.md index 626aad2285b..ec51d6e2ae2 100644 --- a/tests/plugins/copyformatting/manual/undointegration.md +++ b/tests/plugins/copyformatting/manual/undointegration.md @@ -1,9 +1,9 @@ @bender-ui: collapsed -@bender-tags: bug, copyformatting, 4.11.3, trac16675 +@bender-tags: bug, copyformatting, 4.11.3, 2780 @bender-ckeditor-plugins: copyformatting, toolbar, wysiwygarea, undo, basicstyles ## Test both editors -1. Add some content to editor (e.g. new line), to "avctivate" undo step. +1. Add some content to editor (e.g. new line), to "activate" undo step. 2. Start to click around editor to change selection inside editor (20-25 times). Selection have to differ between adjacent steps. ### Expected: diff --git a/tests/plugins/copyformatting/undointegration.js b/tests/plugins/copyformatting/undointegration.js index 219a4283f85..069e40ed500 100644 --- a/tests/plugins/copyformatting/undointegration.js +++ b/tests/plugins/copyformatting/undointegration.js @@ -12,6 +12,7 @@ }; bender.test( { + // (#2780) 'test undo integration': function() { var editor = this.editor, bot = this.editorBot, From bdccfcf0663ea7703c0efbb9a86616803637d9e8 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Mon, 11 Feb 2019 09:56:28 +0100 Subject: [PATCH 06/25] Remove unreachable code. --- plugins/copyformatting/plugin.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/copyformatting/plugin.js b/plugins/copyformatting/plugin.js index 2e19da49eed..2da74e874e3 100644 --- a/plugins/copyformatting/plugin.js +++ b/plugins/copyformatting/plugin.js @@ -423,10 +423,7 @@ documentElement = CKEDITOR.document.getDocumentElement(), isApplied; - if ( !isFromKeystroke && cmd.state !== CKEDITOR.TRISTATE_ON ) { - return; - - } else if ( isFromKeystroke && !copyFormatting.styles ) { + if ( isFromKeystroke && !copyFormatting.styles ) { plugin._putScreenReaderMessage( editor, 'failed' ); plugin._detachPasteKeystrokeHandler( editor ); return false; From a4ea15abdcad29a2cb95c44d5893f0b574dec937 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Mon, 11 Feb 2019 11:08:37 +0100 Subject: [PATCH 07/25] Extend manual test case with new scenario. --- .../manual/undointegration.html | 27 ++++++++++++++++--- .../copyformatting/manual/undointegration.md | 12 ++++++--- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/tests/plugins/copyformatting/manual/undointegration.html b/tests/plugins/copyformatting/manual/undointegration.html index efcec3a344d..04275f8efef 100644 --- a/tests/plugins/copyformatting/manual/undointegration.html +++ b/tests/plugins/copyformatting/manual/undointegration.html @@ -1,18 +1,37 @@

First editor

- +

Current snapshot index: 0.
(Value is refreshed exclusively on "mouseup" event from editable.)

Apollo 11 was the spaceflight that landed the first humans, Americans Neil Armstrong and Buzz Aldrin, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.

Second editor

- +

Current snapshot index: 0.
(Value is refreshed exclusively on "mouseup" event from editable.)

Apollo 11 was the spaceflight that landed the first humans, Americans Neil Armstrong and Buzz Aldrin, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.

diff --git a/tests/plugins/copyformatting/manual/undointegration.md b/tests/plugins/copyformatting/manual/undointegration.md index ec51d6e2ae2..c49c0aeeb97 100644 --- a/tests/plugins/copyformatting/manual/undointegration.md +++ b/tests/plugins/copyformatting/manual/undointegration.md @@ -5,9 +5,15 @@ ## Test both editors 1. Add some content to editor (e.g. new line), to "activate" undo step. 2. Start to click around editor to change selection inside editor (20-25 times). Selection have to differ between adjacent steps. - ### Expected: -Undo UI button is active. - +Undo UI button is active. Current snapshot index does equals 1 and doesn't change with selection change. ### Unexpected: Undo UI became disabled. + + +3. Click undo button to revert change made in point 1. Make sure that Redo button is activated. +4. Make new selection inside editor. +### Expected: +Redo UI button is active. +### Unexpected: +Redo UI button became disabled. From d20e91db118287ba1d9be75654eaf627787f6748 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Mon, 11 Feb 2019 11:30:38 +0100 Subject: [PATCH 08/25] Addunit test for redo case. --- tests/plugins/copyformatting/undointegration.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/plugins/copyformatting/undointegration.js b/tests/plugins/copyformatting/undointegration.js index 069e40ed500..f0b6e7f18d2 100644 --- a/tests/plugins/copyformatting/undointegration.js +++ b/tests/plugins/copyformatting/undointegration.js @@ -13,7 +13,7 @@ bender.test( { // (#2780) - 'test undo integration': function() { + 'test basic undo integration': function() { var editor = this.editor, bot = this.editorBot, sel = editor.getSelection(), @@ -39,7 +39,21 @@ assert.areSame( 1, editor.undoManager.index, 'There shouldn\'t be new undo steps.' ); assert.isTrue( editor.undoManager.undoable(), 'Editor should has possibility to undo.' ); + }, + // (#2780) + 'test basic redo integration': function() { + var editor = this.editor, + bot = this.editorBot; + + bot.setHtmlWithSelection( '

foo []bar baz

' ); + editor.insertText( '1' ); + bot.execCommand( 'undo' ); + + editor.document.fire( 'mouseup', new CKEDITOR.dom.event( { + button: CKEDITOR.MOUSE_BUTTON_LEFT + } ) ); + assert.isTrue( editor.undoManager.redoable(), 'Editor should has possibility to red.' ); } } ); From da969808966f29919d54a4d4a0a9695ab013474e Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Mon, 11 Feb 2019 12:36:16 +0100 Subject: [PATCH 09/25] Add redo unit tests. --- .../plugins/copyformatting/undointegration.js | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/tests/plugins/copyformatting/undointegration.js b/tests/plugins/copyformatting/undointegration.js index f0b6e7f18d2..40a6b839fbd 100644 --- a/tests/plugins/copyformatting/undointegration.js +++ b/tests/plugins/copyformatting/undointegration.js @@ -1,6 +1,7 @@ /* bender-tags: copyformatting */ /* bender-ckeditor-plugins: wysiwygarea, toolbar, copyformatting, undo */ /* bender-include: _helpers/tools.js*/ +/* bender-ui: collapsed */ ( function() { 'use strict'; @@ -11,6 +12,26 @@ } }; + function prepareEditor( bot ) { + var editor = bot.editor; + + bot.setHtmlWithSelection( '

foo []bar baz

' ); + + editor.undoManager.reset(); + editor.fire( 'saveSnapshot' ); + + assert.areSame( 0, editor.undoManager.index, 'There shouldn\'t be any undo steps.' ); + assert.isFalse( editor.undoManager.undoable(), 'Editor should not have possibility to undo.' ); + assert.isFalse( editor.undoManager.redoable(), 'Editor should not have possibility to redo.' ); + + editor.insertText( '1' ); + editor.fire( 'saveSnapshot' ); + + assert.areSame( 1, editor.undoManager.index, 'There should be only 1 undo step, which is currently active.' ); + assert.isTrue( editor.undoManager.undoable(), 'Editor should have possibility to undo.' ); + assert.isFalse( editor.undoManager.redoable(), 'Editor should not have possibility to redo.' ); + } + bender.test( { // (#2780) 'test basic undo integration': function() { @@ -20,12 +41,7 @@ el1, el2; - assert.areSame( 0, editor.undoManager.index, 'There shouldn\'t be any undo steps.' ); - - bot.setHtmlWithSelection( '

foo []bar baz

' ); - editor.insertText( '1' ); - - assert.areSame( 1, editor.undoManager.index, 'There should be only 1 undo step.' ); + prepareEditor( bot ); el1 = editor.editable().findOne( '#one' ); el2 = editor.editable().findOne( '#two' ); @@ -37,23 +53,25 @@ } ) ); } - assert.areSame( 1, editor.undoManager.index, 'There shouldn\'t be new undo steps.' ); + assert.areSame( 1, editor.undoManager.index, 'There shouldn\'t be new undo steps and editor should remain on 1st step.' ); assert.isTrue( editor.undoManager.undoable(), 'Editor should has possibility to undo.' ); }, // (#2780) 'test basic redo integration': function() { var editor = this.editor, - bot = this.editorBot; + bot = this.editorBot, + sel = editor.getSelection(); + + prepareEditor( bot ); - bot.setHtmlWithSelection( '

foo []bar baz

' ); - editor.insertText( '1' ); bot.execCommand( 'undo' ); + sel.selectElement( editor.editable().findOne( '#one' ) ); editor.document.fire( 'mouseup', new CKEDITOR.dom.event( { button: CKEDITOR.MOUSE_BUTTON_LEFT } ) ); - assert.isTrue( editor.undoManager.redoable(), 'Editor should has possibility to red.' ); + assert.isTrue( editor.undoManager.redoable(), 'Editor should has possibility to redo.' ); } } ); From e808244b30eda8fa69a65bb1cd6597bdb9dbcdc7 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Mon, 11 Feb 2019 15:08:54 +0100 Subject: [PATCH 10/25] Add proper target to event. --- tests/plugins/copyformatting/undointegration.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/plugins/copyformatting/undointegration.js b/tests/plugins/copyformatting/undointegration.js index 40a6b839fbd..7edc0fd2ee5 100644 --- a/tests/plugins/copyformatting/undointegration.js +++ b/tests/plugins/copyformatting/undointegration.js @@ -49,7 +49,8 @@ for ( var i = 0; i < editor.undoManager.limit; i++ ) { sel.selectElement( i % 2 ? el1 : el2 ); editor.document.fire( 'mouseup', new CKEDITOR.dom.event( { - button: CKEDITOR.MOUSE_BUTTON_LEFT + button: CKEDITOR.MOUSE_BUTTON_LEFT, + target: editor.editable() } ) ); } @@ -68,7 +69,8 @@ sel.selectElement( editor.editable().findOne( '#one' ) ); editor.document.fire( 'mouseup', new CKEDITOR.dom.event( { - button: CKEDITOR.MOUSE_BUTTON_LEFT + button: CKEDITOR.MOUSE_BUTTON_LEFT, + target: editor.editable() } ) ); assert.isTrue( editor.undoManager.redoable(), 'Editor should has possibility to redo.' ); From 0e03a7baaac5d276edb1471bfab8eed2db81d0fe Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Tue, 12 Feb 2019 16:18:59 +0100 Subject: [PATCH 11/25] Update test description, simplify manual test, change name of unit test helpr to be more accurate. --- .../manual/undointegration.html | 30 ++++++------ .../copyformatting/manual/undointegration.md | 3 +- .../plugins/copyformatting/undointegration.js | 47 ++++++++++--------- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/plugins/copyformatting/manual/undointegration.html b/tests/plugins/copyformatting/manual/undointegration.html index 04275f8efef..9f39265c752 100644 --- a/tests/plugins/copyformatting/manual/undointegration.html +++ b/tests/plugins/copyformatting/manual/undointegration.html @@ -1,37 +1,35 @@

First editor

-

Current snapshot index: 0.
(Value is refreshed exclusively on "mouseup" event from editable.)

+

Current snapshot index: 0.
(Value is refreshed every 200ms.)

Apollo 11 was the spaceflight that landed the first humans, Americans Neil Armstrong and Buzz Aldrin, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.

Second editor

-

Current snapshot index: 0.
(Value is refreshed exclusively on "mouseup" event from editable.)

+

Current snapshot index: 0.
(Value is refreshed every 200ms.)

Apollo 11 was the spaceflight that landed the first humans, Americans Neil Armstrong and Buzz Aldrin, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.

diff --git a/tests/plugins/copyformatting/manual/undointegration.md b/tests/plugins/copyformatting/manual/undointegration.md index c49c0aeeb97..83462d6afbe 100644 --- a/tests/plugins/copyformatting/manual/undointegration.md +++ b/tests/plugins/copyformatting/manual/undointegration.md @@ -5,14 +5,15 @@ ## Test both editors 1. Add some content to editor (e.g. new line), to "activate" undo step. 2. Start to click around editor to change selection inside editor (20-25 times). Selection have to differ between adjacent steps. + ### Expected: Undo UI button is active. Current snapshot index does equals 1 and doesn't change with selection change. ### Unexpected: Undo UI became disabled. - 3. Click undo button to revert change made in point 1. Make sure that Redo button is activated. 4. Make new selection inside editor. + ### Expected: Redo UI button is active. ### Unexpected: diff --git a/tests/plugins/copyformatting/undointegration.js b/tests/plugins/copyformatting/undointegration.js index 7edc0fd2ee5..dfcf9b42e66 100644 --- a/tests/plugins/copyformatting/undointegration.js +++ b/tests/plugins/copyformatting/undointegration.js @@ -12,25 +12,6 @@ } }; - function prepareEditor( bot ) { - var editor = bot.editor; - - bot.setHtmlWithSelection( '

foo []bar baz

' ); - - editor.undoManager.reset(); - editor.fire( 'saveSnapshot' ); - - assert.areSame( 0, editor.undoManager.index, 'There shouldn\'t be any undo steps.' ); - assert.isFalse( editor.undoManager.undoable(), 'Editor should not have possibility to undo.' ); - assert.isFalse( editor.undoManager.redoable(), 'Editor should not have possibility to redo.' ); - - editor.insertText( '1' ); - editor.fire( 'saveSnapshot' ); - - assert.areSame( 1, editor.undoManager.index, 'There should be only 1 undo step, which is currently active.' ); - assert.isTrue( editor.undoManager.undoable(), 'Editor should have possibility to undo.' ); - assert.isFalse( editor.undoManager.redoable(), 'Editor should not have possibility to redo.' ); - } bender.test( { // (#2780) @@ -41,7 +22,7 @@ el1, el2; - prepareEditor( bot ); + resetEditorStatusAndCheckBasicAsserts( bot ); el1 = editor.editable().findOne( '#one' ); el2 = editor.editable().findOne( '#two' ); @@ -54,8 +35,8 @@ } ) ); } - assert.areSame( 1, editor.undoManager.index, 'There shouldn\'t be new undo steps and editor should remain on 1st step.' ); - assert.isTrue( editor.undoManager.undoable(), 'Editor should has possibility to undo.' ); + assert.areSame( 1, editor.undoManager.index, 'There shouldn\'t be new undo steps and editor should remain on the 1st step.' ); + assert.isTrue( editor.undoManager.undoable(), 'Editor should have a possibility to undo.' ); }, // (#2780) 'test basic redo integration': function() { @@ -63,7 +44,7 @@ bot = this.editorBot, sel = editor.getSelection(); - prepareEditor( bot ); + resetEditorStatusAndCheckBasicAsserts( bot ); bot.execCommand( 'undo' ); @@ -77,4 +58,24 @@ } } ); + function resetEditorStatusAndCheckBasicAsserts( bot ) { + var editor = bot.editor; + + bot.setHtmlWithSelection( '

foo []bar baz

' ); + + editor.undoManager.reset(); + editor.fire( 'saveSnapshot' ); + + assert.areSame( 0, editor.undoManager.index, 'There shouldn\'t be any undo steps.' ); + assert.isFalse( editor.undoManager.undoable(), 'Editor should not have possibility to undo.' ); + assert.isFalse( editor.undoManager.redoable(), 'Editor should not have possibility to redo.' ); + + editor.insertText( '1' ); + editor.fire( 'saveSnapshot' ); + + assert.areSame( 1, editor.undoManager.index, 'There should be only 1 undo step, which is currently active.' ); + assert.isTrue( editor.undoManager.undoable(), 'Editor should have possibility to undo.' ); + assert.isFalse( editor.undoManager.redoable(), 'Editor should not have possibility to redo.' ); + } + } )(); From b96338f7ec82780d073acfd5bf9b87868bfbbd80 Mon Sep 17 00:00:00 2001 From: Tomasz Jakut Date: Thu, 14 Feb 2019 14:31:14 +0100 Subject: [PATCH 12/25] Add unit test. --- tests/plugins/copyformatting/applyformat.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/plugins/copyformatting/applyformat.js b/tests/plugins/copyformatting/applyformat.js index bac9abdace6..765fe992983 100644 --- a/tests/plugins/copyformatting/applyformat.js +++ b/tests/plugins/copyformatting/applyformat.js @@ -437,6 +437,20 @@ bender.tools.selection.setWithHtml( editor, '
Ce{ll 1
Ce}ll 2
' ); assert.areSame( tableConstant, determineContext(), 'Selection within two rows' ); + }, + + // (#2655) + 'test applyFormat not fired without copied styles': function() { + var editor = this.editor, + spy = sinon.spy( editor, 'execCommand' ), + isIe8 = CKEDITOR.env.ie && CKEDITOR.env.version < 9; + + editor.document.fire( 'mouseup', new CKEDITOR.dom.event( { + button: isIe8 ? 1 : CKEDITOR.MOUSE_BUTTON_LEFT + } ) ); + spy.restore(); + + assert.areSame( 0, spy.callCount ); } } ); }() ); From f5694fbc4fe8dc731944e17f8aa653b8fd19ac3c Mon Sep 17 00:00:00 2001 From: Tomasz Jakut Date: Thu, 14 Feb 2019 14:31:51 +0100 Subject: [PATCH 13/25] Add manual test. --- .../manual/nestededitablefocus.html | 45 +++++++++++++++++++ .../manual/nestededitablefocus.md | 15 +++++++ 2 files changed, 60 insertions(+) create mode 100644 tests/plugins/copyformatting/manual/nestededitablefocus.html create mode 100644 tests/plugins/copyformatting/manual/nestededitablefocus.md diff --git a/tests/plugins/copyformatting/manual/nestededitablefocus.html b/tests/plugins/copyformatting/manual/nestededitablefocus.html new file mode 100644 index 00000000000..9c22afb91a5 --- /dev/null +++ b/tests/plugins/copyformatting/manual/nestededitablefocus.html @@ -0,0 +1,45 @@ +

Classic editor

+
+
x
Widget1
y
+
+ + diff --git a/tests/plugins/copyformatting/manual/nestededitablefocus.md b/tests/plugins/copyformatting/manual/nestededitablefocus.md new file mode 100644 index 00000000000..5835b501d1b --- /dev/null +++ b/tests/plugins/copyformatting/manual/nestededitablefocus.md @@ -0,0 +1,15 @@ +@bender-tags: bug, 4.11.3, 2655 +@bender-ui: collapsed +@bender-ckeditor-plugins: widget, wysiwygarea, copyformatting + +1. Click inside "Widget 1" text to focus nested editable. +2. Click above the widget (above the black border). +3. Click once more inside "Widget 1" text. + +## Expected + +Focus is moved into nested editable and stays there. + +## Unexpected + +Focus is moved into nested editable for a fraction of second and then disappears. From 183355476a5d4e7dd8955622e226d81cc9b40dc4 Mon Sep 17 00:00:00 2001 From: Tomasz Jakut Date: Thu, 14 Feb 2019 15:02:20 +0100 Subject: [PATCH 14/25] Include #2470 in tests. --- tests/plugins/copyformatting/applyformat.js | 2 +- .../manual/nestededitablefocus.html | 27 ++++++++++++++++--- .../manual/nestededitablefocus.md | 8 +++--- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/tests/plugins/copyformatting/applyformat.js b/tests/plugins/copyformatting/applyformat.js index 765fe992983..f44d6a95462 100644 --- a/tests/plugins/copyformatting/applyformat.js +++ b/tests/plugins/copyformatting/applyformat.js @@ -439,7 +439,7 @@ assert.areSame( tableConstant, determineContext(), 'Selection within two rows' ); }, - // (#2655) + // (#2655, #2470) 'test applyFormat not fired without copied styles': function() { var editor = this.editor, spy = sinon.spy( editor, 'execCommand' ), diff --git a/tests/plugins/copyformatting/manual/nestededitablefocus.html b/tests/plugins/copyformatting/manual/nestededitablefocus.html index 9c22afb91a5..25d5aab9eca 100644 --- a/tests/plugins/copyformatting/manual/nestededitablefocus.html +++ b/tests/plugins/copyformatting/manual/nestededitablefocus.html @@ -1,13 +1,20 @@ +

Classic editor

x
Widget1
y
- diff --git a/tests/plugins/copyformatting/manual/undointegration.md b/tests/plugins/copyformatting/manual/undointegration.md index 83462d6afbe..86921744c5f 100644 --- a/tests/plugins/copyformatting/manual/undointegration.md +++ b/tests/plugins/copyformatting/manual/undointegration.md @@ -4,10 +4,10 @@ ## Test both editors 1. Add some content to editor (e.g. new line), to "activate" undo step. -2. Start to click around editor to change selection inside editor (20-25 times). Selection have to differ between adjacent steps. +2. Start to click around editor to change selection inside editor (20-25 times). Selection **have to differ** between adjacent steps. ### Expected: -Undo UI button is active. Current snapshot index does equals 1 and doesn't change with selection change. +Undo UI button is active. ### Unexpected: Undo UI became disabled. From 0d72dea26564b01f6628a85be660e90bd268b880 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Fri, 15 Feb 2019 13:26:34 +0100 Subject: [PATCH 20/25] Correct unit test, to not fail on build version. --- tests/plugins/copyformatting/applyformat.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/plugins/copyformatting/applyformat.js b/tests/plugins/copyformatting/applyformat.js index 55dc43f8e20..d867a56800f 100644 --- a/tests/plugins/copyformatting/applyformat.js +++ b/tests/plugins/copyformatting/applyformat.js @@ -446,7 +446,8 @@ isIe8 = CKEDITOR.env.ie && CKEDITOR.env.version < 9; editor.document.fire( 'mouseup', new CKEDITOR.dom.event( { - button: isIe8 ? 1 : CKEDITOR.MOUSE_BUTTON_LEFT + button: isIe8 ? 1 : CKEDITOR.MOUSE_BUTTON_LEFT, + target: editor.editable() } ) ); spy.restore(); From c05f7cd6a1ec049e37ec51488115fbd12f02a733 Mon Sep 17 00:00:00 2001 From: Kajetan Litwinowicz Date: Sat, 16 Feb 2019 17:00:53 +0100 Subject: [PATCH 21/25] Fix code style issues with CSS. Co-Authored-By: Comandeer --- tests/plugins/copyformatting/manual/nestededitablefocus.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugins/copyformatting/manual/nestededitablefocus.html b/tests/plugins/copyformatting/manual/nestededitablefocus.html index 25d5aab9eca..b5ab0a9dd77 100644 --- a/tests/plugins/copyformatting/manual/nestededitablefocus.html +++ b/tests/plugins/copyformatting/manual/nestededitablefocus.html @@ -15,7 +15,7 @@

Classic editor