[FIX] web_editor: factorize open Cropper from toolbar
Before this commit, the cropper tool was opened by a closure that spawned the Cropper tool aside from the editable document. This was anoying as the editable document can be in an iframe, hence the Cropper would have been virtually unusable. This commit factorizes the code in a method to allow overrides. Which is done in web_studio:ReportEditorWysiwyg. opw-3484065 closes odoo/odoo#150904 Related: odoo/enterprise#55049 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
@@ -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} $
|
||||
|
||||
Reference in New Issue
Block a user