Vanessa 2025-04-17 23:33:04 +08:00
parent ee7e34706a
commit 8ece62c075
2 changed files with 65 additions and 64 deletions

View file

@ -424,7 +424,7 @@ export class WYSIWYG {
}
} else if (hasClosestByTag(range.startContainer, "TD") || hasClosestByTag(range.startContainer, "TH")) {
tempElement.innerHTML = tempElement.innerHTML.replace(/<br>/g, "\n").replace(/<br\/>/g, "\n");
textPlain = tempElement.textContent;
textPlain = tempElement.textContent.endsWith("\n") ? tempElement.textContent.replace(/\n$/, "") : tempElement.textContent;
} else if (!hasClosestByTag(range.startContainer, "CODE")) {
textPlain = range.toString();
}
@ -1683,6 +1683,7 @@ export class WYSIWYG {
textPlain = textPlain || protyle.lute.BlockDOM2StdMd(html).trimEnd(); // 需要 trimEnd否则 \n 会导致 https://github.com/siyuan-note/siyuan/issues/6218
if (nodeElement.classList.contains("table")) {
textPlain = textPlain.replace(/<br>/g, "\n").replace(/<br\/>/g, "\n");
textPlain = textPlain.endsWith("\n") ? textPlain.replace(/\n$/, "") : textPlain;
}
}
textPlain = textPlain.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382