diff --git a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js index e895cae603e4b7b58017efb890271ed868a71e53..d8b79ecc4cae6bf15518bfb100b08402758eb245 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js @@ -3407,7 +3407,16 @@ export class OdooEditor extends EventTarget { const textFragments = splitAroundUrl[i].split(/\r?\n/); let textIndex = 1; for (const textFragment of textFragments) { - this._applyCommand('insertText', textFragment); + // Replace consecutive spaces by alternating nbsp. + const modifiedTextFragment = textFragment.replace(/( {2,})/g, match => { + let alertnateValue = false; + return match.replace(/ /g, () => { + alertnateValue = !alertnateValue; + const replaceContent = alertnateValue ? '\u00A0' : ' '; + return replaceContent; + }); + }); + this._applyCommand('insertText', modifiedTextFragment); if (textIndex < textFragments.length) { this._applyCommand('oShiftEnter'); } diff --git a/addons/web_editor/static/lib/odoo-editor/test/spec/copyPaste.test.js b/addons/web_editor/static/lib/odoo-editor/test/spec/copyPaste.test.js index d9565b37a215b9260bbf737cf2dd1b02635459f9..8c58d7c612c7912c4b0fd402f7fe109eb76fe2da 100644 --- a/addons/web_editor/static/lib/odoo-editor/test/spec/copyPaste.test.js +++ b/addons/web_editor/static/lib/odoo-editor/test/spec/copyPaste.test.js @@ -132,7 +132,7 @@ describe('Copy and paste', () => { stepFunction: async editor => { await pasteText(editor, 'x y'); }, - contentAfter: '<p>abx y[]cd</p>', + contentAfter: '<p>abx y[]cd</p>', }); }); it('should paste a text in a span', async () => { @@ -186,7 +186,7 @@ describe('Copy and paste', () => { stepFunction: async editor => { await pasteText(editor, 'x y'); }, - contentAfter: '<p>ax y[]d</p>', + contentAfter: '<p>ax y[]d</p>', }); }); it('should paste a text in a span', async () => {