Skip to content

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

:bug: Prevent duplicate moves at nested list gaps https://github.com/siyuan-note/siyuan/issues/18304

Daniel6afc63f83e9b
diff --git a/AGENTS.md b/AGENTS.md
index 9040c9b103..5f962f3c72 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -24,6 +24,7 @@ SiYuan spans several repos. This repo (`siyuan`) holds the kernel + Electron/web
| `siyuan` | **This repo** — kernel + Electron/web/tablet UI |
| `siyuan-android` / `siyuan-ios` / `siyuan-harmony` | Native apps wrapping the gomobile kernel; build steps differ per platform — see each project's README |
| `siyuan-chrome` | Browser extension (web clipper); talks to the running kernel over HTTP only |
+| `siyuan-testing` | Playwright end-to-end tests for a running SiYuan instance; test data belongs in the `Test` notebook — see that repository's `AGENTS.md` |
| `petal` | SiYuan Plugin API declaration (the plugin system is named "petal"); consumed by plugins, not a kernel Go dependency |
| `lute` | Markdown/Kramdown AST engine — the editor + `.sy` format; also the source of the bundled `lute.min.js` (a GopherJS build served to the frontend). **Lives under `$GOPATH/src/github.com/88250/lute`, not as a sibling repo** |
| `dejavu` | Data repo / sync engine (encrypted snapshots) |
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index 476dd964c2..5ada01c061 100644
--- a/app/src/protyle/util/editorCommonEvent.ts
+++ b/app/src/protyle/util/editorCommonEvent.ts
@@ -1324,8 +1324,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
// 非列表项源(如段落)拖到子列表首项上方间隙:列表只能包含列表项,段落无法成为 .li 的同级,
// 而该间隙的语义实为"插入到父列表项内容末尾(子列表之前)",故锚点改为父列表项,
- // 将段落作为父列表项内容插到子列表之前。命中后需跳过下方 isChild/sibling 链,避免重复插入。
- let liGapIntercepted = false;
+ // 将段落作为父列表项内容插到子列表之前。命中后立即结束落盘,避免后续通用分支重复移动。
if (hasContentBlockSource && !isChild && targetElement.getAttribute("data-type") === "NodeListItem") {
const parentLi = targetElement.parentElement?.parentElement;
if (targetClass.some((c: string) => c.indexOf("dragover__top--sibling") === 0) &&
@@ -1336,22 +1335,23 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
const anchorBlock = contentBlocks.length > 0 ? contentBlocks[contentBlocks.length - 1] : null;
if (anchorBlock) {
// 插到最后一个内容块之后:moveTo 会把段落放在子列表之前,形成列表项内容
- dragSame(protyle, sourceElements, anchorBlock, true, isCopyDrag);
+ await dragSame(protyle, sourceElements, anchorBlock, true, isCopyDrag);
} else {
- dragSame(protyle, sourceElements, contentLi, isBottom, isCopyDrag);
+ await dragSame(protyle, sourceElements, contentLi, isBottom, isCopyDrag);
}
- liGapIntercepted = true;
+ dragoverElement = undefined;
+ return;
}
}
- if (!liGapIntercepted && hasContentBlockSource && !isChild &&
+ if (hasContentBlockSource && !isChild &&
targetElement.getAttribute("data-type") === "NodeListItem") {
// 普通内容块不能成为列表块的直接子节点。
dragoverElement = undefined;
return;
}
- if (!liGapIntercepted && isChild && targetElement.getAttribute("data-type") === "NodeListItem") {
+ if (isChild && targetElement.getAttribute("data-type") === "NodeListItem") {
const nestedList = Array.from(targetElement.children).find(c => c.classList.contains("list"));
let nestedTarget: Element;
if (nestedList) {