Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline image resizing miscalculations / Resizing an image to make it smaller sometimes does the opposite #15821

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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