Vanessa 2025-11-30 20:20:26 +08:00
parent b65aeac03c
commit f222147848
6 changed files with 50 additions and 15 deletions

View file

@ -160,7 +160,7 @@
&-img {
height: 1.2em;
width: 1.2em;
width: 100%;
}
&-title {

View file

@ -20,6 +20,7 @@ import {hideTooltip} from "../../dialog/tooltip";
import {openFileById} from "../../editor/util";
import {checkFold} from "../../util/noRelyPCFunction";
import {hideAllElements} from "../../protyle/ui/hideElements";
import {dragOverScroll, stopScrollAnimation} from "./dragover";
export const initWindowEvent = (app: App) => {
document.body.addEventListener("mouseleave", () => {
@ -48,6 +49,53 @@ export const initWindowEvent = (app: App) => {
windowMouseMove(event, mouseIsEnter);
});
let scrollTarget: HTMLElement | false;
window.addEventListener("dragover", (event: DragEvent & { target: HTMLElement }) => {
if (event.dataTransfer.types.includes("text/plain")) {
return;
}
const fileElement = hasClosestByClassName(event.target, "sy__file");
const protyleElement = hasClosestByClassName(event.target, "protyle");
if (!scrollTarget) {
scrollTarget = fileElement || protyleElement;
}
if (scrollTarget && scrollTarget.classList.contains("sy__file") && protyleElement) {
scrollTarget = protyleElement;
} else if (scrollTarget && scrollTarget.classList.contains("protyle") && fileElement) {
scrollTarget = fileElement;
}
if (hasClosestByClassName(event.target, "layout-tab-container__drag") ||
event.dataTransfer.types.includes(Constants.SIYUAN_DROP_TAB)) {
stopScrollAnimation();
return;
}
let scrollElement;
if (scrollTarget && scrollTarget.classList.contains("sy__file")) {
scrollElement = scrollTarget.firstElementChild.nextElementSibling;
} else if (scrollTarget && scrollTarget.classList.contains("protyle")) {
scrollElement = scrollTarget.querySelector(".protyle-content");
}
if (scrollTarget && scrollElement) {
if ((event.dataTransfer.types.includes(Constants.SIYUAN_DROP_FILE) &&
hasClosestByClassName(event.target, "layout-tab-bar")) ||
(event.dataTransfer.types.includes("Files") && scrollTarget.classList.contains("sy__file"))) {
stopScrollAnimation();
} else {
dragOverScroll(event, scrollElement.getBoundingClientRect(), scrollElement);
}
} else {
stopScrollAnimation();
}
});
window.addEventListener("dragend", () => {
console.log("dragend");
stopScrollAnimation();
});
window.addEventListener("dragleave", () => {
console.log("dragleave");
stopScrollAnimation();
});
window.addEventListener("mouseup", (event) => {
if (event.button === 3) {
event.preventDefault();

View file

@ -313,11 +313,6 @@ export class Wnd {
}
saveLayout();
});
this.headersElement.parentElement.addEventListener("dragenter", (event) => {
if (event.dataTransfer.types.includes(Constants.SIYUAN_DROP_FILE)) {
stopScrollAnimation();
}
});
let elementDragCounter = 0;
this.element.addEventListener("dragenter", (event: DragEvent & { target: HTMLElement }) => {
elementDragCounter++;
@ -341,9 +336,6 @@ export class Wnd {
dragElement.removeAttribute("style");
}
});
dragElement.addEventListener("dragenter", () => {
stopScrollAnimation();
});
dragElement.addEventListener("dragover", (event: DragEvent & { layerX: number, layerY: number }) => {
document.querySelectorAll(".layout-tab-bars--drag").forEach(item => {
item.classList.remove("layout-tab-bars--drag");
@ -358,7 +350,6 @@ export class Wnd {
dragElement.addEventListener("dragleave", () => {
dragElement.classList.add("fn__none");
dragElement.removeAttribute("style");
stopScrollAnimation();
});
dragElement.addEventListener("drop", (event: DragEvent & { target: HTMLElement }) => {

View file

@ -485,13 +485,12 @@ export class Files extends Model {
item.classList.remove("layout-tab-bars--drag");
});
/// #endif
stopScrollAnimation();
});
this.element.addEventListener("dragover", (event: DragEvent & { target: HTMLElement }) => {
if (window.siyuan.config.readonly || event.dataTransfer.types.includes(Constants.SIYUAN_DROP_TAB)) {
return;
}
dragOverScroll(event, this.element.getBoundingClientRect(), this.element);
// dragOverScroll(event, this.element.getBoundingClientRect(), this.element);
let liElement = hasClosestByTag(event.target, "LI");
if (!liElement) {
liElement = hasClosestByTag(document.elementFromPoint(event.clientX, event.clientY - 1), "LI");

View file

@ -184,7 +184,6 @@ export class Gutter {
item.style.opacity = "";
});
window.siyuan.dragElement = undefined;
stopScrollAnimation();
});
this.element.addEventListener("click", (event: MouseEvent & { target: HTMLInputElement }) => {
const buttonElement = hasClosestByTag(event.target, "BUTTON");

View file

@ -1175,7 +1175,6 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
window.siyuan.dragElement.style.opacity = "";
window.siyuan.dragElement = undefined;
}
stopScrollAnimation();
});
let dragoverElement: Element;
let disabledPosition: string;
@ -1595,7 +1594,6 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
window.siyuan.dragElement = undefined;
document.onmousemove = null;
}
stopScrollAnimation();
});
};