mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
revert to the old wrap() behaviour
wrap2() was introduced recently to try and resolve an issue where styling outside of the wrapped section was getting lost. eg, <b>some [text] etc</b> When the user created a cloze deletion or added math tags to the [text] part, the text ended up not being bold - the inner portion is displayed without styling. wrap2() used setFormat("inserttext", ...), which did fix that issue - but it also introduced multiple new issues: - any HTML inside the selected area, including newlines and images, was lost - the unicode entities inserted when creating a cloze deletion in RTL mode end up inserted as plain text For now, I'm just going to revert to the old behaviour. If anyone has a suggestion for an approach that is able to preserve both the inner formatting and the surrounding formatting, a pull request or post on the forums would be appreciated!
This commit is contained in:
parent
69a7ee430d
commit
bf93731e49
2 changed files with 9 additions and 10 deletions
|
@ -606,7 +606,7 @@ to a cloze type first, via Edit>Change Note Type."""
|
||||||
highest += 1
|
highest += 1
|
||||||
# must start at 1
|
# must start at 1
|
||||||
highest = max(1, highest)
|
highest = max(1, highest)
|
||||||
self.web.eval("wrap2('{{c%d::', '}}');" % highest)
|
self.web.eval("wrap('{{c%d::', '}}');" % highest)
|
||||||
|
|
||||||
# Foreground colour
|
# Foreground colour
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -888,22 +888,22 @@ to a cloze type first, via Edit>Change Note Type."""
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def insertLatex(self):
|
def insertLatex(self):
|
||||||
self.web.eval("wrap2('[latex]', '[/latex]');")
|
self.web.eval("wrap('[latex]', '[/latex]');")
|
||||||
|
|
||||||
def insertLatexEqn(self):
|
def insertLatexEqn(self):
|
||||||
self.web.eval("wrap2('[$]', '[/$]');")
|
self.web.eval("wrap('[$]', '[/$]');")
|
||||||
|
|
||||||
def insertLatexMathEnv(self):
|
def insertLatexMathEnv(self):
|
||||||
self.web.eval("wrap2('[$$]', '[/$$]');")
|
self.web.eval("wrap('[$$]', '[/$$]');")
|
||||||
|
|
||||||
def insertMathjaxInline(self):
|
def insertMathjaxInline(self):
|
||||||
self.web.eval("wrap2('\\\\(', '\\\\)');")
|
self.web.eval("wrap('\\\\(', '\\\\)');")
|
||||||
|
|
||||||
def insertMathjaxBlock(self):
|
def insertMathjaxBlock(self):
|
||||||
self.web.eval("wrap2('\\\\[', '\\\\]');")
|
self.web.eval("wrap('\\\\[', '\\\\]');")
|
||||||
|
|
||||||
def insertMathjaxChemistry(self):
|
def insertMathjaxChemistry(self):
|
||||||
self.web.eval("wrap2('\\\\(\\\\ce{', '}\\\\)');")
|
self.web.eval("wrap('\\\\(\\\\ce{', '}\\\\)');")
|
||||||
|
|
||||||
# Links from HTML
|
# Links from HTML
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
|
@ -284,13 +284,12 @@ function maybeDisableButtons() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* old method, kept around for the benefit of add-ons that were using it */
|
|
||||||
function wrap(front, back) {
|
function wrap(front, back) {
|
||||||
wrapInternal(front, back, false);
|
wrapInternal(front, back, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* new method */
|
/* currently unused */
|
||||||
function wrap2(front, back) {
|
function wrapIntoText(front, back) {
|
||||||
wrapInternal(front, back, true);
|
wrapInternal(front, back, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue