mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
This commit is contained in:
parent
f084f3d34f
commit
1c6538bf97
1 changed files with 28 additions and 13 deletions
|
@ -896,10 +896,14 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
window.siyuan.dragElement = target;
|
window.siyuan.dragElement = target;
|
||||||
const selectIds: string[] = [];
|
const selectIds: string[] = [];
|
||||||
blockElement.querySelectorAll(".av__gallery-item--select").forEach(item => {
|
blockElement.querySelectorAll(".av__gallery-item--select").forEach(item => {
|
||||||
selectIds.push(item.getAttribute("data-id"));
|
const bodyElement = hasClosestByClassName(item, "av__body") as HTMLElement;
|
||||||
|
const groupId = bodyElement.getAttribute("data-group-id");
|
||||||
|
selectIds.push(item.getAttribute("data-id") + (groupId ? `@${groupId}` : ""));
|
||||||
});
|
});
|
||||||
if (selectIds.length === 0) {
|
if (selectIds.length === 0) {
|
||||||
selectIds.push(target.getAttribute("data-id"));
|
const bodyElement = hasClosestByClassName(target, "av__body") as HTMLElement;
|
||||||
|
const groupId = bodyElement.getAttribute("data-group-id");
|
||||||
|
selectIds.push(target.getAttribute("data-id") + (groupId ? `@${groupId}` : ""));
|
||||||
}
|
}
|
||||||
event.dataTransfer.setData(`${Constants.SIYUAN_DROP_GUTTER}NodeAttributeView${Constants.ZWSP}GalleryItem${Constants.ZWSP}${selectIds}`,
|
event.dataTransfer.setData(`${Constants.SIYUAN_DROP_GUTTER}NodeAttributeView${Constants.ZWSP}GalleryItem${Constants.ZWSP}${selectIds}`,
|
||||||
ghostElement.outerHTML);
|
ghostElement.outerHTML);
|
||||||
|
@ -1172,10 +1176,12 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
// gallery item 内部拖拽
|
// gallery item 内部拖拽
|
||||||
const doOperations: IOperation[] = [];
|
const doOperations: IOperation[] = [];
|
||||||
const undoOperations: IOperation[] = [];
|
const undoOperations: IOperation[] = [];
|
||||||
const undoPreviousId = blockElement.querySelector(`.av__gallery-item[data-id="${selectedIds[0]}"]`).previousElementSibling?.getAttribute("data-id") || "";
|
|
||||||
const targetGroupID = targetElement.parentElement.parentElement.getAttribute("data-group-id");
|
const targetGroupID = targetElement.parentElement.parentElement.getAttribute("data-group-id");
|
||||||
selectedIds.reverse().forEach(item => {
|
selectedIds.reverse().forEach(item => {
|
||||||
const groupID = blockElement.querySelector(`.av__gallery-item[data-id="${item}"]`).parentElement.parentElement.getAttribute("data-group-id");
|
const items = item.split("@");
|
||||||
|
const id = items[0];
|
||||||
|
const groupID = items[1] || "";
|
||||||
|
const undoPreviousId = blockElement.querySelector(`.av__body[data-group-id="${groupID}"] .av__gallery-item[data-id="${id}"]`).previousElementSibling.getAttribute("data-id") || "";
|
||||||
if (previousID !== item && undoPreviousId !== previousID || (
|
if (previousID !== item && undoPreviousId !== previousID || (
|
||||||
(undoPreviousId === "" && previousID === "" && targetGroupID !== groupID)
|
(undoPreviousId === "" && previousID === "" && targetGroupID !== groupID)
|
||||||
)) {
|
)) {
|
||||||
|
@ -1183,7 +1189,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
action: "sortAttrViewRow",
|
action: "sortAttrViewRow",
|
||||||
avID,
|
avID,
|
||||||
previousID,
|
previousID,
|
||||||
id: item,
|
id,
|
||||||
blockID: blockElement.dataset.nodeId,
|
blockID: blockElement.dataset.nodeId,
|
||||||
groupID,
|
groupID,
|
||||||
targetGroupID,
|
targetGroupID,
|
||||||
|
@ -1192,7 +1198,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
action: "sortAttrViewRow",
|
action: "sortAttrViewRow",
|
||||||
avID,
|
avID,
|
||||||
previousID: undoPreviousId,
|
previousID: undoPreviousId,
|
||||||
id: item,
|
id,
|
||||||
blockID: blockElement.dataset.nodeId,
|
blockID: blockElement.dataset.nodeId,
|
||||||
groupID: targetGroupID,
|
groupID: targetGroupID,
|
||||||
targetGroupID: groupID,
|
targetGroupID: groupID,
|
||||||
|
@ -1599,27 +1605,36 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
gutterTypes[2].split(",").find(item => {
|
gutterTypes[2].split(",").find(item => {
|
||||||
if (item && item.split("@")[1] !== groupID) {
|
if (item && item.split("@")[1] !== groupID) {
|
||||||
targetElement = false;
|
targetElement = false;
|
||||||
editorElement.querySelectorAll(".dragover__bottom, .dragover__top, .dragover").forEach((item: HTMLElement) => {
|
|
||||||
item.classList.remove("dragover__top", "dragover__bottom", "dragover");
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (targetElement && gutterType && gutterType.startsWith(`${Constants.SIYUAN_DROP_GUTTER}NodeAttributeView${Constants.ZWSP}GalleryItem${Constants.ZWSP}`.toLowerCase())) {
|
} else if (targetElement && gutterType && gutterType.startsWith(`${Constants.SIYUAN_DROP_GUTTER}NodeAttributeView${Constants.ZWSP}GalleryItem${Constants.ZWSP}`.toLowerCase())) {
|
||||||
// gallery item 只能拖拽当前 av 中
|
|
||||||
const containerElement = hasClosestByClassName(event.target, "av__container");
|
const containerElement = hasClosestByClassName(event.target, "av__container");
|
||||||
if (targetElement.classList.contains("av") || !containerElement ||
|
if (targetElement.classList.contains("av") || !containerElement ||
|
||||||
!containerElement.contains(window.siyuan.dragElement) || targetElement === window.siyuan.dragElement) {
|
!containerElement.contains(window.siyuan.dragElement) || targetElement === window.siyuan.dragElement) {
|
||||||
|
// gallery item 只能拖拽当前 av 中
|
||||||
targetElement = false;
|
targetElement = false;
|
||||||
editorElement.querySelectorAll(".dragover__left, .dragover__right").forEach((item: HTMLElement) => {
|
} else {
|
||||||
item.classList.remove("dragover__left", "dragover__right");
|
// 模板、创建时间、更新时间 字段作为分组方式时不允许跨分组拖拽 https://github.com/siyuan-note/siyuan/issues/15553
|
||||||
|
const bodyElement = hasClosestByClassName(targetElement, "av__body");
|
||||||
|
if (bodyElement && ["template", "created", "updated"].includes(bodyElement.getAttribute("data-dtype"))) {
|
||||||
|
const groupID = bodyElement.getAttribute("data-group-id");
|
||||||
|
gutterTypes[2].split(",").find(item => {
|
||||||
|
if (item && item.split("@")[1] !== groupID) {
|
||||||
|
targetElement = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!targetElement) {
|
if (!targetElement) {
|
||||||
|
editorElement.querySelectorAll(".dragover__bottom, .dragover__top, .dragover, .dragover__left, .dragover__right").forEach((item: HTMLElement) => {
|
||||||
|
item.classList.remove("dragover__top", "dragover__bottom", "dragover", "dragover__left", "dragover__right");
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const isNotAvItem = !targetElement.classList.contains("av__row") &&
|
const isNotAvItem = !targetElement.classList.contains("av__row") &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue