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/15102

Vanessadcc0539e4b1c
diff --git a/app/src/assets/scss/component/_list.scss b/app/src/assets/scss/component/_list.scss
index 35975bec3f..4d6745ae28 100644
--- a/app/src/assets/scss/component/_list.scss
+++ b/app/src/assets/scss/component/_list.scss
@@ -9,20 +9,11 @@
&--background .b3-list-item {
border-radius: var(--b3-border-radius);
- &:hover,
+ &:hover:not(.b3-list-item--focus):not(.dragover):not(.dragover__current):not(.dragover__top):not(.dragover__bottom),
&--focus {
background-color: var(--b3-list-hover);
}
- &.dragover,
- &.dragover__top,
- &.dragover__bottom,
- &.dragover__current {
- &:hover {
- background-color: var(--b3-list-hover);
- }
- }
-
&.dragover,
&.dragover__top,
&.dragover__bottom {
diff --git a/app/src/assets/scss/main/_main.scss b/app/src/assets/scss/main/_main.scss
index 2a36d36b90..2780ec4128 100644
--- a/app/src/assets/scss/main/_main.scss
+++ b/app/src/assets/scss/main/_main.scss
@@ -284,22 +284,6 @@ html {
overflow: hidden;
transition: var(--b3-transition);
}
-
- &--dragover {
- .b3-list--background .b3-list-item:not(.b3-list-item--focus) {
- background-color: transparent;
- }
-
- .b3-list-item {
- &--hide-action .b3-list-item__action {
- display: none;
- }
-
- > * {
- pointer-events: none;
- }
- }
- }
}
.counter {
diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts
index a216eb5231..320b2712cf 100644
--- a/app/src/block/popover.ts
+++ b/app/src/block/popover.ts
@@ -16,7 +16,10 @@ export const initBlockPopover = (app: App) => {
let timeoutHide: number;
// 编辑器内容块引用/backlinks/tag/bookmark/套娃中使用
document.addEventListener("mouseover", (event: MouseEvent & { target: HTMLElement, path: HTMLElement[] }) => {
- if (!window.siyuan.config || !window.siyuan.menus) {
+ if (!window.siyuan.config || !window.siyuan.menus ||
+ // 拖拽时禁止
+ window.siyuan.dragElement || document.onmousemove) {
+ hideTooltip();
return;
}
const aElement = hasClosestByAttribute(event.target, "data-type", "a", true) ||
diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts
index 7c93cf993a..8231572309 100644
--- a/app/src/layout/dock/Files.ts
+++ b/app/src/layout/dock/Files.ts
@@ -40,8 +40,6 @@ export class Files extends Model {
public parent: Tab;
private actionsElement: HTMLElement;
public closeElement: HTMLElement;
- private cachedContentRect: DOMRect | null = null;
- private cachedElementRects: Map<HTMLElement, DOMRect> = new Map();
constructor(options: { tab: Tab, app: App }) {
super({
@@ -426,15 +424,10 @@ export class Files extends Model {
event.preventDefault();
return;
}
- this.element.classList.add("file-tree--dragover");
window.getSelection().removeAllRanges();
hideTooltip();
const liElement = hasClosestByTag(event.target, "LI");
if (liElement) {
- this.cachedElementRects.clear();
- this.element.querySelectorAll("li.b3-list-item").forEach((item: HTMLElement) => {
- this.cachedElementRects.set(item, item.getBoundingClientRect());
- });
let selectElements: Element[] = Array.from(this.element.querySelectorAll(".b3-list-item--focus"));
if (!liElement.classList.contains("b3-list-item--focus")) {
selectElements.forEach((item) => {
@@ -471,7 +464,6 @@ export class Files extends Model {
}
});
this.element.addEventListener("dragend", () => {
- this.element.classList.remove("file-tree--dragover");
this.element.querySelectorAll(".b3-list-item--focus").forEach((item: HTMLElement, index) => {
item.style.opacity = "";
// https://github.com/siyuan-note/siyuan/issues/11587
@@ -483,8 +475,6 @@ export class Files extends Model {
}
});
window.siyuan.dragElement = undefined;
- this.cachedContentRect = null;
- this.cachedElementRects.clear();
/// #if !BROWSER
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "resetTabsStyle", data: "rmDragStyle"});
/// #else
@@ -497,16 +487,7 @@ export class Files extends Model {
if (window.siyuan.config.readonly || event.dataTransfer.types.includes(Constants.SIYUAN_DROP_TAB)) {
return;
}
- // 避免在 dragover 中频繁调用 getBoundingClientRect()
- if (this.cachedElementRects.size === 0) {
- this.element.querySelectorAll("li.b3-list-item").forEach((item: HTMLElement) => {
- this.cachedElementRects.set(item, item.getBoundingClientRect());
- });
- }
- if (!this.cachedContentRect) {
- this.cachedContentRect = this.element.getBoundingClientRect();
- }
- const contentRect = this.cachedContentRect;
+ const contentRect = this.element.getBoundingClientRect();
if (event.clientY < contentRect.top + Constants.SIZE_SCROLL_TB || event.clientY > contentRect.bottom - Constants.SIZE_SCROLL_TB) {
this.element.scroll({
top: this.element.scrollTop + (event.clientY < contentRect.top + Constants.SIZE_SCROLL_TB ? -Constants.SIZE_SCROLL_STEP : Constants.SIZE_SCROLL_STEP),
@@ -562,8 +543,7 @@ export class Files extends Model {
(!sourceOnlyRoot && targetType !== "navigation-root" &&
(notebookSort === "6" || (window.siyuan.config.fileTree.sort === 6 && notebookSort === "15")))
) {
- // 避免在 dragover 中频繁调用 getBoundingClientRect()
- const nodeRect = this.cachedElementRects.get(liElement as HTMLElement) || liElement.getBoundingClientRect();
+ const nodeRect = liElement.getBoundingClientRect();
const dragHeight = nodeRect.height * .2;
if (targetType === "navigation-root" && sourceOnlyRoot) {
if (event.clientY > nodeRect.top + nodeRect.height / 2) {
@@ -593,8 +573,6 @@ export class Files extends Model {
this.element.querySelectorAll(".dragover, .dragover__bottom, .dragover__top").forEach((item: HTMLElement) => {
item.classList.remove("dragover", "dragover__bottom", "dragover__top");
});
- this.cachedContentRect = null;
- this.cachedElementRects.clear();
}
});
this.element.addEventListener("dragenter", (event) => {
@@ -783,8 +761,6 @@ export class Files extends Model {
}
}
newElement.classList.remove("dragover", "dragover__bottom", "dragover__top");
- this.cachedContentRect = null;
- this.cachedElementRects.clear();
});
this.init();
if (window.siyuan.config.openHelp) {
@@ -1339,4 +1315,3 @@ aria-label="${ariaLabel}">${getDisplayName(item.name, true, true)}</span>
return window.siyuan.menus.menu;
}
}
-