Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #330 from ckeditor/t/ckeditor5-image/310
Browse files Browse the repository at this point in the history
Other: Improved the resizer performance. Closes ckeditor/ckeditor5#5191.
  • Loading branch information
Reinmar authored Oct 16, 2019
2 parents b99cb16 + a15e79a commit c46072b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/imageresize.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe( 'ImageResize', () => {
it( 'disables the resizer if the command is disabled', () => {
setData( editor.model, `<paragraph>foo</paragraph>[<image src="${ IMAGE_SRC_FIXTURE }"></image>]` );

const resizer = editor.plugins.get( 'WidgetResize' ).resizers[ 0 ];
const resizer = getSelectedImageResizer( editor );

let isEnabled = false;

Expand Down Expand Up @@ -161,7 +161,7 @@ describe( 'ImageResize', () => {
editor.model.insertContent( writer.createElement( 'image', { src: IMAGE_SRC_FIXTURE } ) );
} );

const resizer = editor.plugins.get( 'WidgetResize' ).resizers[ 0 ];
const resizer = getSelectedImageResizer( editor );
const resizerWrapper = editor.ui.getEditableElement().querySelector( '.ck-widget__resizer' );

expect( resizer.isEnabled ).to.be.false;
Expand Down Expand Up @@ -521,7 +521,7 @@ describe( 'ImageResize', () => {

editor.commands.get( 'undo' ).execute();

await wait( 40 );
await wait( 160 ); // ui#update event is throttled.

const resizerWrapper = document.querySelector( '.ck-widget__resizer' );
const shadowBoundingRect = resizerWrapper.getBoundingClientRect();
Expand Down Expand Up @@ -668,7 +668,7 @@ describe( 'ImageResize', () => {
it( 'hides the resize wrapper when its disabled', () => {
setData( editor.model, `<paragraph>foo</paragraph>[<image src="${ IMAGE_SRC_FIXTURE }"></image>]` );

const resizer = editor.plugins.get( 'WidgetResize' ).resizers[ 0 ];
const resizer = getSelectedImageResizer( editor );
const resizerWrapper = editor.ui.getEditableElement().querySelector( '.ck-widget__resizer' );

expect( resizerWrapper.style.display ).to.equal( '' );
Expand Down Expand Up @@ -771,6 +771,12 @@ describe( 'ImageResize', () => {
editor.ui.focusTracker.isFocused = true;
}

function getSelectedImageResizer( editor ) {
return editor.plugins.get( 'WidgetResize' )._getResizerByViewElement(
editor.editing.view.document.selection.getSelectedElement()
);
}

function createEditor( config ) {
editorElement = document.createElement( 'div' );

Expand Down

0 comments on commit c46072b

Please sign in to comment.