Skip to content

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

:bug: Preserve heading structure when pasting heading sections https://github.com/siyuan-note/siyuan/issues/18419

Daniele45a7179d6bb
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts
index 848f93386b..3cfafa4b4b 100644
--- a/app/src/protyle/util/paste.ts
+++ b/app/src/protyle/util/paste.ts
@@ -729,7 +729,10 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
tempElement.querySelectorAll('[contenteditable="false"][spellcheck]').forEach((e) => {
e.setAttribute("contenteditable", "true");
});
- if (isBlock && pasteCrossBlockRange(protyle, tempElement, range)) {
+ const hasHeadingChildren = Array.from(tempElement.children).some(item =>
+ item.hasAttribute("parent-heading"));
+ // 标题及下方块需要保留块类型和折叠关系,交由 insertHTML 处理 https://github.com/siyuan-note/siyuan/issues/18419
+ if (isBlock && !hasHeadingChildren && pasteCrossBlockRange(protyle, tempElement, range)) {
blockRender(protyle, protyle.wysiwyg.element);
processRender(protyle.wysiwyg.element);
highlightRender(protyle.wysiwyg.element);