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 ace2a33a145..fdaf3d9d7f0 100644 --- a/addons/web_editor/static/src/js/backend/convert_inline.js +++ b/addons/web_editor/static/src/js/backend/convert_inline.js @@ -799,7 +799,7 @@ function fontToImg($editable) { image.style.setProperty('line-height', lineHeight); image.style.setProperty('width', intrinsicWidth + 'px'); image.style.setProperty('height', intrinsicHeight + 'px'); - image.style.setProperty('display', 'block'); + image.style.setProperty('vertical-align', 'unset'); // undo Bootstrap's default (middle). if (!padding) { image.style.setProperty('margin', _getStylePropertyValue(font, 'margin')); } @@ -815,9 +815,12 @@ function fontToImg($editable) { } font.remove(); wrapper.style.setProperty('padding', padding); - wrapper.style.setProperty('width', width + 'px'); + const wrapperWidth = width + ['left', 'right'].reduce((sum, side) => ( + sum + (+_getStylePropertyValue(image, `margin-${side}`).replace('px', '') || 0) + ), 0); + wrapper.style.setProperty('width', wrapperWidth + 'px'); wrapper.style.setProperty('height', height + 'px'); - wrapper.style.setProperty('vertical-align', 'middle'); + wrapper.style.setProperty('vertical-align', 'text-bottom'); wrapper.style.setProperty('background-color', image.style.backgroundColor); wrapper.setAttribute('class', 'oe_unbreakable ' + // prevent sanitize from grouping image wrappers @@ -905,6 +908,11 @@ function formatTables($editable) { if (alignSelf === 'start' || justifyContent === 'start' || justifyContent === 'flex-start') { cell.style.verticalAlign = 'top'; } else if (alignSelf === 'center' || justifyContent === 'center') { + const parentCell = cell.parentElement.closest('td'); + const parentTable = cell.closest('table'); + if (parentCell) { + parentTable.style.height = _getHeight(parentCell) + 'px'; + } cell.style.verticalAlign = 'middle'; } else if (alignSelf === 'end' || justifyContent === 'end' || justifyContent === 'flex-end') { cell.style.verticalAlign = 'bottom'; @@ -1317,13 +1325,12 @@ function _createMso(content='') { function _createTable(attributes = []) { const table = document.createElement('table'); Object.entries(TABLE_ATTRIBUTES).forEach(([att, value]) => table.setAttribute(att, value)); - // $table.attr(TABLE_ATTRIBUTES); - table.style.setProperty('width', '100%', 'important'); for (const attr of attributes) { if (!(attr.name === 'width' && attr.value === '100%')) { table.setAttribute(attr.name, attr.value); } } + table.style.setProperty('width', '100%', 'important'); if (table.classList.contains('o_layout')) { // The top mailing element inherits the body's font size and line-height // and should keep them.