Skip to content

Commit 6cf3c6d

Browse files
authored
Merge pull request #132 from WoltLab/bugifx/update-img-max-width
Write `max-with` in the `change` callback
2 parents c104293 + a1f5369 commit 6cf3c6d

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
@@ -77,7 +77,7 @@ export class WoltlabImage extends Plugin {
7777
dispatcher.on<DowncastInsertEvent>(
7878
`insert:${imageType}`,
7979
(_evt, { item }, conversionApi) => {
80-
const { mapper, writer } = conversionApi;
80+
const { mapper } = conversionApi;
8181
const { domConverter } = this.editor.editing.view;
8282

8383
const container = mapper.toViewElement(item as Element);
@@ -102,7 +102,13 @@ export class WoltlabImage extends Plugin {
102102
}
103103

104104
const setMaxWidth = () => {
105-
writer.setStyle("max-width", `${img.naturalWidth}px`, container);
105+
this.editor.editing.view.change((writer) => {
106+
writer.setStyle(
107+
"max-width",
108+
`${img.naturalWidth}px`,
109+
container,
110+
);
111+
});
106112
};
107113

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

0 commit comments

Comments
 (0)