Skip to content

Commit a1f5369

Browse files
committed
Write max-with in the change callback. This triggers the refresh of the DOM
1 parent 8f0cbce commit a1f5369

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

plugins/ckeditor5-woltlab-image/src/woltlabimage.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class WoltlabImage extends Plugin {
7676
dispatcher.on<DowncastInsertEvent>(
7777
`insert:${imageType}`,
7878
(_evt, { item }, conversionApi) => {
79-
const { mapper, writer } = conversionApi;
79+
const { mapper } = conversionApi;
8080
const { domConverter } = this.editor.editing.view;
8181

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

101101
const setMaxWidth = () => {
102-
writer.setStyle("max-width", `${img.naturalWidth}px`, container);
102+
this.editor.editing.view.change((writer) => {
103+
writer.setStyle(
104+
"max-width",
105+
`${img.naturalWidth}px`,
106+
container,
107+
);
108+
});
103109
};
104110

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

0 commit comments

Comments
 (0)