preserve contextual formatting when wrapping text

https://anki.tenderapp.com/discussions/ankidesktop/37385-cloze-is-stripping-formatting-enlarging-text

any formatting inside the selection is removed, but formatting that
starts and ends outside the selection will be preserved
This commit is contained in:
Damien Elmes 2019-12-09 12:52:18 +10:00
parent 5a5be92d09
commit b1ab681571

View file

@ -276,8 +276,8 @@ function wrap(front, back) {
var content = r.cloneContents();
var span = document.createElement("span");
span.appendChild(content);
var new_ = wrappedExceptForWhitespace(span.innerHTML, front, back);
setFormat("inserthtml", new_);
var new_ = wrappedExceptForWhitespace(span.innerText, front, back);
setFormat("inserttext", new_);
if (!span.innerHTML) {
// run with an empty selection; move cursor back past postfix
r = s.getRangeAt(0);