diff --git a/services/web/frontend/js/features/source-editor/extensions/visual/visual-widgets/editable-graphics.ts b/services/web/frontend/js/features/source-editor/extensions/visual/visual-widgets/editable-graphics.ts index 0559461187..6b86b86d0f 100644 --- a/services/web/frontend/js/features/source-editor/extensions/visual/visual-widgets/editable-graphics.ts +++ b/services/web/frontend/js/features/source-editor/extensions/visual/visual-widgets/editable-graphics.ts @@ -49,9 +49,6 @@ export class EditableGraphicsWidget extends GraphicsWidget { renderGraphic(element: HTMLElement, view: EditorView) { super.renderGraphic(element, view) if (this.figureData) { - if (this.figureData.width) { - element.dataset.width = this.figureData.width.toString() - } const button = this.createEditButton(view) element.prepend(button) } diff --git a/services/web/frontend/js/features/source-editor/extensions/visual/visual-widgets/graphics.ts b/services/web/frontend/js/features/source-editor/extensions/visual/visual-widgets/graphics.ts index 3e2a9ccd3e..f7e2972b27 100644 --- a/services/web/frontend/js/features/source-editor/extensions/visual/visual-widgets/graphics.ts +++ b/services/web/frontend/js/features/source-editor/extensions/visual/visual-widgets/graphics.ts @@ -48,6 +48,12 @@ export class GraphicsWidget extends WidgetType { updateDOM(element: HTMLImageElement, view: EditorView) { this.destroyed = false element.classList.toggle('ol-cm-environment-centered', this.centered) + if ( + this.filePath === element.dataset.filepath && + element.dataset.width === this.figureData?.width?.toString() + ) { + return true + } this.renderGraphic(element, view) return true } @@ -76,7 +82,7 @@ export class GraphicsWidget extends WidgetType { const preview = this.getPreviewByPath(this.filePath) element.dataset.filepath = this.filePath - element.dataset.width = undefined + element.dataset.width = this.figureData?.width?.toString() if (!preview) { const message = document.createElement('div')