diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js index 95bf0ef2911..751f9605fde 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js @@ -220,6 +220,7 @@ export class OdooEditor extends EventTarget { showEmptyElementHint: true, defaultLinkAttributes: {}, plugins: [], + getUnremovableElements: () => [], getReadOnlyAreas: () => [], getContentEditableAreas: () => [], getPowerboxElement: () => { @@ -1947,6 +1948,9 @@ export class OdooEditor extends EventTarget { for (const node of this.options.getReadOnlyAreas()) { node.setAttribute('contenteditable', false); } + for (const element of this.options.getUnremovableElements()) { + element.classList.add("oe_unremovable"); + } this.observerActive('_activateContenteditable'); } _stopContenteditable() { diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 00484d49f3a..ce0e6074c0c 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -169,6 +169,7 @@ const Wysiwyg = Widget.extend({ controlHistoryFromDocument: this.options.controlHistoryFromDocument, getContentEditableAreas: this.options.getContentEditableAreas, getReadOnlyAreas: this.options.getReadOnlyAreas, + getUnremovableElements: this.options.getUnremovableElements, defaultLinkAttributes: this.options.userGeneratedContent ? {rel: 'ugc' } : {}, allowCommandVideo: this.options.allowCommandVideo, getYoutubeVideoElement: getYoutubeVideoElement, diff --git a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js index 08d4709c41d..c9714bb94d3 100644 --- a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js +++ b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js @@ -278,6 +278,7 @@ export class WysiwygAdapterComponent extends ComponentAdapter { bindLinkTool: true, showEmptyElementHint: false, getReadOnlyAreas: this._getReadOnlyAreas.bind(this), + getUnremovableElements: this._getUnremovableElements.bind(this), ...this.props.wysiwygOptions, }; } @@ -358,6 +359,9 @@ export class WysiwygAdapterComponent extends ComponentAdapter { _getReadOnlyAreas() { return []; } + _getUnremovableElements () { + return this.$editable[0].querySelectorAll("#top_menu a:not(.oe_unremovable)"); + } /** * This method provides support for the legacy event system. * The supported events are defined in the prototype.