[FIX] web_editor: apply original element attributes on toggle list
When converting an element to a list element, we didn't preserve that original element's attributes. As a consequence the text direction was lost. closes odoo/odoo#90247 X-original-commit: 0731ff677491d80540fa2ffc645fd2b471a9f61c Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -49,6 +49,7 @@ HTMLLIElement.prototype.oShiftTab = function () {
|
||||
return li;
|
||||
} else {
|
||||
const ul = li.parentNode;
|
||||
const dir = ul.getAttribute('dir');
|
||||
let p;
|
||||
while (li.firstChild) {
|
||||
if (isBlock(li.firstChild)) {
|
||||
@@ -56,6 +57,10 @@ HTMLLIElement.prototype.oShiftTab = function () {
|
||||
ul.after(li.firstChild);
|
||||
} else {
|
||||
p = p || document.createElement('P');
|
||||
if (dir) {
|
||||
p.setAttribute('dir', dir);
|
||||
p.style.setProperty('text-align', ul.style.getPropertyValue('text-align'));
|
||||
}
|
||||
p.append(li.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ HTMLElement.prototype.oToggleList = function (offset, mode = 'UL') {
|
||||
restoreCursor();
|
||||
} else {
|
||||
const list = insertListAfter(this, mode, [this]);
|
||||
for (const attribute of this.attributes) {
|
||||
list.setAttribute(attribute.name, attribute.value);
|
||||
}
|
||||
restoreCursor(new Map([[this, list.firstElementChild]]));
|
||||
}
|
||||
};
|
||||
@@ -37,6 +40,9 @@ HTMLElement.prototype.oToggleList = function (offset, mode = 'UL') {
|
||||
HTMLParagraphElement.prototype.oToggleList = function (offset, mode = 'UL') {
|
||||
const restoreCursor = preserveCursor(this.ownerDocument);
|
||||
const list = insertListAfter(this, mode, [[...this.childNodes]]);
|
||||
for (const attribute of this.attributes) {
|
||||
list.setAttribute(attribute.name, attribute.value);
|
||||
}
|
||||
this.remove();
|
||||
|
||||
restoreCursor(new Map([[this, list.firstChild]]));
|
||||
|
||||
Reference in New Issue
Block a user