Skip to content

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

:bug: fix https://github.com/siyuan-note/siyuan/issues/5584

Vanessabed700823478
diff --git a/app/src/protyle/wysiwyg/enter.ts b/app/src/protyle/wysiwyg/enter.ts
index 52cbd9f1fa..a96506dd17 100644
--- a/app/src/protyle/wysiwyg/enter.ts
+++ b/app/src/protyle/wysiwyg/enter.ts
@@ -211,8 +211,9 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
});
// 代码块
const trimStartText = editableElement.textContent.trimStart();
- if (trimStartText.startsWith("```") || trimStartText.startsWith("···") || trimStartText.startsWith("~~~") ||
- trimStartText.indexOf("\n```") > -1 || trimStartText.indexOf("\n~~~") > -1 || trimStartText.indexOf("\n···") > -1) {
+ if (!editableElement.querySelector('[data-type="block-ref"]') &&
+ (trimStartText.startsWith("```") || trimStartText.startsWith("···") || trimStartText.startsWith("~~~") ||
+ trimStartText.indexOf("\n```") > -1 || trimStartText.indexOf("\n~~~") > -1 || trimStartText.indexOf("\n···") > -1)) {
if (editableElement.innerHTML.indexOf("\n") === -1 && trimStartText.replace(/·|~/g, "`").replace(/^`{3,}/g, "").indexOf("`") > -1) {
// ```test` 不处理,正常渲染为段落块
} else {
diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.ts
index 5b7da1358e..37c091ba1a 100644
--- a/app/src/protyle/wysiwyg/input.ts
+++ b/app/src/protyle/wysiwyg/input.ts
@@ -62,13 +62,15 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
editElement.innerHTML = "><wbr>";
}
const trimStartText = editElement.textContent.trimStart();
- if ((trimStartText.startsWith("````") || trimStartText.startsWith("····") || trimStartText.startsWith("~~~~")) &&
+ if (!editElement.querySelector('[data-type="block-ref"]') &&
+ (trimStartText.startsWith("````") || trimStartText.startsWith("····") || trimStartText.startsWith("~~~~")) &&
editElement.innerHTML.indexOf("\n") === -1) {
// 超过三个标记符就可以形成为代码块,下方会处理
- } else if ((trimStartText.startsWith("```") || trimStartText.startsWith("···") || trimStartText.startsWith("~~~")) &&
+ } else if (!editElement.querySelector('[data-type="block-ref"]') &&
+ (trimStartText.startsWith("```") || trimStartText.startsWith("···") || trimStartText.startsWith("~~~")) &&
editElement.innerHTML.indexOf("\n") === -1 && trimStartText.replace(/·|~/g, "`").replace(/^`{3,}/g, "").indexOf("`") === -1) {
// ```test` 后续处理,```test 不处理
- updateTransaction(protyle, id, blockElement.outerHTML, protyle.wysiwyg.lastHTMLs[id]);
+ updateTransaction(protyle, id, blockElement.outerHTML, protyle.wysiwyg.lastHTMLs[id]);
wbrElement.remove();
return;
}
@@ -108,8 +110,9 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
todoOldHTML = blockElement.outerHTML;
}
} else {
- if (trimStartText.startsWith("```") || trimStartText.startsWith("~~~") || trimStartText.startsWith("···") ||
- editElement.textContent.indexOf("\n```") > -1 || editElement.textContent.indexOf("\n~~~") > -1 || editElement.textContent.indexOf("\n···") > -1) {
+ if (!editElement.querySelector('[data-type="block-ref"]') &&
+ (trimStartText.startsWith("```") || trimStartText.startsWith("~~~") || trimStartText.startsWith("···") ||
+ editElement.textContent.indexOf("\n```") > -1 || editElement.textContent.indexOf("\n~~~") > -1 || editElement.textContent.indexOf("\n···") > -1)) {
if (editElement.innerHTML.indexOf("\n") === -1 && editElement.textContent.replace(/·|~/g, "`").replace(/^`{3,}/g, "").indexOf("`") > -1) {
// ```test` 不处理,正常渲染为段落块
} else {