Skip to content

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

:bug: Prevent dropping content into list markers https://github.com/siyuan-note/siyuan/issues/14834

Daniele27e86255b7d
diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts
index 80c02b6421..9b689f692b 100644
--- a/app/src/protyle/util/selection.ts
+++ b/app/src/protyle/util/selection.ts
@@ -8,7 +8,13 @@ import {
isEndOfBlock,
isNotEditBlock
} from "../wysiwyg/getBlock";
-import {hasClosestBlock, hasClosestByAttribute, hasClosestByTag, isInEmbedBlock} from "./hasClosest";
+import {
+ hasClosestBlock,
+ hasClosestByAttribute,
+ hasClosestByClassName,
+ hasClosestByTag,
+ isInEmbedBlock
+} from "./hasClosest";
import {countBlockWord, countSelectWord} from "../../layout/status";
import {hideElements} from "../ui/hideElements";
import {genRenderFrame} from "../render/util";
@@ -154,6 +160,14 @@ export const getRangeByPoint = (x: number, y: number) => {
range.setStart(imgElement.nextSibling, 0);
range.collapse();
}
+ // 列表标记不承载编辑内容,拖放命中时将插入点定位到列表项正文开头。
+ const actionElement = hasClosestByClassName(range.startContainer, "protyle-action");
+ const blockElement = actionElement && hasClosestBlock(actionElement);
+ const editableElement = blockElement && getContenteditableElement(blockElement);
+ if (editableElement) {
+ range.selectNodeContents(editableElement);
+ range.collapse(true);
+ }
return range;
};