[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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user