Vanessa 2025-07-14 18:03:03 +08:00
parent 7e885478ed
commit dcc0539e4b
4 changed files with 7 additions and 54 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -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) ||

View file

@ -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;
}
}