diff --git a/CHANGES.md b/CHANGES.md index 1de6cb16414..2e7e7dc180d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,10 @@ ## CKEditor 4.7.3 +Fixed Issues: + +* [#554](https://github.com/ckeditor/ckeditor-dev/issues/554): Fixed: [`change`](https://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-change) event not fired when typing the first character after pasting into the editor. Thanks to [Daniel Miller](https://github.com/millerdev)! + ## CKEditor 4.7.2 New Features: diff --git a/plugins/undo/plugin.js b/plugins/undo/plugin.js index 809b457f319..a67ac3917e4 100644 --- a/plugins/undo/plugin.js +++ b/plugins/undo/plugin.js @@ -1049,6 +1049,14 @@ this.ignoreInputEvent = true; }, + /** + * Stop ignoring `input` events. + * @since 4.7.3 + */ + activateInputEventListener: function() { + this.ignoreInputEvent = false; + }, + /** * Attaches editable listeners required to provide the undo functionality. */ @@ -1080,6 +1088,9 @@ editable.attachListener( editable, 'paste', that.ignoreInputEventListener, that, null, 999 ); editable.attachListener( editable, 'drop', that.ignoreInputEventListener, that, null, 999 ); + // After paste we need to re-enable input event listener (#554). + editor.on( 'afterPaste', that.activateInputEventListener, that, null, 999 ); + // Click should create a snapshot if needed, but shouldn't cause change event. // Don't pass onNavigationKey directly as a listener because it accepts one argument which // will conflict with evt passed to listener. diff --git a/tests/plugins/undo/change.js b/tests/plugins/undo/change.js index 108ffe5820f..fb1049b58fe 100644 --- a/tests/plugins/undo/change.js +++ b/tests/plugins/undo/change.js @@ -1,5 +1,5 @@ /* bender-tags: editor */ -/* bender-ckeditor-plugins: undo,basicstyles,toolbar,wysiwygarea */ +/* bender-ckeditor-plugins: undo,clipboard,basicstyles,toolbar,wysiwygarea */ /* global undoEventDispatchTestsTools */ ( function() { @@ -180,6 +180,27 @@ // After setting text - caret is moved to beginning. We don't care - it does not change nothing. keyTools.keyEvent( keyCodesEnum.LEFT, null, true ); } ); + }, + + // #554 + 'test change event fired on type after paste': function() { + this.editorBot.setHtmlWithSelection( '

foo^

' ); + + var that = this, + keys = this.keyTools.keyCodesEnum; + + bender.tools.emulatePaste( this.editor, 'PASTE' ); + + this.editor.once( 'afterPaste', function() { + resume( function() { + changeCounter = 0; + that.checkChange( function() { + that.keyTools.keyEvent( keys.KEY_G ); + } ); + } ); + } ); + + wait(); } } ); diff --git a/tests/plugins/undo/manual/changeevent.html b/tests/plugins/undo/manual/changeevent.html new file mode 100644 index 00000000000..e974c54ae7d --- /dev/null +++ b/tests/plugins/undo/manual/changeevent.html @@ -0,0 +1,14 @@ +
+

Paste something here:

+
+
+ + diff --git a/tests/plugins/undo/manual/changeevent.md b/tests/plugins/undo/manual/changeevent.md new file mode 100644 index 00000000000..89c08cd6f93 --- /dev/null +++ b/tests/plugins/undo/manual/changeevent.md @@ -0,0 +1,10 @@ +@bender-tags: 554, 4.7.3, bug +@bender-ui: collapsed +@bender-ckeditor-plugins: undo,clipboard,basicstyles,toolbar,wysiwygarea + +---- + +1. Paste some text into the editor. +2. Type a single character after pasting. + +**Expected:** There should be exactly two change events shown below the editor.