From c1afb4156ac4754f0b57672f3e3cbf8d3547f948 Mon Sep 17 00:00:00 2001 From: Younn Olivier Date: Thu, 15 Sep 2022 07:51:38 +0000 Subject: [PATCH] [FIX] web_editor, website: fix website edition with rtl languages Before this commit, for the following flow: - Add arabic language (or any other rtl language), - On one of the websites, set it as the only website's language, - Reload and go to the client action, => The frontend is correctly displayed in rtl, - Click on edit, => The frontend, in the iframe, is reverted to ltr, The WysiwygAdapter, introduced in [1], was not passing the correct direction option to the OdooEditor, which would revert the editable to the default 'ltr' direction. [1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b task-2687506 X-original-commit: 2f463ca65b149122c85a04b20b4f82e0be479fc8 Part-of: odoo/odoo#101972 --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 2 +- .../static/src/components/wysiwyg_adapter/wysiwyg_adapter.js | 1 + addons/website/static/src/services/website_service.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index f17200bb03f..2187c607e7c 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -202,7 +202,7 @@ const Wysiwyg = Widget.extend({ commands: powerboxOptions.commands, categories: powerboxOptions.categories, plugins: options.editorPlugins, - direction: localization.direction || 'ltr', + direction: options.direction || localization.direction || 'ltr', collaborationClientAvatarUrl: `${browser.location.origin}/web/image?model=res.users&field=avatar_128&id=${this.getSession().uid}`, }, editorCollaborationOptions)); 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 e5cd7397bf7..ca075adcc68 100644 --- a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js +++ b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js @@ -279,6 +279,7 @@ export class WysiwygAdapterComponent extends ComponentAdapter { showEmptyElementHint: false, getReadOnlyAreas: this._getReadOnlyAreas.bind(this), getUnremovableElements: this._getUnremovableElements.bind(this), + direction: this.websiteService.currentWebsite.metadata.direction, ...this.props.wysiwygOptions, }; } diff --git a/addons/website/static/src/services/website_service.js b/addons/website/static/src/services/website_service.js index 5c78065b03c..764cfa43dfc 100644 --- a/addons/website/static/src/services/website_service.js +++ b/addons/website/static/src/services/website_service.js @@ -126,6 +126,7 @@ export const websiteService = { editable: !!document.getElementById('wrapwrap'), viewXmlid: viewXmlid, lang: document.documentElement.getAttribute('lang').replace('-', '_'), + direction: document.documentElement.querySelector('#wrapwrap.o_rtl') ? 'rtl' : 'ltr', }; } contentWindow = document.defaultView;