Revert "Remove <br> from empty fields."

This reverts commit 4ca2220117.

The above commit caused a regression with RTL text:
https://anki.tenderapp.com/discussions/ankidesktop/33592-bugs-in-add-box
This commit is contained in:
Damien Elmes 2019-04-16 18:58:59 +10:00
parent 8c58e7a76a
commit 4a2f39e8f4
2 changed files with 9 additions and 3 deletions

View file

@ -8,9 +8,7 @@
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;

View file

@ -91,6 +91,11 @@ 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();
} }
@ -293,6 +298,9 @@ 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' ";