diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js index 1ae2ae8f8b7..64f40889735 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js @@ -4811,7 +4811,16 @@ export class OdooEditor extends EventTarget { const textFragments = splitAroundUrl[i].split(/\r?\n/); let textIndex = 1; for (const textFragment of textFragments) { - this._applyCommand('insert', 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('insert', modifiedTextFragment); if (textIndex < textFragments.length) { // Break line by inserting new paragraph and // remove current paragraph's bottom margin. diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/copyPaste.test.js b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/copyPaste.test.js index 87cab3f1df9..f697cd3d90b 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/copyPaste.test.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/copyPaste.test.js @@ -275,7 +275,7 @@ describe('Paste', () => { stepFunction: async editor => { await pasteText(editor, 'x y'); }, - contentAfter: '
abx y[]cd
', + contentAfter: 'abx y[]cd
', }); }); it('should paste a text in a span', async () => { @@ -335,7 +335,7 @@ describe('Paste', () => { stepFunction: async editor => { await pasteText(editor, 'x y'); }, - contentAfter: 'ax y[]d
', + contentAfter: 'ax y[]d
', }); }); it('should paste a text in a span', async () => {