mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
Merge pull request #270 from dlon/br-improve
Remove <br> from empty fields.
This commit is contained in:
commit
3c96492a1a
3 changed files with 3 additions and 14 deletions
|
@ -254,7 +254,6 @@ class Editor:
|
||||||
return
|
return
|
||||||
txt = urllib.parse.unquote(txt)
|
txt = urllib.parse.unquote(txt)
|
||||||
txt = unicodedata.normalize("NFC", txt)
|
txt = unicodedata.normalize("NFC", txt)
|
||||||
txt = self.mungeHTML(txt)
|
|
||||||
# misbehaving apps may include a null byte in the text
|
# misbehaving apps may include a null byte in the text
|
||||||
txt = txt.replace("\x00", "")
|
txt = txt.replace("\x00", "")
|
||||||
# reverse the url quoting we added to get images to display
|
# reverse the url quoting we added to get images to display
|
||||||
|
@ -286,10 +285,6 @@ class Editor:
|
||||||
else:
|
else:
|
||||||
print("uncaught cmd", cmd)
|
print("uncaught cmd", cmd)
|
||||||
|
|
||||||
def mungeHTML(self, txt):
|
|
||||||
txt = re.sub(r"<br>$", "", txt)
|
|
||||||
return txt
|
|
||||||
|
|
||||||
# Setting/unsetting the current note
|
# Setting/unsetting the current note
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
overflow-wrap: break-word;
|
overflow-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
.field:empty:before {
|
||||||
|
content: "\00a0"; /* nbsp */
|
||||||
|
}
|
||||||
.clearfix:after {
|
.clearfix:after {
|
||||||
content: "";
|
content: "";
|
||||||
display: table;
|
display: table;
|
||||||
|
|
|
@ -87,11 +87,6 @@ function inPreEnvironment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInput() {
|
function onInput() {
|
||||||
// empty field?
|
|
||||||
if (currentField.innerHTML === "") {
|
|
||||||
currentField.innerHTML = "<br>";
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure IME changes get saved
|
// make sure IME changes get saved
|
||||||
triggerKeyTimer();
|
triggerKeyTimer();
|
||||||
}
|
}
|
||||||
|
@ -292,9 +287,6 @@ function setFields(fields) {
|
||||||
for (var i = 0; i < fields.length; i++) {
|
for (var i = 0; i < fields.length; i++) {
|
||||||
var n = fields[i][0];
|
var n = fields[i][0];
|
||||||
var f = fields[i][1];
|
var f = fields[i][1];
|
||||||
if (!f) {
|
|
||||||
f = "<br>";
|
|
||||||
}
|
|
||||||
txt += "<tr><td class=fname>{0}</td></tr><tr><td width=100%>".format(n);
|
txt += "<tr><td class=fname>{0}</td></tr><tr><td width=100%>".format(n);
|
||||||
txt += "<div id=f{0} onkeydown='onKey();' oninput='onInput()' onmouseup='onKey();'".format(i);
|
txt += "<div id=f{0} onkeydown='onKey();' oninput='onInput()' onmouseup='onKey();'".format(i);
|
||||||
txt += " onfocus='onFocus(this);' onblur='onBlur();' class='field clearfix' ";
|
txt += " onfocus='onFocus(this);' onblur='onBlur();' class='field clearfix' ";
|
||||||
|
|
Loading…
Reference in a new issue