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/issues/8554 调整划选范围

Vanessa842b2595ad2d
diff --git a/app/src/assets/scss/protyle/_protyle.scss b/app/src/assets/scss/protyle/_protyle.scss
index c10126f0c7..91738f76f3 100644
--- a/app/src/assets/scss/protyle/_protyle.scss
+++ b/app/src/assets/scss/protyle/_protyle.scss
@@ -199,11 +199,6 @@
background-color: var(--b3-theme-primary-lightest);
z-index: 3; // 需大于 database header and footer
pointer-events: none; // 划选矩形不拦截鼠标事件,避免 elementFromPoint 命中自身
-
- // 划选未超过一个块时不显示矩形
- &[data-empty="true"] {
- display: none;
- }
}
.protyle-breadcrumb {
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index db0e649b2c..c11a9994ad 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -1653,8 +1653,7 @@ export class WYSIWYG {
if (selectElements.length === 1 && !selectElements[0].classList.contains("list") &&
!selectElements[0].classList.contains("bq") && !selectElements[0].classList.contains("callout") &&
!selectElements[0].classList.contains("sb")) {
- // 只有一个 p 时不选中,用 data 属性标记未选中状态(矩形视觉保持可见)
- protyle.selectElement.setAttribute("data-empty", "true");
+ // 只有一个 p 时不选中块
protyle.wysiwyg.element.classList.remove("protyle-wysiwyg--hiderange");
} else {
protyle.wysiwyg.element.classList.add("protyle-wysiwyg--hiderange");
@@ -1663,7 +1662,6 @@ export class WYSIWYG {
item.classList.add("protyle-wysiwyg--select");
}
});
- protyle.selectElement.removeAttribute("data-empty");
}
};
@@ -1681,7 +1679,6 @@ export class WYSIWYG {
});
protyle.selectElement.classList.add("fn__none");
protyle.selectElement.removeAttribute("style");
- protyle.selectElement.removeAttribute("data-empty");
if (tableBlockElement) {
// @ts-ignore
tableBlockElement.firstElementChild.style.webkitUserModify = "";
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 631e064126..0fe221c3bf 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -108,7 +108,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return;
}
if (protyle.disabled ||
- (!protyle.selectElement.classList.contains("fn__none") && !protyle.selectElement.getAttribute("data-empty") &&
+ (!protyle.selectElement.classList.contains("fn__none") &&
// 框选块时放行 ⌘C,以便复制选中的块 https://github.com/siyuan-note/siyuan/issues/18043
!matchHotKey("⌘C", event))) {
event.stopPropagation();