summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2018-11-02 16:54:50 +0000
committerNicolas Lempereur <nle@odoo.com>2018-11-12 11:22:43 +0000
commite0b906d74db69fce1fec09aa5807fc3863816655 (patch)
tree385fa929c6d2176c2dc2e8734b3e1c240386840b /addons/web_editor/static/src
parent8d77288a8cc801552b91118a719865685c42c847 (diff)
[FIX] web_editor: firefox ctrl+a and un/format
When we for example do ctrl+a in firefox, the selection is over the container and not the content. This is an issue when we apply a format, since the container could be removed. eg: we have selection over `<pre>hello</pre>`, on firefox the selected node is `pre`, on chromium it is `TextNode "hello"`. if we remove the style, `pre` is deleted so firefox selection is broken, whilst chrome has no issue since "hello" still exist. There was also an issue when the selection was over the blockquote, there was no error but the style could not be removed. opw-1903738 opw-1903735 closes #28369
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/editor/summernote.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/addons/web_editor/static/src/js/editor/summernote.js b/addons/web_editor/static/src/js/editor/summernote.js
index 36729ff8ed3..b3a5d36009b 100644
--- a/addons/web_editor/static/src/js/editor/summernote.js
+++ b/addons/web_editor/static/src/js/editor/summernote.js
@@ -1891,6 +1891,15 @@ $.summernote.pluginEvents.formatBlock = function (event, editor, layoutInfo, sTa
if (!r) {
return;
}
+ // select content since container (that firefox selects) may be removed
+ if (r.so === 0) {
+ r.sc = dom.firstChild(r.sc);
+ }
+ if (dom.nodeLength(r.ec) >= r.eo) {
+ r.ec = dom.lastChild(r.ec);
+ r.eo = dom.nodeLength(r.ec);
+ }
+ r = range.create(r.sc, r.so, r.ec, r.eo);
r.reRange().select();
if (sTagName === "blockquote" || sTagName === "pre") {