From 8c8d28328662dfab0bb779c9073fbac054a14c11 Mon Sep 17 00:00:00 2001 From: shsa-odoo Date: Fri, 1 Jul 2022 07:16:32 +0000 Subject: [PATCH] [FIX] web_editor: changing header style keep its text alignment Before this commit: changing header style, changes the alignment of the selection After this commit: Now after applying header on selection it doesnot changes its alignment. Task-2641462 closes odoo/odoo#99358 X-original-commit: da8d2669b03e1016dc05f031a2a7ac840541962e Signed-off-by: David Monjoie (dmo) --- .../src/js/editor/odoo-editor/src/commands/commands.js | 5 +++++ 1 file changed, 5 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 55ae2559ed5..8ddbdb6ac6f 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 @@ -586,7 +586,12 @@ export const editorCommands = { ) { setSelection(block, 0, block, nodeSize(block)); editor.historyPauseSteps(); + // Keep the alignment and remove rest of the applied styles. + const textAlign = block.style.textAlign; editor.execCommand('removeFormat'); + if (textAlign) { + block.style.textAlign = textAlign; + } editor.historyUnpauseSteps(); const inLI = block.closest('li'); if (inLI && tagName === "P") {