[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
This commit is contained in:
Nicolas Lempereur
2018-11-12 11:22:43 +00:00
parent 8d77288a8c
commit e0b906d74d
@@ -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") {