From c748e2f76a7b93fbe812afb88647de93682ca483 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Mon, 19 Oct 2020 11:11:54 +0000 Subject: [PATCH] [ADD] field_html: add resizer in most field_html --- .../mass_mailing/static/src/js/mass_mailing_widget.js | 1 + addons/web_editor/static/src/js/backend/field_html.js | 11 ++++++++++- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 9 ++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/addons/mass_mailing/static/src/js/mass_mailing_widget.js b/addons/mass_mailing/static/src/js/mass_mailing_widget.js index c96fb991fe0..df44fb7dc55 100644 --- a/addons/mass_mailing/static/src/js/mass_mailing_widget.js +++ b/addons/mass_mailing/static/src/js/mass_mailing_widget.js @@ -35,6 +35,7 @@ var MassMailingFieldHtml = FieldHtml.extend({ if (!this.nodeOptions.snippets) { this.nodeOptions.snippets = 'mass_mailing.email_designer_snippets'; } + this.enableResizer = false; }, //-------------------------------------------------------------------------- diff --git a/addons/web_editor/static/src/js/backend/field_html.js b/addons/web_editor/static/src/js/backend/field_html.js index 6b39ec7bf16..083f7f767b5 100644 --- a/addons/web_editor/static/src/js/backend/field_html.js +++ b/addons/web_editor/static/src/js/backend/field_html.js @@ -40,6 +40,13 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, { wysiwyg_attachment: '_onAttachmentChange', }, + /** + * @override + */ + init: function () { + this._super.apply(this, arguments); + this.enableResizer = true; + }, /** * @override */ @@ -191,6 +198,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, { res_model: this.model, res_id: this.res_id, }, + enableResizer: this.enableResizer, noAttachment: this.nodeOptions['no-attachment'], snippets: this.nodeOptions.snippets, value: this.value || '', @@ -215,7 +223,8 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
- `, + ` + + (this.enableResizer ? ` ` : ''), }); }, /** diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index d1669bb8820..1cfc7fb86bd 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -263,11 +263,18 @@ var Wysiwyg = Widget.extend({ describeImage: { handler: this.describeImage.bind(this) }, }); } + const plugins = [] + if (this.options.enableWebsite && !this.options.enableTranslation) { + plugins.push([JWEditorLib.OdooField]); + } + if (this.options.enableResizer) { + plugins.push([JWEditorLib.Resizer]); + } this.editor = new JWEditorLib.OdooWebsiteEditor(Object.assign({}, this.options, { snippetMenuElement: $mainSidebar[0], snippetManipulators: $snippetManipulators[0], customCommands: Object.assign(customCommands, this.options.customCommands), - plugins: this.options.enableWebsite && !this.options.enableTranslation ? [[this.JWEditorLib.OdooField]] : [], + plugins: plugins, source: this.value, location: this.options.location || [this.el, 'replace'], mode: this._modeConfig,