Skip to content

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

:art: https://github.com/siyuan-note/siyuan/pull/13975

Vanessa3f0ec1630af2
diff --git a/app/src/protyle/ui/initUI.ts b/app/src/protyle/ui/initUI.ts
index c08f277e41..8920e6c857 100644
--- a/app/src/protyle/ui/initUI.ts
+++ b/app/src/protyle/ui/initUI.ts
@@ -115,11 +115,19 @@ export const initUI = (protyle: IProtyle) => {
}, {passive: true});
protyle.contentElement.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
// wysiwyg 元素下方点击无效果 https://github.com/siyuan-note/siyuan/issues/12009
- // 选中文本或块时,禁止添加空块 https://github.com/siyuan-note/siyuan/issues/13905
- if (protyle.disabled || window.getSelection().toString().length > 0 || event.target.querySelector(".protyle-wysiwyg--select") ||
+ if (protyle.disabled ||
+ // 选中块时,禁止添加空块 https://github.com/siyuan-note/siyuan/issues/13905
+ protyle.contentElement.querySelector(".protyle-wysiwyg--select") ||
(!event.target.classList.contains("protyle-content") && !event.target.classList.contains("protyle-wysiwyg"))) {
return;
}
+ // 选中文本禁止添加空块 https://github.com/siyuan-note/siyuan/issues/13905
+ if (window.getSelection().rangeCount > 0) {
+ const currentRange = window.getSelection().getRangeAt(0);
+ if (currentRange.toString() !== "" && protyle.wysiwyg.element.contains(currentRange.startContainer)) {
+ return;
+ }
+ }
const lastRect = protyle.wysiwyg.element.lastElementChild.getBoundingClientRect();
const range = document.createRange();
if (event.y > lastRect.bottom) {