mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
fix literal '\n' being inserted into card
This commit is contained in:
parent
b81a64272e
commit
8503ab29ab
1 changed files with 8 additions and 8 deletions
|
@ -42,7 +42,7 @@ function onKey() {
|
||||||
|
|
||||||
function insertNewline() {
|
function insertNewline() {
|
||||||
if (!inPreEnvironment()) {
|
if (!inPreEnvironment()) {
|
||||||
setFormat("insertText", "\\n");
|
setFormat("insertText", "\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,9 +59,9 @@ function insertNewline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldHeight = currentField.clientHeight;
|
var oldHeight = currentField.clientHeight;
|
||||||
setFormat("inserthtml", "\\n");
|
setFormat("inserthtml", "\n");
|
||||||
if (currentField.clientHeight === oldHeight) {
|
if (currentField.clientHeight === oldHeight) {
|
||||||
setFormat("inserthtml", "\\n");
|
setFormat("inserthtml", "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,13 +326,13 @@ function isInlineElement(n) {
|
||||||
function convertDivToNewline(node, isParagraph) {
|
function convertDivToNewline(node, isParagraph) {
|
||||||
var html = node.innerHTML;
|
var html = node.innerHTML;
|
||||||
if (isInlineElement(node.previousSibling) && html) {
|
if (isInlineElement(node.previousSibling) && html) {
|
||||||
html = "\\n" + html;
|
html = "\n" + html;
|
||||||
}
|
}
|
||||||
if (isInlineElement(node.nextSibling)) {
|
if (isInlineElement(node.nextSibling)) {
|
||||||
html += "\\n";
|
html += "\n";
|
||||||
}
|
}
|
||||||
if (isParagraph) {
|
if (isParagraph) {
|
||||||
html += "\\n";
|
html += "\n";
|
||||||
}
|
}
|
||||||
node.outerHTML = html;
|
node.outerHTML = html;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ var filterNode = function (node) {
|
||||||
if (node.nodeType === 3) {
|
if (node.nodeType === 3) {
|
||||||
if (prewrapMode) {
|
if (prewrapMode) {
|
||||||
// collapse standard whitespace
|
// collapse standard whitespace
|
||||||
var val = node.nodeValue.replace(/^[ \\r\\n\\t]+$/g, " ");
|
var val = node.nodeValue.replace(/^[ \r\n\t]+$/g, " ");
|
||||||
|
|
||||||
// non-breaking spaces can be represented as normal spaces
|
// non-breaking spaces can be represented as normal spaces
|
||||||
val = val.replace(/ |\u00a0/g, " ");
|
val = val.replace(/ |\u00a0/g, " ");
|
||||||
|
@ -376,7 +376,7 @@ var filterNode = function (node) {
|
||||||
node.outerHTML = node.innerHTML;
|
node.outerHTML = node.innerHTML;
|
||||||
}
|
}
|
||||||
} else if (prewrapMode && node.tagName === "BR") {
|
} else if (prewrapMode && node.tagName === "BR") {
|
||||||
node.outerHTML = "\\n";
|
node.outerHTML = "\n";
|
||||||
} else if (prewrapMode && node.tagName === "DIV") {
|
} else if (prewrapMode && node.tagName === "DIV") {
|
||||||
convertBlockToNewline(node, false);
|
convertBlockToNewline(node, false);
|
||||||
} else if (prewrapMode && node.tagName === "P") {
|
} else if (prewrapMode && node.tagName === "P") {
|
||||||
|
|
Loading…
Reference in a new issue