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
Danielc4186911be6d
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.tsindex 7806a7d2a4..8f5bc16d60 100644--- a/app/src/protyle/util/editorCommonEvent.ts+++ b/app/src/protyle/util/editorCommonEvent.ts@@ -1653,14 +1653,25 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {}// 忘记为什么要限定文档树的拖拽了,先放开 https://github.com/siyuan-note/siyuan/pull/13284#issuecomment-2503853135if (liTarget) {- const htmlTarget = liTarget as HTMLElement;+ let htmlTarget = liTarget as HTMLElement;+ // 列表项上半部分映射到前一个同级列表项的下半语义("在 X 前插入" = "在 X 的前一个兄弟后插入"),+ // 避免 top--child 这类视觉位置与实际效果不一致的插入点+ if (event.clientY <= liTarget.getBoundingClientRect().top + liTarget.getBoundingClientRect().height / 2) {+ const prevLi = htmlTarget.previousElementSibling;+ if (prevLi?.classList.contains("li")) {+ htmlTarget = prevLi as HTMLElement;+ } else {+ // 列表第一个项的上半:无前驱兄弟,不显示插入点+ return;+ }+ }const nodeId = htmlTarget.getAttribute("data-node-id");// Cache expensive computations per target element (never changes while hovering same element)if (!dragCache || dragCache.nodeId !== nodeId) {- const contentBlock = Array.from(liTarget.children).find(c => c.hasAttribute("data-node-id")) as HTMLElement;+ const contentBlock = Array.from(htmlTarget.children).find(c => c.hasAttribute("data-node-id")) as HTMLElement;const indent = contentBlock ? parseFloat(getComputedStyle(contentBlock).marginLeft) || 34 : 34;- const depth = getListDepth(liTarget);- const computedColor = getComputedStyle(liTarget).getPropertyValue("--b3-theme-primary-lighter").trim();+ const depth = getListDepth(htmlTarget);+ const computedColor = getComputedStyle(htmlTarget).getPropertyValue("--b3-theme-primary-lighter").trim();const rgb = parseHexColor(computedColor) || {r: 53, g: 115, b: 217};let siblingGuides = "";for (let n = 1; n <= depth; n++) {@@ -1676,8 +1687,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {const isRTL = getComputedStyle(htmlTarget).direction === "rtl";const offsetX = isRTL ? (liRect.right - event.clientX) : (event.clientX - liRect.left);const isChild = offsetX >= indent;- const position = event.clientY > liRect.top + liRect.height / 2 ? "bottom" : "top";- const className = `dragover__${position}--${isChild ? "child" : "sibling"}`;+ const className = `dragover__bottom--${isChild ? "child" : "sibling"}`;htmlTarget.classList.add(className);htmlTarget.style.setProperty("--drag-indent", `${indent}px`);@@ -1693,9 +1703,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {window.siyuan.languages.dragTipListItemChild.replace("${x}", targetText),event.clientX, event.clientY);} else {- const key = position === "bottom" ? "dragTipListItemAfter" : "dragTipListItemBefore";showDragTip(window.siyuan.dragTitle || "",- window.siyuan.languages[key].replace("${x}", targetText),+ window.siyuan.languages.dragTipListItemAfter.replace("${x}", targetText),event.clientX, event.clientY);}return;