An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve the drag-and-drop experience in the list and super block https://github.com/siyuan-note/siyuan/issues/17893
Danielbf066f220e47
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.tsindex 5157c7d562..df88567ad6 100644--- a/app/src/protyle/util/editorCommonEvent.ts+++ b/app/src/protyle/util/editorCommonEvent.ts@@ -1183,7 +1183,29 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {}}- if (isChild && targetElement.getAttribute("data-type") === "NodeListItem") {+ // 非列表项源(如段落)拖到子列表首项上方间隙:列表只能包含列表项,段落无法成为 .li 的同级,+ // 而该间隙的语义实为"插入到父列表项内容末尾(子列表之前)",故锚点改为父列表项,+ // 将段落作为父列表项内容插到子列表之前。命中后需跳过下方 isChild/sibling 链,避免重复插入。+ let liGapIntercepted = false;+ if (!isListItemSource && !isChild && targetElement.getAttribute("data-type") === "NodeListItem") {+ const parentLi = targetElement.parentElement?.parentElement;+ if (targetClass.some((c: string) => c.indexOf("dragover__top--sibling") === 0) &&+ parentLi?.classList.contains("li")) {+ const contentLi = parentLi as HTMLElement;+ const contentBlocks = Array.from(contentLi.children).filter(+ c => c.hasAttribute("data-node-id") && !c.classList.contains("list"));+ const anchorBlock = contentBlocks.length > 0 ? contentBlocks[contentBlocks.length - 1] : null;+ if (anchorBlock) {+ // 插到最后一个内容块之后:moveTo 会把段落放在子列表之前,形成列表项内容+ dragSame(protyle, sourceElements, anchorBlock, true, event.ctrlKey);+ } else {+ dragSame(protyle, sourceElements, contentLi, isBottom, event.ctrlKey);+ }+ liGapIntercepted = true;+ }+ }++ if (!liGapIntercepted && isChild && targetElement.getAttribute("data-type") === "NodeListItem") {const nestedList = Array.from(targetElement.children).find(c => c.classList.contains("list"));let nestedTarget: Element;if (nestedList) {@@ -1212,28 +1234,6 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {dragSame(protyle, sourceElements, targetElement, isBottom, event.ctrlKey);}}- } else if (!isListItemSource && targetElement.getAttribute("data-type") === "NodeListItem") {- // 非列表项源(如段落)拖到列表项:列表只能包含列表项,段落无法成为 .li 的同级,- // 需降级为"作为某个列表项的内容插入"。两种命中:- // 1) dragover__bottom--sibling:拖到含子列表的列表项下方 → 作为该列表项内容、插到子列表之前- // 2) dragover__top--sibling:拖到子列表首项上方间隙(targetElement 是子列表首项)→- // 实为"插到父列表项内容末尾(子列表之前)",故锚点改为父列表项- const isBottomSibling = targetClass.some((c: string) => c.indexOf("dragover__bottom--sibling") === 0);- const parentLi = targetElement.parentElement?.parentElement;- const isNestedTopSibling = targetClass.some((c: string) => c.indexOf("dragover__top--sibling") === 0) &&- !!parentLi?.classList.contains("li");- if (isBottomSibling || isNestedTopSibling) {- const contentLi = isNestedTopSibling ? parentLi as HTMLElement : targetElement;- const contentBlocks = Array.from(contentLi.children).filter(- c => c.hasAttribute("data-node-id") && !c.classList.contains("list"));- const anchorBlock = contentBlocks.length > 0 ? contentBlocks[contentBlocks.length - 1] : null;- if (anchorBlock) {- // 插到最后一个内容块之后:moveTo 会把段落放在子列表之前,形成列表项内容- dragSame(protyle, sourceElements, anchorBlock, true, event.ctrlKey);- } else {- dragSame(protyle, sourceElements, contentLi, isBottom, event.ctrlKey);- }- }} else if (targetElement.parentElement.getAttribute("data-type") === "NodeSuperBlock" &&targetElement.parentElement.getAttribute("data-sb-layout") === "col") {if (targetClass.includes("dragover__left") || targetClass.includes("dragover__right")) {