From 5d51aff938b348cd7ca74733feb065d280ccfd54 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 24 Jun 2015 14:41:48 +0200 Subject: [PATCH] [FIX] summernote: insert a p tag when try to insert a br with insertNode method, if the editor is inside a p, li, h1... --- .../static/lib/summernote/src/js/core/range.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/lib/summernote/src/js/core/range.js b/addons/web_editor/static/lib/summernote/src/js/core/range.js index aa72cd31e55..9611e09c72b 100644 --- a/addons/web_editor/static/lib/summernote/src/js/core/range.js +++ b/addons/web_editor/static/lib/summernote/src/js/core/range.js @@ -474,9 +474,15 @@ define([ return this.normalize(); } - // if apply the editor to a P, LI... - if (dom.isText(sc) && /^P|^LI|^H[1-7]/.test(sc.parentNode.nodeName.toUpperCase())) { - return this.normalize(); + // if apply the editor to a P, LI... or inside a P, LI... + if (dom.isText(sc)) { + var node = sc; + while (node.parentNode !== document) { + node = node.parentNode; + if (/^(P|LI|H[1-7]|BUTTON|A|SPAN)/.test(node.nodeName.toUpperCase())) { + return this.normalize(); + } + } } // find inline top ancestor