[FIX] web_editor: font>a colorize a change font color
If you change the color of a link with the editor without using the link edition menu, this do not work (which might be expected), but if the text outside the font had been colorized, the font will be applied outside of the link only. This is unexpected since if we have: "hello <a>cruel</a> world!", if we select only "cruel" and change color, the change only happen to "hello" and "world!". With this changeset, an anchor in the ancestor prevent to use an ancestor font tag to change color (which prevent the issue). opw-2044551 closes #35862 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
@@ -2121,13 +2121,15 @@ $.summernote.pluginEvents.applyFont = function (event, editor, layoutInfo, color
|
||||
}
|
||||
|
||||
// apply font: foreColor, backColor, size (the color can be use a class text-... or bg-...)
|
||||
var node, font, $font, fonts = [], className;
|
||||
var node, ancestors, font, $font, fonts = [], className;
|
||||
if (color || bgcolor || size) {
|
||||
for (var i=0; i<nodes.length; i++) {
|
||||
node = nodes[i];
|
||||
|
||||
font = dom.ancestor(node, dom.isFont);
|
||||
if (!font) {
|
||||
ancestors = dom.listAncestor(node, dom.isFont);
|
||||
font = ancestors.slice(-1)[0];
|
||||
// add font if node is not inside a font or inside an anchor firstly
|
||||
if (!dom.isFont(font) || ancestors.filter(dom.isAnchor).length) {
|
||||
if (node.textContent.match(/^[ ]|[ ]$/)) {
|
||||
node.textContent = node.textContent.replace(/^[ ]|[ ]$/g, '\u00A0');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user