Skip to content

Commit

Permalink
Simplify helper function.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmotyczynska committed Sep 7, 2023
1 parent be765a0 commit 9cf1ed5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions packages/ckeditor5-image/src/image/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-image/src/imagesizeattributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}

Expand All @@ -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' ) );
}

Expand Down

0 comments on commit 9cf1ed5

Please sign in to comment.