Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/pull/14008

Vanessa9945bb3c75be
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 671e6478e3..1931966bac 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -415,8 +415,13 @@ export class WYSIWYG {
html = tempElement.innerHTML;
}
// 不能使用 commonAncestorContainer https://ld246.com/article/1643282894693
- if (hasClosestByAttribute(range.startContainer, "data-type", "NodeCodeBlock")) {
- textPlain = tempElement.textContent.replace(Constants.ZWSP, "").replace(/\n$/, "");
+ const codeBlockElement = hasClosestByAttribute(range.startContainer, "data-type", "NodeCodeBlock");
+ if (codeBlockElement) {
+ textPlain = tempElement.textContent.replace(Constants.ZWSP, "");
+ if (range.endContainer.textContent.length === range.endOffset &&
+ (range.endContainer.parentElement.getAttribute("spellcheck") ? !range.endContainer.nextSibling : !range.endContainer.parentElement.nextSibling)) {
+ textPlain = textPlain.replace(/\n$/, "");
+ }
} else if (hasClosestByMatchTag(range.startContainer, "CODE")) {
textPlain = tempElement.textContent.replace(Constants.ZWSP, "");
} else {