Skip to content

Commit

Permalink
Write max-with in the change callback. This triggers the refresh …
Browse files Browse the repository at this point in the history
…of the DOM
  • Loading branch information
Cyperghost committed Aug 21, 2024
1 parent 8f0cbce commit a1f5369
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugins/ckeditor5-woltlab-image/src/woltlabimage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class WoltlabImage extends Plugin {
dispatcher.on<DowncastInsertEvent>(
`insert:${imageType}`,
(_evt, { item }, conversionApi) => {
const { mapper, writer } = conversionApi;
const { mapper } = conversionApi;
const { domConverter } = this.editor.editing.view;

const container = mapper.toViewElement(item as Element);
Expand All @@ -99,7 +99,13 @@ export class WoltlabImage extends Plugin {
}

const setMaxWidth = () => {
writer.setStyle("max-width", `${img.naturalWidth}px`, container);
this.editor.editing.view.change((writer) => {
writer.setStyle(
"max-width",
`${img.naturalWidth}px`,
container,
);
});
};

if (img.complete && img.naturalHeight !== 0) {
Expand Down

0 comments on commit a1f5369

Please sign in to comment.