Remove special treatment of empty fields in editor ts

This commit is contained in:
Henrik Giesel 2020-12-21 03:13:31 +01:00
parent 165007180a
commit 502049025a
2 changed files with 10 additions and 21 deletions

View File

@ -8,9 +8,14 @@
padding: 5px; padding: 5px;
overflow-wrap: break-word; overflow-wrap: break-word;
overflow: auto; overflow: auto;
&:empty::after {
content: "\A";
white-space: pre;
}
} }
.clearfix:after { .clearfix::after {
content: ""; content: "";
display: table; display: table;
clear: both; clear: both;

View File

@ -121,11 +121,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();
} }
@ -346,9 +341,6 @@ function setFields(fields) {
for (let i = 0; i < fields.length; i++) { for (let i = 0; i < fields.length; i++) {
const n = fields[i][0]; const n = fields[i][0];
let f = fields[i][1]; let f = fields[i][1];
if (!f) {
f = "<br>";
}
txt += ` txt += `
<tr> <tr>
<td class=fname id="name${i}">${n}</td> <td class=fname id="name${i}">${n}</td>
@ -408,20 +400,12 @@ function hideDupes() {
$("#dupes").hide(); $("#dupes").hide();
} }
/// If the field has only an empty br, remove it first.
let insertHtmlRemovingInitialBR = function (html: string) {
if (html !== "") {
// remove <br> in empty field
if (currentField && currentField.innerHTML === "<br>") {
currentField.innerHTML = "";
}
setFormat("inserthtml", html);
}
};
let pasteHTML = function (html, internal, extendedMode) { let pasteHTML = function (html, internal, extendedMode) {
html = filterHTML(html, internal, extendedMode); html = filterHTML(html, internal, extendedMode);
insertHtmlRemovingInitialBR(html);
if (html !== "") {
setFormat("inserthtml", html);
}
}; };
let filterHTML = function (html, internal, extendedMode) { let filterHTML = function (html, internal, extendedMode) {