[FIX] web_editor: detect spaces correctly

Because of css rules, when a space was inserted (which is supposed to close the power box), it wouldn't be present in the innerText string.
It was fixed by using the textContent property instead, which contains all the spaces, including the invisible ones.
This might cause problems in some situation where the markup that the editor is modifying contains formatting spaces.

task-2584101

closes odoo/odoo#74766

Signed-off-by: Antoine Guenet <Zinston@users.noreply.github.com>
This commit is contained in:
Emilien Durieu (edu)
2021-08-10 07:56:35 +00:00
parent de2c7cff6f
commit b684ad963c
@@ -170,7 +170,7 @@ export class Powerbox {
this.show();
openOnKeyupTarget.removeEventListener('keyup', showOnceOnKeyup, true);
initialTarget = openOnKeyupTarget;
this._initialValue = openOnKeyupTarget.innerText;
this._initialValue = openOnKeyupTarget.textContent;
};
openOnKeyupTarget.addEventListener('keyup', showOnceOnKeyup, true);
@@ -188,7 +188,7 @@ export class Powerbox {
if (!initialTarget) return;
const diff = patienceDiff(
this._initialValue.split(''),
initialTarget.innerText.split(''),
initialTarget.textContent.split(''),
true,
);
this._lastText = diff.bMove.join('');
@@ -284,7 +284,7 @@ export class Powerbox {
this._currentOpenOptions = openOptions;
this._initialValue = (
this._currentOpenOptions.openOnKeyupTarget || this.options.editable
).innerText;
).textContent;
this._currentFilteredCommands = this._currentOpenOptions.commands;
this.render(this._currentOpenOptions.commands);
}