From 9cf1ed51c17f3292bf9646f9fcfaeb8e9205eec7 Mon Sep 17 00:00:00 2001 From: Marta Motyczynska Date: Thu, 7 Sep 2023 15:47:51 +0200 Subject: [PATCH] Simplify helper function. --- packages/ckeditor5-image/src/image/utils.ts | 3 +-- .../ckeditor5-image/src/imageresize/imageresizeediting.ts | 4 ++-- packages/ckeditor5-image/src/imagesizeattributes.ts | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/ckeditor5-image/src/image/utils.ts b/packages/ckeditor5-image/src/image/utils.ts index aaf1406f7f9..2c0f1707bee 100644 --- a/packages/ckeditor5-image/src/image/utils.ts +++ b/packages/ckeditor5-image/src/image/utils.ts @@ -154,8 +154,7 @@ export function getSizeValueIfInPx( size: string | undefined ): number | null { * browser. In this case, the image looks the same as if these styles were applied to attributes instead of styles. * That's why we can upcast these styles to width & height attributes instead of resizedWidth and resizedHeight. */ -export function widthAndHeightStylesAreBothSet( editor: Editor, viewElement: ViewElement ): boolean { - const imageUtils: ImageUtils = editor.plugins.get( 'ImageUtils' ); +export function widthAndHeightStylesAreBothSet( viewElement: ViewElement ): boolean { const widthStyle = getSizeValueIfInPx( viewElement.getStyle( 'width' ) ); const heightStyle = getSizeValueIfInPx( viewElement.getStyle( 'height' ) ); diff --git a/packages/ckeditor5-image/src/imageresize/imageresizeediting.ts b/packages/ckeditor5-image/src/imageresize/imageresizeediting.ts index c8158ade8c0..006c41fc909 100644 --- a/packages/ckeditor5-image/src/imageresize/imageresizeediting.ts +++ b/packages/ckeditor5-image/src/imageresize/imageresizeediting.ts @@ -162,7 +162,7 @@ export default class ImageResizeEditing extends Plugin { model: { key: 'resizedWidth', value: ( viewElement: ViewElement ) => { - if ( widthAndHeightStylesAreBothSet( this.editor, viewElement ) ) { + if ( widthAndHeightStylesAreBothSet( viewElement ) ) { return null; } @@ -182,7 +182,7 @@ export default class ImageResizeEditing extends Plugin { model: { key: 'resizedHeight', value: ( viewElement: ViewElement ) => { - if ( widthAndHeightStylesAreBothSet( this.editor, viewElement ) ) { + if ( widthAndHeightStylesAreBothSet( viewElement ) ) { return null; } diff --git a/packages/ckeditor5-image/src/imagesizeattributes.ts b/packages/ckeditor5-image/src/imagesizeattributes.ts index 51ae2f9b571..eec5a0e1cf1 100644 --- a/packages/ckeditor5-image/src/imagesizeattributes.ts +++ b/packages/ckeditor5-image/src/imagesizeattributes.ts @@ -71,7 +71,7 @@ export default class ImageSizeAttributes extends Plugin { model: { key: 'width', value: ( viewElement: ViewElement ) => { - if ( widthAndHeightStylesAreBothSet( this.editor, viewElement ) ) { + if ( widthAndHeightStylesAreBothSet( viewElement ) ) { return getSizeValueIfInPx( viewElement.getStyle( 'width' ) ); } @@ -96,7 +96,7 @@ export default class ImageSizeAttributes extends Plugin { model: { key: 'height', value: ( viewElement: ViewElement ) => { - if ( widthAndHeightStylesAreBothSet( this.editor, viewElement ) ) { + if ( widthAndHeightStylesAreBothSet( viewElement ) ) { return getSizeValueIfInPx( viewElement.getStyle( 'height' ) ); }