From 447c7eb22274d2e107e8a565f385601d3b17df36 Mon Sep 17 00:00:00 2001
From: dhba-odoo <dhba@odoo.com>
Date: Fri, 1 Sep 2023 18:21:42 +0530
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#134240

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
---
 .../static/lib/odoo-editor/src/commands/commands.js    | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/addons/web_editor/static/lib/odoo-editor/src/commands/commands.js b/addons/web_editor/static/lib/odoo-editor/src/commands/commands.js
index e71a8cb1a6b5..b75c9075f3de 100644
--- a/addons/web_editor/static/lib/odoo-editor/src/commands/commands.js
+++ b/addons/web_editor/static/lib/odoo-editor/src/commands/commands.js
@@ -415,11 +415,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
-- 
GitLab