From 4e103b25f183173518e590a6dea57e38102d6de2 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Fri, 11 Dec 2020 11:45:36 +0000 Subject: [PATCH] [FIX] web_editor: allow edition of branded nodes only To be able to be saved, nodes have to provide information on where to save them. This is done through the use of data attributes. Nodes that do not have these data attributes or are not contained within nodes that do, should therefore not be editable. Recent changes in Jabberwock ensure that the nodes with these data attributes are saved either as `OdooStructureNode` or as `OdooFieldNode` so we can simply check for these. closes odoo/odoo#63311 X-original-commit: adf778d4bb499c6beb6b54d8093ced4f81d2ac57 Signed-off-by: David Monjoie (dmo) --- .../web_editor/static/src/js/wysiwyg/wysiwyg.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 27d1aae1c03..c24a3e79071 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -96,6 +96,21 @@ var Wysiwyg = Widget.extend({ this._modeConfig = { id: 'edit', rules: [ + { + selector: [ + (node) => { + return !node.closest(ancestor => { + return ( + ancestor instanceof this.JWEditorLib.OdooStructureNode || + ancestor instanceof this.JWEditorLib.OdooFieldNode + ); + }); + }, + ], + properties: { + editable: { value: false }, + }, + }, { selector: [ (node) => {