Skip to content

Commit

Permalink
Merge pull request #1540 from ckeditor/t/932-1529
Browse files Browse the repository at this point in the history
Fixed invalid images selection after paste in Easy Image
  • Loading branch information
mlewand authored and Comandeer committed Feb 6, 2018
2 parents 889c9d1 + 474c153 commit 748f4ed
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugins/easyimage/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@
var contextView = editor._.easyImageToolbarContext.toolbar._view;

if ( contextView.rect.visible ) {
contextView.attach( contextView._pointedElement );
// We have to disable focusing balloon toolbar to prevent loosing focus by an image (#1529).
contextView.attach( contextView._pointedElement, { focusElement: false } );
}
} );
}
Expand Down
18 changes: 18 additions & 0 deletions tests/plugins/easyimage/manual/removeafterpaste.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<p>Note, this test uses a real Cloud Service connection, so you might want to be on-line 😉.</p>

<div id="editor1">
</div>

<script src="_helpers/tools.js"></script>
<script>
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 11 ) {
bender.ignore();
}

getToken( function( token ) {
CKEDITOR.replace( 'editor1', {
cloudServices_url: 'https://files.cke-cs.com/upload/',
cloudServices_token: token
});
} );
</script>
15 changes: 15 additions & 0 deletions tests/plugins/easyimage/manual/removeafterpaste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@bender-tags: 4.9.0, bug, 1529
@bender-ui: collapsed
@bender-ckeditor-plugins: sourcearea, wysiwygarea, toolbar, easyimage, undo

1. Drag an image into editor.
2. Wait until image is uploaded.
3. Press `delete/backspace` key.

## Expected

The image has been deleted.

## Unexpected

The image has not been deleted.
21 changes: 21 additions & 0 deletions tests/plugins/easyimage/uploadintegrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,27 @@
assert.beautified.html( CKEDITOR.document.getById( 'expected-multiple-image-base64' ).getHtml(), editor.getData(), 'Editor data' );
},

// #1529
'test uploaded image has correct focus': function() {
var editor = this.editor;

this.listeners.push( this.editor.widgets.on( 'instanceCreated', function( evt ) {
var widget = evt.data;
if ( widget.name == 'easyimage' ) {
widget.once( 'uploadDone', function() {
resume( function() {
assert.areSame( editor.window.getFrame(), CKEDITOR.document.getActive(), 'Focus should remain on editor frame' );
assert.areSame( 'easyimage', editor.widgets.focused.name );
} );
} );
}
} ) );

pasteFiles( editor, [ bender.tools.getTestPngFile() ] );

wait();
},

'test pasting mixed HTML content': function() {
var editor = this.editor,
widgets;
Expand Down

0 comments on commit 748f4ed

Please sign in to comment.