diff --git a/CHANGES.md b/CHANGES.md index 0e6b78d545e..d8cd7c2449b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ New Features: Fixed Issues: * [#13755](http://dev.ckeditor.com/ticket/13755): [Edge] Fixed: Pasting images in Edge does not work. +* [#13548](http://dev.ckeditor.com/ticket/13548): [Internet Explorer] Fixed: Clicking on element's path disables cut/copy icons. ## CKEditor 4.5.10 diff --git a/plugins/elementspath/plugin.js b/plugins/elementspath/plugin.js index 8207624b825..7ce98e00561 100644 --- a/plugins/elementspath/plugin.js +++ b/plugins/elementspath/plugin.js @@ -91,13 +91,22 @@ } ); function onClick( elementIndex ) { - var element = elementsPath.list[ elementIndex ]; + var element = elementsPath.list[ elementIndex ], + selection; + if ( element.equals( editor.editable() ) || element.getAttribute( 'contenteditable' ) == 'true' ) { var range = editor.createRange(); range.selectNodeContents( element ); - range.select(); + + selection = range.select(); } else { - editor.getSelection().selectElement( element ); + selection = editor.getSelection(); + selection.selectElement( element ); + } + + // Explicitly fire selectionChange when clicking on an element path button. (#13548) + if ( CKEDITOR.env.ie ) { + editor.fire( 'selectionChange', { selection: selection, path: new CKEDITOR.dom.elementPath( element ) } ); } // It is important to focus() *after* the above selection diff --git a/tests/core/command/command.js b/tests/core/command/command.js index 8ff915b8cc0..9edf10d11c5 100644 --- a/tests/core/command/command.js +++ b/tests/core/command/command.js @@ -1,6 +1,6 @@ /* bender-tags: editor,unit */ // jscs:disable maximumLineLength -/* bender-ckeditor-plugins: basicstyles,bidi,blockquote,button,clipboard,colorbutton,dialog,div,docprops,find,flash,font,format,forms,horizontalrule,iframe,iframedialog,image,indent,justify,link,list,listblock,maximize,newpage,pagebreak,pastefromword,pastetext,placeholder,preview,print,removeformat,save,selectall,showblocks,showborders,smiley,sourcearea,specialchar,stylescombo,table,templates,toolbar,uicolor,undo */ +/* bender-ckeditor-plugins: basicstyles,bidi,blockquote,button,clipboard,colorbutton,dialog,div,docprops,elementspath,find,flash,font,format,forms,horizontalrule,iframe,iframedialog,image,indent,justify,link,list,listblock,maximize,newpage,pagebreak,pastefromword,pastetext,placeholder,preview,print,removeformat,save,selectall,showblocks,showborders,smiley,sourcearea,specialchar,stylescombo,table,templates,toolbar,uicolor,undo */ // jscs:enable maximumLineLength // This list of commands are to be maintained whenever new commands are added. @@ -256,5 +256,51 @@ bender.test( { assert.isFalse( cmd.checkAllowed(), 'is not allowed - cache' ); assert.isTrue( cmd.checkAllowed( true ), 'is allowed - no cache' ); + }, + + // #13548 + 'test copy command not disabled after clicking on elements path': function() { + if ( !CKEDITOR.env.ie ) { + assert.ignore(); + return; + } + + var editor = this.editor, + cmd = editor.getCommand( 'copy' ); + + var bot = this.editorBot; + bot.setHtmlWithSelection( '

test^

' ); + + editor.once( 'selectionChange', function() { + resume( function() { + assert.areNotSame( cmd.state, CKEDITOR.TRISTATE_DISABLED ); + } ); + } ); + editor._.elementsPath.onClick( 0 ); + + wait(); + }, + + // #13548 + 'test cut command not disabled after clicking on elements path': function() { + if ( !CKEDITOR.env.ie ) { + assert.ignore(); + return; + } + + var editor = this.editor, + cmd = editor.getCommand( 'cut' ); + + var bot = this.editorBot; + bot.setHtmlWithSelection( '

test^

' ); + + editor.once( 'selectionChange', function() { + resume( function() { + assert.areNotSame( cmd.state, CKEDITOR.TRISTATE_DISABLED ); + } ); + } ); + editor._.elementsPath.onClick( 0 ); + + wait(); } -} ); \ No newline at end of file +} ); diff --git a/tests/tickets/13548/1.html b/tests/tickets/13548/1.html new file mode 100644 index 00000000000..91538c76fae --- /dev/null +++ b/tests/tickets/13548/1.html @@ -0,0 +1,4 @@ + + diff --git a/tests/tickets/13548/1.md b/tests/tickets/13548/1.md new file mode 100644 index 00000000000..fbc3af0fc54 --- /dev/null +++ b/tests/tickets/13548/1.md @@ -0,0 +1,10 @@ +@bender-tags: 4.5.11, tc, elementspath, 13548 +@bender-ui: collapsed +@bender-ckeditor-plugins: wysiwygarea, toolbar, clipboard, elementspath, basicstyles + +### Only in IE 9-11 + +1. Place the caret at the end of the text. +2. Click the "body" button in the elements path. + +**Expected**: "Test" should get selected and the cut and copy buttons should activate.