[FIX] web_editor: prevent crash when inserting empty string

Before this commit, when unsing the function `insert()` with data being
an empty string, the function crashed but shouldn't.

task-2833740

X-original-commit: d44302550ddc027d4891ad04bf16c364e171e5ad
Part-of: odoo/odoo#89932
This commit is contained in:
Nicolas Bayet
2022-04-28 09:00:50 +02:00
parent c40d9e513c
commit 444fb09d1e
@@ -46,6 +46,9 @@ const TEXT_CLASSES_REGEX = /\btext-[^\s]*\b/g;
const BG_CLASSES_REGEX = /\bbg-[^\s]*\b/g;
function insert(editor, data, isText = true) {
if (!data) {
return;
}
const selection = editor.document.getSelection();
const range = selection.getRangeAt(0);
let currentNode;