IE8 execCommand insertorderedlist ignores BR elements
-
11-02-2021 - |
Вопрос
Using a command like:
this.document.execCommand("insertorderedlist", false, argument);
In most browsers works correctly, however, in IE (including IE9), it includes too much text.
So, for instance, say you have the following text in a ContentEditable div, with the caret located as specified (html included for structure):
test<br>
<br>[caret]
test2
And you then execute the execCommant, you end up with a bullet point at the the very beginning, and everything is indented as part of that bullet.
Like So:
<ol>
<li> test<br>
<br>[caret]
test2
</ol>
Which is to say, IE is including surrounding text that is only separated by a <br>
. It works correctly if there is container elements (div or span).
Решение
It appears the only real solution is to not use <br>
to separate lines. Instead using <div>
or <p>
.