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 1ee442858d7..da08af32367 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js @@ -2335,14 +2335,17 @@ export class OdooEditor extends EventTarget { this._lastBeforeInputType === 'insertParagraph'; if (this.keyboardType === KEYBOARD_TYPES.PHYSICAL || !wasCollapsed) { if (ev.inputType === 'deleteContentBackward') { + this._compositionStep(); this.historyRollback(); ev.preventDefault(); this._applyCommand('oDeleteBackward'); } else if (ev.inputType === 'deleteContentForward' || isChromeDeleteforward) { + this._compositionStep(); this.historyRollback(); ev.preventDefault(); this._applyCommand('oDeleteForward'); } else if (ev.inputType === 'insertParagraph' || isChromeInsertParagraph) { + this._compositionStep(); this.historyRollback(); ev.preventDefault(); if (this._applyCommand('oEnter') === UNBREAKABLE_ROLLBACK_CODE) { @@ -2404,6 +2407,7 @@ export class OdooEditor extends EventTarget { this.sanitize(); this.historyStep(); } else if (ev.inputType === 'insertLineBreak') { + this._compositionStep(); this.historyRollback(); ev.preventDefault(); this._applyCommand('oShiftEnter'); @@ -2411,6 +2415,8 @@ export class OdooEditor extends EventTarget { this.sanitize(); this.historyStep(); } + } else if (ev.inputType === 'insertCompositionText') { + this._fromCompositionText = true; } } @@ -2589,6 +2595,17 @@ export class OdooEditor extends EventTarget { this.editable.contains(selection.focusNode); } + /** + * @private + */ + _compositionStep() { + if (this._fromCompositionText) { + this._fromCompositionText = false; + this.sanitize(); + this.historyStep(); + } + } + /** * Returns true if the current selection content is only one ZWS *