diff --git a/addons/web_editor/static/lib/odoo-editor/src/utils/utils.js b/addons/web_editor/static/lib/odoo-editor/src/utils/utils.js index 837c073c31d118b1e27177df4fb591b91eb2767c..50406b53d121b5b8e605f26b74589ba97ed5d470 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/utils/utils.js +++ b/addons/web_editor/static/lib/odoo-editor/src/utils/utils.js @@ -977,7 +977,7 @@ export const formatSelection = (editor, formatName, {applyStyle, formatProps} = removeFormat(splitNode, formatSpec); } else { if (firstBlockOrClassHasFormat && !applyStyle) { - formatSpec.addNeutralStyle(getOrCreateSpan(selectedTextNode, inlineAncestors)); + formatSpec.addNeutralStyle && formatSpec.addNeutralStyle(getOrCreateSpan(selectedTextNode, inlineAncestors)); } else if (!firstBlockOrClassHasFormat && applyStyle) { const tag = formatSpec.tagName && document.createElement(formatSpec.tagName); if (tag) { diff --git a/addons/web_editor/static/lib/odoo-editor/test/spec/format.test.js b/addons/web_editor/static/lib/odoo-editor/test/spec/format.test.js index b1c4c40528e818c0b172be653821918d6c6a6425..937f8819235e01a484bf68a877f3b28abeb2de98 100644 --- a/addons/web_editor/static/lib/odoo-editor/test/spec/format.test.js +++ b/addons/web_editor/static/lib/odoo-editor/test/spec/format.test.js @@ -497,6 +497,13 @@ describe('Format', () => { contentAfter: `<p>${s(`ab[]cd`)}</p>`, }); }); + it('should do nothing when a block already has a line-through decoration', async () => { + await testEditor(BasicEditor, { + contentBefore: `<p style="text-decoration: line-through;">a[b]c</p>`, + stepFunction: strikeThrough, + contentAfter: `<p style="text-decoration: line-through;">a[b]c</p>`, + }); + }); }); describe('underline + strikeThrough', () => {