Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 't/13548'
  • Loading branch information
Comandeer committed Aug 23, 2016
2 parents 8ec2d2f + fad8078 commit 24f2f3c
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -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

Expand Down
15 changes: 12 additions & 3 deletions plugins/elementspath/plugin.js
Expand Up @@ -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
Expand Down
50 changes: 48 additions & 2 deletions 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.
Expand Down Expand Up @@ -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( '<p><strong>test^</strong></p>' );

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( '<p><strong>test^</strong></p>' );

editor.once( 'selectionChange', function() {
resume( function() {
assert.areNotSame( cmd.state, CKEDITOR.TRISTATE_DISABLED );
} );
} );
editor._.elementsPath.onClick( 0 );

wait();
}
} );
} );
4 changes: 4 additions & 0 deletions tests/tickets/13548/1.html
@@ -0,0 +1,4 @@
<textarea id="editor1"><p><strong>Test</strong></p></textarea>
<script>
var editor = CKEDITOR.replace( 'editor1' );
</script>
10 changes: 10 additions & 0 deletions 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.

0 comments on commit 24f2f3c

Please sign in to comment.