summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2019-04-17 12:38:40 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2019-04-17 12:45:52 +0000
commit2830b93a3a7ca575bd6a29c34c50c902bb5c8913 (patch)
tree3fb453f572d941e55a721df497051065c909b661 /addons/web_editor/static/src
parentc8b91b0a1551766d6d1b0559a3a201a44c96167f (diff)
[FIX] web_editor: insert br within a p
Have a fieldHTML as: ``` <p> Some text <br> <br> More text </p> ``` In the Html field widget, place your cursor before the "M" press Enter to insert a newline Before this commit "Some text" and the subsequent `<br>` were deleted This was because the code: - split the original `<p>` into two ( i.e. it became ``` <p> Some text <br> <br> </p> <p> More text </p> ``` ) - took the last child of the first p, which is a text then fell back to the first p - replaced the whole p with <br> After this commit, the original p is still split, but we append the br to it instead of replacing it closes odoo/odoo#32777 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/editor/summernote.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/addons/web_editor/static/src/js/editor/summernote.js b/addons/web_editor/static/src/js/editor/summernote.js
index 36f5becce06..71130f54afb 100644
--- a/addons/web_editor/static/src/js/editor/summernote.js
+++ b/addons/web_editor/static/src/js/editor/summernote.js
@@ -1259,9 +1259,11 @@ $.summernote.pluginEvents.enter = function (event, editor, layoutInfo) {
} else {
node = dom.splitTree(last, {'node': r.sc, 'offset': r.so}) || r.sc;
if (!contentBefore) {
+ // dom.node chooses the parent if node is text
var cur = dom.node(dom.lastChild(node.previousSibling));
if (!dom.isBR(cur)) {
- $(cur).html(br);
+ // We should concat what was before with a <br>
+ $(cur).html(cur.innerHTML + br.outerHTML);
}
}
if (!dom.isVisibleText(node)) {