From c7c7de056356e607910b124cfa3385d4a23c2e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Roldi?= Date: Tue, 3 Oct 2023 17:31:38 -0300 Subject: [PATCH] remove height --- .../lib/plugins/ImageEdit/ImageEdit.ts | 1 + .../plugins/ImageEdit/editInfoUtils/applyChange.ts | 1 + .../test/imageEdit/imageEditTest.ts | 14 ++++++++++++++ 3 files changed, 16 insertions(+) diff --git a/packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/ImageEdit.ts b/packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/ImageEdit.ts index aa9fce3cc5b..79793a051be 100644 --- a/packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/ImageEdit.ts +++ b/packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/ImageEdit.ts @@ -427,6 +427,7 @@ export default class ImageEdit implements EditorPlugin { this.clonedImage = this.image.cloneNode(true) as HTMLImageElement; this.clonedImage.removeAttribute('id'); this.clonedImage.style.removeProperty('max-width'); + this.clonedImage.style.removeProperty('max-height'); this.clonedImage.style.width = this.editInfo.widthPx + 'px'; this.clonedImage.style.height = this.editInfo.heightPx + 'px'; this.wrapper = createElement( diff --git a/packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/editInfoUtils/applyChange.ts b/packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/editInfoUtils/applyChange.ts index d4e8caeec20..7b093c75c66 100644 --- a/packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/editInfoUtils/applyChange.ts +++ b/packages/roosterjs-editor-plugins/lib/plugins/ImageEdit/editInfoUtils/applyChange.ts @@ -80,5 +80,6 @@ export default function applyChange( image.style.removeProperty('width'); image.style.removeProperty('height'); image.style.removeProperty('max-width'); + image.style.removeProperty('max-height'); } } diff --git a/packages/roosterjs-editor-plugins/test/imageEdit/imageEditTest.ts b/packages/roosterjs-editor-plugins/test/imageEdit/imageEditTest.ts index 6fb333f8131..18c75250913 100644 --- a/packages/roosterjs-editor-plugins/test/imageEdit/imageEditTest.ts +++ b/packages/roosterjs-editor-plugins/test/imageEdit/imageEditTest.ts @@ -362,6 +362,20 @@ describe('ImageEdit | wrapper', () => { expect(imageShadow?.style.maxWidth).toBe(''); }); + it('image selection, remove max-height', () => { + const IMG_ID = 'IMAGE_ID_SELECTION'; + const content = ``; + editor.setContent(content); + const image = document.getElementById(IMG_ID) as HTMLImageElement; + image.style.maxHeight = '100%'; + editor.focus(); + editor.select(image); + const imageParent = image.parentElement; + const shadowRoot = imageParent?.shadowRoot; + const imageShadow = shadowRoot?.querySelector('img'); + expect(imageShadow?.style.maxHeight).toBe(''); + }); + it('image selection, cloned image should use style width/height attributes', () => { const IMG_ID = 'IMAGE_ID_SELECTION_2'; const content = ``;