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/issues/11766

Vanessa29fc04e4a4d3
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 94e0111248..63c752e939 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -153,21 +153,33 @@ export class WYSIWYG {
// text block-ref file-annotation-ref a 结尾处打字应为普通文本
private escapeInline(protyle: IProtyle, range: Range, event: InputEvent) {
- if (!event.data) {
+ if (!event.data && event.inputType !== "insertLineBreak") {
return;
}
+
const inputData = event.data;
protyle.toolbar.range = range;
const inlineElement = range.startContainer.parentElement;
const currentTypes = protyle.toolbar.getCurrentType();
+ // https://github.com/siyuan-note/siyuan/issues/11766
+ if (event.inputType === "insertLineBreak") {
+ if (currentTypes.length > 0 && range.toString() === "" && inlineElement.tagName === "SPAN" &&
+ inlineElement.textContent.startsWith("\n") &&
+ range.startContainer.previousSibling && range.startContainer.previousSibling.textContent === "\n") {
+ inlineElement.before(range.startContainer.previousSibling);
+ }
+ return;
+ }
+
let dataLength = inputData.length;
if (inputData === "<" || inputData === ">") {
// 使用 inlineElement.innerHTML 会出现 https://ld246.com/article/1627185027423 中的第2个问题
dataLength = 4;
}
// https://github.com/siyuan-note/siyuan/issues/5924
- if (currentTypes.length > 0 && range.toString() === "" && range.startOffset === inputData.length && inlineElement.tagName === "SPAN" &&
+ if (currentTypes.length > 0 && range.toString() === "" && range.startOffset === inputData.length &&
+ inlineElement.tagName === "SPAN" &&
inlineElement.textContent.replace(Constants.ZWSP, "") !== inputData &&
inlineElement.textContent.replace(Constants.ZWSP, "").length >= inputData.length &&
!hasPreviousSibling(range.startContainer) && !hasPreviousSibling(inlineElement)) {