diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 4edb4677ada..eb391dd1417 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1895,15 +1895,7 @@ export class Wysiwyg extends Component { } this._updateMediaJustifyButton(justifyBtn.id); }); - $toolbar.find('#image-crop').click(e => { - if (!this.lastMediaClicked) { - return; - } - this.imageCropProps.media = this.lastMediaClicked; - this.imageCropProps.showCount++; - this.odooEditor.toolbarHide(); - $(this.lastMediaClicked).on('image_cropper_destroyed', () => this.odooEditor.toolbarShow()); - }); + $toolbar.find('#image-crop').click(() => this._showImageCrop()); $toolbar.find('#image-transform').click(e => { if (!this.lastMediaClicked) { return; @@ -1955,6 +1947,16 @@ export class Wysiwyg extends Component { document.addEventListener('scroll', this._onScroll, true); } } + + _showImageCrop() { + if (!this.lastMediaClicked) { + return; + } + this.imageCropProps.media = this.lastMediaClicked; + this.imageCropProps.showCount++; + this.odooEditor.toolbarHide(); + $(this.lastMediaClicked).on('image_cropper_destroyed', () => this.odooEditor.toolbarShow()); + } /** * @private * @param {jQuery} $