[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:
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user