From 1a595779a40200cbfea68708fb435ce773d1d859 Mon Sep 17 00:00:00 2001 From: dhba-odoo Date: Fri, 21 Jul 2023 10:08:26 +0530 Subject: [PATCH] [FIX] web_editor: unable navigate to next line of banner Before this commit: - Inserting a banner after already existing content it's impossible to go to the next line of the banner. After this commit: - It's now possible to navigate to the next line of the banner. task-3432167 X-original-commit: 05a879f81ac59d47b718abbb5966fd4f8214e1de Part-of: odoo/odoo#151735 --- .../js/editor/odoo-editor/src/utils/utils.js | 5 ++ .../odoo-editor/test/spec/htmlTables.test.js | 6 +- .../web_editor/static/tests/banner_tests.js | 85 +++++++++++++++++++ 3 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 addons/web_editor/static/tests/banner_tests.js diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js index 519e10cea28..be1dacca72f 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js @@ -1973,6 +1973,11 @@ export function splitElement(element, offset) { index < offset ? before.appendChild(child) : after.appendChild(child); index++; } + // e.g.:

Test/banner

+ ENTER <=>

Test


", + }, + ], + }, + }, + }; + setupViewRegistries(); + patchWithCleanup(Wysiwyg.prototype, { + init() { + super.init(...arguments); + wysiwyg = this; + }, + }); + await makeView({ + type: "form", + serverData, + resModel: "note", + arch: + "
" + + '' + + "", + resId: 1, + }); + }, + }, + function () { + + QUnit.module("insert a new banner"); + QUnit.test("should insert a banner followed by a paragraph", async function (assert) { + const { editor, editable } = onMount(); + const node = editable.querySelector("p"); + setSelection(node, 0); + insertText(editor, "Test"); + setSelection(node.firstChild, 3, node.firstChild, 3); + insertText(editor, '/banner'); + triggerEvent(editor.editable, "keydown", { key: "Enter" }); + await nextTick(); + assert.strictEqual( + editable.innerHTML, + `

Test

+ +
+


+
+


`, + ); + }); + } +);