From 349bab3f4588018df4caceb1d9403250b188a11f Mon Sep 17 00:00:00 2001 From: dhba-odoo Date: Fri, 1 Sep 2023 12:51:42 +0000 Subject: [PATCH] [FIX] web_editor: clear format not working properly Before this commit: The text moves back to the left side on remove format even if the direction rtl is applied. After this commit: The text will not move to the left side on remove format if the direction rtl is applied. task-3482193 closes odoo/odoo#136849 X-original-commit: ff955e2cf74189a7cd4b175e8edfe5cfc8f31821 Signed-off-by: David Monjoie (dmo) --- .../src/js/editor/odoo-editor/src/commands/commands.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js index ae81acab42a..0a5b5bb5cf5 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js @@ -389,11 +389,21 @@ export const editorCommands = { } }, removeFormat: editor => { + const textAlignStyles = new Map(); + getTraversedNodes(editor.editable).forEach((element) => { + const block = closestBlock(element); + if (block.style.textAlign) { + textAlignStyles.set(block, block.style.textAlign); + } + }); editor.document.execCommand('removeFormat'); for (const node of getTraversedNodes(editor.editable)) { // The only possible background image on text is the gradient. closestElement(node).style.backgroundImage = ''; } + textAlignStyles.forEach((textAlign, block) => { + block.style.setProperty('text-align', textAlign); + }); }, // Align