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 668b3a086f3..45c59b3faad 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js @@ -46,6 +46,7 @@ import { YOUTUBE_URL_GET_VIDEO_ID, unwrapContents, peek, + rightPos, } from './utils/utils.js'; import { editorCommands } from './commands/commands.js'; import { Powerbox } from './powerbox/Powerbox.js'; @@ -2138,7 +2139,21 @@ export class OdooEditor extends EventTarget { this.historyRollback(); ev.preventDefault(); if (this._applyCommand('oEnter') === UNBREAKABLE_ROLLBACK_CODE) { - this._applyCommand('oShiftEnter'); + const brs = this._applyCommand('oShiftEnter'); + const anchor = brs[0].parentElement; + if (anchor.nodeName === 'A') { + if (brs.includes(anchor.firstChild)) { + brs.forEach(br => anchor.before(br)); + setSelection(...rightPos(brs[brs.length - 1])); + this.sanitize(); + this.historyStep(); + } else if (brs.includes(anchor.lastChild)) { + brs.forEach(br => anchor.after(br)); + setSelection(...rightPos(brs[0])); + this.sanitize(); + this.historyStep(); + } + } } } else if (['insertText', 'insertCompositionText'].includes(ev.inputType)) { // insertCompositionText, courtesy of Samsung keyboard. diff --git a/addons/web_editor/static/lib/odoo-editor/src/commands/shiftEnter.js b/addons/web_editor/static/lib/odoo-editor/src/commands/shiftEnter.js index 3b106e124f2..20c56ee8ec3 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/commands/shiftEnter.js +++ b/addons/web_editor/static/lib/odoo-editor/src/commands/shiftEnter.js @@ -12,7 +12,7 @@ import { } from '../utils/utils.js'; Text.prototype.oShiftEnter = function (offset) { - this.parentElement.oShiftEnter(splitTextNode(this, offset)); + return this.parentElement.oShiftEnter(splitTextNode(this, offset)); }; HTMLElement.prototype.oShiftEnter = function (offset) { @@ -39,4 +39,6 @@ HTMLElement.prototype.oShiftEnter = function (offset) { break; } } + + return brEls; }; diff --git a/addons/web_editor/static/lib/odoo-editor/test/spec/collab.test.js b/addons/web_editor/static/lib/odoo-editor/test/spec/collab.test.js index 7eed71df836..9dcd7b73e7a 100644 --- a/addons/web_editor/static/lib/odoo-editor/test/spec/collab.test.js +++ b/addons/web_editor/static/lib/odoo-editor/test/spec/collab.test.js @@ -139,7 +139,7 @@ const testMultiEditor = spec => { clientInfo.editor.onExternalHistorySteps(missingSteps.concat([step])); }, }); - clientInfo.editor.keyboardType = 'PHYSICAL_KEYBOARD'; + clientInfo.editor.keyboardType = 'PHYSICAL'; const selection = selections[clientInfo.clientId]; if (selection) { setTestSelection(selection, iframeDocument); diff --git a/addons/web_editor/static/lib/odoo-editor/test/spec/editor.test.js b/addons/web_editor/static/lib/odoo-editor/test/spec/editor.test.js index 66ac039f857..ab79496d972 100644 --- a/addons/web_editor/static/lib/odoo-editor/test/spec/editor.test.js +++ b/addons/web_editor/static/lib/odoo-editor/test/spec/editor.test.js @@ -2248,6 +2248,31 @@ X[] contentAfter: '
abc
[]