[FIX] web_editor: prevent sanitize from grouping font image wrappers

The HTML sanitization regroups similar elements into a single one.
For 'style-inline' HTML fields, the font awesome icons are converted
to images within spans.
Because of this, when sanitizing a "5 Stars" block in a 'style-inline'
HTML field, the spans are grouped and all the images end up inside a
single span, with:
- each image being `display: block;` and
- the global span having a fixed width equal to a single image's width.
This turns the horizontal succession of stars into a vertical one.

This commit adds the `oe_unbreakable` class to the image wrapping spans
to prevent sanitize from grouping them into a single one.

Note that this commit does not address the issue that upon a further
edit of the field, the Stars block is not recognized anymore. This
would require a `convert_from_inline` reverting operation which would
change many other behaviors.

Steps to reproduce:
- Go to user profile.
- Edit signature.
- Insert a "5 Stars" block (i.e. use the "/5" command).
- Save.
=> Stars became vertical.

task-2845963

X-original-commit: 9bf0b9872056e5f69a9c912825b863e0a353d5f5
Part-of: odoo/odoo#96071
This commit is contained in:
Benoit Socias
2022-07-15 19:16:07 +02:00
parent 0e26e59943
commit cbbe2029ba
@@ -709,7 +709,10 @@ function fontToImg($editable) {
wrapper.style.setProperty('height', height + 'px');
wrapper.style.setProperty('vertical-align', 'middle');
wrapper.style.setProperty('background-color', image.style.backgroundColor);
wrapper.setAttribute('class', font.getAttribute('class').replace(new RegExp('(^|\\s+)' + icon + '(-[^\\s]+)?', 'gi'), '')); // remove inline font-awsome style);
wrapper.setAttribute('class',
'oe_unbreakable ' + // prevent sanitize from grouping image wrappers
font.getAttribute('class').replace(new RegExp('(^|\\s+)' + icon + '(-[^\\s]+)?', 'gi'), '') // remove inline font-awsome style
);
} else {
font.remove();
}