From 82e270d998edf946b0d64abbc153cf6ce5509386 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Thu, 10 Feb 2022 10:22:21 +0000 Subject: [PATCH] [FIX] web_editor: propagate text alignment through tables Outlook doesn't seem to properly read `text-align: inherit` on tables. This makes them explicit by fetching the alignment of the first ancestor with an explicit alignment. task-2761098 Part-of: odoo/odoo#87962 --- .../static/src/js/backend/convert_inline.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/web_editor/static/src/js/backend/convert_inline.js b/addons/web_editor/static/src/js/backend/convert_inline.js index b1a65918ce1..48ab8c9ccc4 100644 --- a/addons/web_editor/static/src/js/backend/convert_inline.js +++ b/addons/web_editor/static/src/js/backend/convert_inline.js @@ -663,6 +663,18 @@ function formatTables($editable) { cell.style.verticalAlign = 'bottom'; } } + // Tables don't properly inherit alignments from their ancestors in Outlook. + for (const table of editable.querySelectorAll('table')) { + if (table.style.textAlign === 'inherit') { + let ancestor = table; + while (ancestor && (!ancestor.style.textAlign || ancestor.style.textAlign === 'inherit')) { + ancestor = ancestor.parentElement; + } + if (ancestor) { + table.style.setProperty('text-align', ancestor.style.textAlign); + } + } + } } /** * Parse through the given document's stylesheets, preprocess(*) them and return