Skip to content

Commit

Permalink
Merge pull request #2122 from microsoft/u/juliaroldi/remove-max-height
Browse files Browse the repository at this point in the history
Remove height max-height when editing
  • Loading branch information
juliaroldi authored Oct 4, 2023
2 parents 4237327 + a09015e commit 05fe924
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
14 changes: 14 additions & 0 deletions packages/roosterjs-editor-plugins/test/imageEdit/imageEditTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<img id="${IMG_ID}" src='test'/>`;
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 = `<img id="${IMG_ID}" style="width: 300px; height: 300px" src='test'/>`;
Expand Down

0 comments on commit 05fe924

Please sign in to comment.