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 86d84938710..80245b19007 100644 --- a/addons/web_editor/static/src/js/backend/field_html.js +++ b/addons/web_editor/static/src/js/backend/field_html.js @@ -229,7 +229,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, { * @returns {Object} */ _getWysiwygOptions: function () { - return Object.assign({}, this.nodeOptions, { + const wysiwygOptions = { recordInfo: { context: this.record.getContext(this.recordParams), res_model: this.model, @@ -246,7 +246,6 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, { iframeCssAssets: this.nodeOptions.cssEdit, snippets: this.nodeOptions.snippets, value: this.value, - allowCommandVideo: Boolean(this.nodeOptions.allowCommandVideo) && (!this.field.sanitize || !this.field.sanitize_tags), mediaModalParams: { noVideos: 'noVideos' in this.nodeOptions ? this.nodeOptions.noVideos : true, res_model: this.model, @@ -260,7 +259,20 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, { maxHeight: this.nodeOptions.maxHeight, resizable: 'resizable' in this.nodeOptions ? this.nodeOptions.resizable : false, editorPlugins: [QWebPlugin], - }); + }; + if ('allowCommandImage' in this.nodeOptions) { + // Set the option only if it is explicitly set in the view so a + // default can be set elsewhere otherwise. + wysiwygOptions.allowCommandImage = Boolean(this.nodeOptions.allowCommandImage); + } + if (this.field.sanitize && this.field.sanitize_tags) { + wysiwygOptions.allowCommandVideo = false; // Sanitized fields remove videos. + } else if ('allowCommandVideo' in this.nodeOptions) { + // Set the option only if it is explicitly set in the view so a + // default can be set elsewhere otherwise. + wysiwygOptions.allowCommandVideo = Boolean(this.nodeOptions.allowCommandVideo); + } + return Object.assign({}, this.nodeOptions, wysiwygOptions); }, /** * Toggle the code view and update the UI. diff --git a/addons/web_editor/static/src/js/backend/html_field.js b/addons/web_editor/static/src/js/backend/html_field.js index b181e45e834..d5105bd7285 100644 --- a/addons/web_editor/static/src/js/backend/html_field.js +++ b/addons/web_editor/static/src/js/backend/html_field.js @@ -616,6 +616,37 @@ HtmlField.displayName = _lt("Html"); HtmlField.supportedTypes = ["html"]; HtmlField.extractProps = ({ attrs, field }) => { + const wysiwygOptions = { + placeholder: attrs.placeholder, + noAttachment: attrs.options['no-attachment'], + inIframe: Boolean(attrs.options.cssEdit), + iframeCssAssets: attrs.options.cssEdit, + iframeHtmlClass: attrs.iframeHtmlClass, + snippets: attrs.options.snippets, + mediaModalParams: { + noVideos: 'noVideos' in attrs.options ? attrs.options.noVideos : true, + useMediaLibrary: true, + }, + linkForceNewWindow: true, + tabsize: 0, + height: attrs.options.height, + minHeight: attrs.options.minHeight, + maxHeight: attrs.options.maxHeight, + resizable: 'resizable' in attrs.options ? attrs.options.resizable : false, + editorPlugins: [QWebPlugin], + }; + if ('allowCommandImage' in attrs.options) { + // Set the option only if it is explicitly set in the view so a default + // can be set elsewhere otherwise. + wysiwygOptions.allowCommandImage = Boolean(attrs.options.allowCommandImage); + } + if (field.sanitize && field.sanitize_tags) { + wysiwygOptions.allowCommandVideo = false; // Sanitized fields remove videos. + } else if ('allowCommandVideo' in attrs.options) { + // Set the option only if it is explicitly set in the view so a default + // can be set elsewhere otherwise. + wysiwygOptions.allowCommandVideo = Boolean(attrs.options.allowCommandVideo); + } return { isTranslatable: field.translate, fieldName: field.name, @@ -629,27 +660,7 @@ HtmlField.extractProps = ({ attrs, field }) => { isInlineStyle: attrs.options['style-inline'], wrapper: attrs.options.wrapper, - wysiwygOptions: { - placeholder: attrs.placeholder, - noAttachment: attrs.options['no-attachment'], - inIframe: Boolean(attrs.options.cssEdit), - iframeCssAssets: attrs.options.cssEdit, - iframeHtmlClass: attrs.iframeHtmlClass, - snippets: attrs.options.snippets, - allowCommandImage: Boolean(attrs.options.allowCommandImage), - allowCommandVideo: Boolean(attrs.options.allowCommandVideo) && (!field.sanitize || !field.sanitize_tags), - mediaModalParams: { - noVideos: 'noVideos' in attrs.options ? attrs.options.noVideos : true, - useMediaLibrary: true, - }, - linkForceNewWindow: true, - tabsize: 0, - height: attrs.options.height, - minHeight: attrs.options.minHeight, - maxHeight: attrs.options.maxHeight, - resizable: 'resizable' in attrs.options ? attrs.options.resizable : false, - editorPlugins: [QWebPlugin], - }, + wysiwygOptions, }; };