mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
🎨 drag
This commit is contained in:
parent
e3c610aa3b
commit
af651215a9
3 changed files with 18 additions and 10 deletions
|
|
@ -379,3 +379,10 @@ img.av__cellassetimg {
|
||||||
max-width: none;
|
max-width: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html[data-theme-mode="dark"] .av__panel .b3-menu__item {
|
||||||
|
mix-blend-mode: lighten;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-theme-mode="light"] .av__panel .b3-menu__item {
|
||||||
|
mix-blend-mode: darken;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -423,8 +423,7 @@ export class Files extends Model {
|
||||||
}
|
}
|
||||||
let liElement = hasClosestByTag(event.target, "LI");
|
let liElement = hasClosestByTag(event.target, "LI");
|
||||||
if (!liElement) {
|
if (!liElement) {
|
||||||
liElement = document.elementFromPoint(event.clientX, event.clientY - 1) as HTMLElement;
|
liElement = hasClosestByTag(document.elementFromPoint(event.clientX, event.clientY - 1), "LI");
|
||||||
liElement = hasClosestByTag(liElement, "LI");
|
|
||||||
}
|
}
|
||||||
if (!liElement || !window.siyuan.dragElement) {
|
if (!liElement || !window.siyuan.dragElement) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
||||||
|
|
@ -296,13 +296,17 @@ export const openMenuPanel = (options: {
|
||||||
let dragoverElement: HTMLElement;
|
let dragoverElement: HTMLElement;
|
||||||
avPanelElement.addEventListener("dragover", (event: DragEvent) => {
|
avPanelElement.addEventListener("dragover", (event: DragEvent) => {
|
||||||
const target = event.target as HTMLElement;
|
const target = event.target as HTMLElement;
|
||||||
const targetElement = hasClosestByAttribute(target, "draggable", "true");
|
let targetElement = hasClosestByAttribute(target, "draggable", "true");
|
||||||
|
if (!targetElement) {
|
||||||
|
targetElement = hasClosestByAttribute(document.elementFromPoint(event.clientX, event.clientY - 1), "draggable", "true")
|
||||||
|
}
|
||||||
if (!targetElement || targetElement.isSameNode(window.siyuan.dragElement)) {
|
if (!targetElement || targetElement.isSameNode(window.siyuan.dragElement)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (dragoverElement && targetElement.isSameNode(dragoverElement)) {
|
if (dragoverElement && targetElement.isSameNode(dragoverElement)) {
|
||||||
const nodeRect = targetElement.getBoundingClientRect();
|
const nodeRect = targetElement.getBoundingClientRect();
|
||||||
|
targetElement.classList.remove("dragover__bottom", "dragover__top");
|
||||||
if (event.clientY > nodeRect.top + nodeRect.height / 2) {
|
if (event.clientY > nodeRect.top + nodeRect.height / 2) {
|
||||||
targetElement.classList.add("dragover__bottom");
|
targetElement.classList.add("dragover__bottom");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -312,12 +316,10 @@ export const openMenuPanel = (options: {
|
||||||
}
|
}
|
||||||
dragoverElement = targetElement;
|
dragoverElement = targetElement;
|
||||||
});
|
});
|
||||||
avPanelElement.addEventListener("dragleave", (event) => {
|
avPanelElement.addEventListener("dragleave", () => {
|
||||||
const target = event.target as HTMLElement;
|
avPanelElement.querySelectorAll(".dragover__bottom, .dragover__top").forEach((item: HTMLElement) => {
|
||||||
const targetElement = hasClosestByAttribute(target, "draggable", "true");
|
item.classList.remove("dragover__bottom", "dragover__top");
|
||||||
if (targetElement) {
|
});
|
||||||
targetElement.classList.remove("dragover__top", "dragover__bottom");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
avPanelElement.addEventListener("dragend", () => {
|
avPanelElement.addEventListener("dragend", () => {
|
||||||
if (window.siyuan.dragElement) {
|
if (window.siyuan.dragElement) {
|
||||||
|
|
@ -752,7 +754,7 @@ export const openMenuPanel = (options: {
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
if (isLocalPath(assetLink) && (
|
if (isLocalPath(assetLink) && (
|
||||||
[".pdf"].concat(Constants.SIYUAN_ASSETS_AUDIO).concat(Constants.SIYUAN_ASSETS_VIDEO).includes(suffix) && (
|
[".pdf"].concat(Constants.SIYUAN_ASSETS_AUDIO).concat(Constants.SIYUAN_ASSETS_VIDEO).includes(suffix) && (
|
||||||
suffix !== ".pdf" || ( suffix === ".pdf" && !assetLink.startsWith("file://"))
|
suffix !== ".pdf" || (suffix === ".pdf" && !assetLink.startsWith("file://"))
|
||||||
)
|
)
|
||||||
)) {
|
)) {
|
||||||
openAsset(options.protyle.app, assetLink.trim(), parseInt(getSearch("page", assetLink)), "right");
|
openAsset(options.protyle.app, assetLink.trim(), parseInt(getSearch("page", assetLink)), "right");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue