Merge pull request #270 from dlon/br-improve

Remove <br> from empty fields.
This commit is contained in:
Damien Elmes 2019-01-21 14:26:12 +10:00 committed by GitHub
commit 3c96492a1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 14 deletions

View file

@ -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
###################################################################### ######################################################################

View file

@ -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;

View file

@ -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' ";