Skip to content

Commit

Permalink
Merge pull request #15821 from ckeditor/ck/10267
Browse files Browse the repository at this point in the history
Fix (image): Fixed an issue with inline images where resizing an image to reduce its dimensions resulted in the opposite effect. Closes #10267.
  • Loading branch information
DawidKossowski committed Feb 15, 2024
2 parents 2d82998 + 5396cc0 commit 44e3c43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Expand Up @@ -104,11 +104,11 @@ export default class ImageResizeHandles extends Plugin {
// Return the model image element parent to avoid setting an inline element (<a>/<span>) as a resize host.
return domConverter.mapViewToDom( mapper.toViewElement( imageModel.parent as Element )! ) as HTMLElement;
},
// TODO consider other positions.

isCentered() {
const imageStyle = imageModel.getAttribute( 'imageStyle' );

return !imageStyle || imageStyle == 'block' || imageStyle == 'alignCenter';
return imageStyle == 'alignCenter';
},

onCommit( newValue ) {
Expand Down
Expand Up @@ -87,7 +87,7 @@ describe( 'ImageResizeHandles', () => {
resizerMouseSimulator.dragTo( editor, domParts.resizeHandle, finalPointerPosition );

expect( spy.calledOnce ).to.be.true;
expect( spy.args[ 0 ][ 0 ] ).to.deep.equal( { width: '80px' } );
expect( spy.args[ 0 ][ 0 ] ).to.deep.equal( { width: '90px' } );
} );

it( 'disables the resizer if the command is disabled', async () => {
Expand Down Expand Up @@ -146,7 +146,7 @@ describe( 'ImageResizeHandles', () => {
resizerMouseSimulator.dragTo( editor, domParts.resizeHandle, finalPointerPosition );

expect( stub.calledOnce ).to.be.true;
expect( stub.args[ 0 ][ 0 ] ).to.deep.equal( { width: '80px' } );
expect( stub.args[ 0 ][ 0 ] ).to.deep.equal( { width: '90px' } );

expect( widget.hasClass( 'image_resized' ), 'CSS class' ).to.be.false;
expect( widget.hasStyle( 'width' ), 'width style' ).to.be.false;
Expand Down Expand Up @@ -564,7 +564,7 @@ describe( 'ImageResizeHandles', () => {
resizerMouseSimulator.dragTo( editor, domParts.resizeHandle, finalPointerPosition );

expect( spy.calledOnce ).to.be.true;
expect( spy.args[ 0 ][ 0 ] ).to.deep.equal( { width: '80px' } );
expect( spy.args[ 0 ][ 0 ] ).to.deep.equal( { width: '90px' } );
} );

it( 'disables the resizer if the command is disabled', async () => {
Expand Down Expand Up @@ -807,7 +807,7 @@ describe( 'ImageResizeHandles', () => {

resizerMouseSimulator.dragTo( editor, domParts.resizeHandle, finalPointerPosition );

sinon.assert.calledWithExactly( spy.firstCall, { width: '80px' } );
sinon.assert.calledWithExactly( spy.firstCall, { width: '90px' } );

await editor.destroy();
} );
Expand Down

0 comments on commit 44e3c43

Please sign in to comment.