-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix disappearing undo steps after multiple selection changes #2792
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
822686f
Add manual tests for copyformatting undo bug.
d66b1ec
Add fix to not refresh snapshot when there is no selected format.
71bf1c6
Correct manual test description, add unit test.
ede079b
Add changelog entry.
91c5095
Add issue reference, correct spelling mistake.
bdccfcf
Remove unreachable code.
a4ea15a
Extend manual test case with new scenario.
d20e91d
Addunit test for redo case.
da96980
Add redo unit tests.
e808244
Add proper target to event.
0e03a7b
Update test description, simplify manual test, change name of unit te…
b96338f
Add unit test.
Comandeer f5694fb
Add manual test.
Comandeer 1833554
Include #2470 in tests.
Comandeer dcb4705
Add changelog entries.
Comandeer 6edeceb
Add ticket reference to the code.
Comandeer f2f0afd
Fix unit test for IE8. Fix typo.
Comandeer fa90cd1
Fix code style issue.
Comandeer 9d94ac4
Remove snapshot indicator in manual test, which works incorrectly and…
0d72dea
Correct unit test, to not fail on build version.
c05f7cd
Fix code style issues with CSS.
engineering-this 050ad15
Remove unnecessary assert, correct helper name.
6e76d77
Update description of manual test.
d63537f
Remove referrence to unused tools, remove variables and id attributes…
a3361ff
Update link in changelog entry.
Comandeer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
tests/plugins/copyformatting/manual/nestededitablefocus.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<style> | ||
#square { | ||
margin-top: 20px; | ||
width: 100px; | ||
height: 100px; | ||
border: 1px #000 solid; | ||
background-color: red; | ||
Comandeer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
</style> | ||
<h2>Classic editor</h2> | ||
<div id="classic"> | ||
<div class="test1">x<div class="content">Widget1</div>y</div> | ||
Comandeer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
|
||
<div id="square"></div> | ||
|
||
<script> | ||
CKEDITOR.addCss( '.cke_editable { margin: 0; padding: 50px; }' + | ||
'.test1 { border: 1px #000 solid; }' ); | ||
CKEDITOR.replace( 'classic', { | ||
extraPlugins: 'test1' | ||
} ); | ||
|
||
CKEDITOR.plugins.add( 'test1', { | ||
requires: 'widget', | ||
init: function( editor ) { | ||
editor.widgets.add( 'test1', { | ||
button: 'Create autoparagraph test', | ||
pathName: 'test-widget', | ||
|
||
template: | ||
'<div class="test1">' + | ||
'<div class="content"></div>' + | ||
'</div>', | ||
|
||
editables: { | ||
content: { | ||
selector: '.content', | ||
allowedContent: 'br' | ||
} | ||
}, | ||
|
||
allowedContent: 'div(test1,content)', | ||
requiredContent: 'div(test1)', | ||
|
||
upcast: function( element ) { | ||
return element.name == 'div' && element.hasClass( 'test1' ); | ||
}, | ||
|
||
init: function() { | ||
var square = CKEDITOR.document.getById( 'square' ); | ||
|
||
this.editables.content.on( 'focus', function() { | ||
square.setStyle( 'background-color', 'green' ); | ||
} ); | ||
this.editables.content.on( 'blur', function() { | ||
square.setStyle( 'background-color', 'red' ); | ||
} ); | ||
} | ||
|
||
} ); | ||
} | ||
} ); | ||
</script> |
17 changes: 17 additions & 0 deletions
17
tests/plugins/copyformatting/manual/nestededitablefocus.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@bender-tags: bug, 4.11.3, 2655, 2470 | ||
@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. | ||
* Square under the editor is green. | ||
|
||
## Unexpected | ||
|
||
* Focus is moved into nested editable for a fraction of second and then disappears. | ||
* Square under the editor is red. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<h2>First editor</h2> | ||
<div id="editor1" contenteditable="true"> | ||
<p><strong><u><span style="color: #f00;" class="important">Apollo 11</span></u></strong> <s>was the</s> <span style="color: #f00;" class="important">spaceflight</span> that landed the first humans, Americans <a href="http://en.wikipedia.org/wiki/Neil_Armstrong" title="Neil Armstrong">Neil Armstrong</a> and <a href="http://en.wikipedia.org/wiki/Buzz_Aldrin" title="Buzz Aldrin">Buzz Aldrin</a>, on the Moon on July 20, 1969, at 20:18 UTC. <span style="background-color: #f00;" bogus-attr="2">Armstrong</span> became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p> | ||
</div> | ||
|
||
<h2>Second editor</h2> | ||
<div id="editor2" contenteditable="true"> | ||
<p><strong><u><span style="color: #f00;" class="important">Apollo 11</span></u></strong> <s>was the</s> <span style="color: #f00;" class="important">spaceflight</span> that landed the first humans, Americans <a href="http://en.wikipedia.org/wiki/Neil_Armstrong" title="Neil Armstrong">Neil Armstrong</a> and <a href="http://en.wikipedia.org/wiki/Buzz_Aldrin" title="Buzz Aldrin">Buzz Aldrin</a>, on the Moon on July 20, 1969, at 20:18 UTC. <span style="background-color: #f00;" bogus-attr="2">Armstrong</span> became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p> | ||
</div> | ||
|
||
<script> | ||
CKEDITOR.replace( 'editor1' ); | ||
CKEDITOR.replace( 'editor2', { | ||
extraPlugins: 'divarea' | ||
} ); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@bender-ui: collapsed | ||
@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 "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. | ||
### Unexpected: | ||
Undo UI became disabled. | ||
|
||
Comandeer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* bender-tags: copyformatting */ | ||
/* bender-ckeditor-plugins: wysiwygarea, toolbar, copyformatting, undo */ | ||
/* bender-ui: collapsed */ | ||
|
||
( function() { | ||
'use strict'; | ||
|
||
var leftMouseButton = CKEDITOR.env.ie && CKEDITOR.env.version < 9 ? 1 : CKEDITOR.MOUSE_BUTTON_LEFT; | ||
|
||
bender.editor = { | ||
config: { | ||
allowedContent: true | ||
} | ||
}; | ||
|
||
|
||
bender.test( { | ||
// (#2780) | ||
'test basic undo integration': function() { | ||
var editor = this.editor, | ||
bot = this.editorBot, | ||
sel = editor.getSelection(), | ||
spans; | ||
|
||
resetUndoAndCreateFirstSnapshot( bot ); | ||
|
||
spans = editor.editable().find( 'span' ); | ||
for ( var i = 0; i < editor.undoManager.limit; i++ ) { | ||
sel.selectElement( spans.getItem( i % 2 ) ); | ||
editor.document.fire( 'mouseup', new CKEDITOR.dom.event( { | ||
button: leftMouseButton, | ||
target: editor.editable() | ||
} ) ); | ||
} | ||
|
||
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() { | ||
var editor = this.editor, | ||
bot = this.editorBot, | ||
sel = editor.getSelection(); | ||
|
||
resetUndoAndCreateFirstSnapshot( bot ); | ||
|
||
bot.execCommand( 'undo' ); | ||
|
||
sel.selectElement( editor.editable().find( 'span' ).getItem( 0 ) ); | ||
editor.document.fire( 'mouseup', new CKEDITOR.dom.event( { | ||
button: leftMouseButton, | ||
target: editor.editable() | ||
} ) ); | ||
|
||
assert.isTrue( editor.undoManager.redoable(), 'Editor should has possibility to redo.' ); | ||
} | ||
} ); | ||
|
||
function resetUndoAndCreateFirstSnapshot( bot ) { | ||
var editor = bot.editor; | ||
|
||
bot.setHtmlWithSelection( '<p><span>foo</span> []bar <span>baz</span></p>' ); | ||
|
||
editor.undoManager.reset(); | ||
editor.fire( 'saveSnapshot' ); | ||
|
||
editor.insertText( '1' ); | ||
editor.fire( 'saveSnapshot' ); | ||
} | ||
|
||
} )(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.