Vanessa 2024-04-18 19:48:09 +08:00
parent e4a128123d
commit 3f0c6675a9
3 changed files with 74 additions and 61 deletions

View file

@ -215,16 +215,19 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone", "block"]
const targetElement = element.querySelector(".dragover__bottom, .dragover__top") as HTMLElement;
if (targetElement && dragBlockElement) {
const isBottom = targetElement.classList.contains("dragover__bottom");
const previousID = isBottom ? targetElement.dataset.colId : targetElement.previousElementSibling?.getAttribute("data-col-id")
const undoPreviousID = window.siyuan.dragElement.previousElementSibling?.getAttribute("data-col-id")
if (previousID !== undoPreviousID && previousID !== window.siyuan.dragElement.dataset.colId) {
transaction(protyle, [{
action: "sortAttrViewCol",
avID: dragBlockElement.dataset.avId,
previousID: isBottom ? targetElement.dataset.colId : targetElement.previousElementSibling?.getAttribute("data-col-id"),
previousID,
id: window.siyuan.dragElement.dataset.colId,
blockID: id
}, {
action: "sortAttrViewCol",
avID: dragBlockElement.dataset.avId,
previousID: window.siyuan.dragElement.previousElementSibling?.getAttribute("data-col-id"),
previousID: undoPreviousID,
id,
blockID: id
}]);
@ -233,6 +236,7 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone", "block"]
} else {
targetElement.before(window.siyuan.dragElement);
}
}
targetElement.classList.remove("dragover__bottom", "dragover__top");
}
window.siyuan.dragElement = null;

View file

@ -389,16 +389,20 @@ export const openMenuPanel = (options: {
return;
}
if (targetElement.getAttribute("data-type") === "editCol") {
const previousID = (targetElement.classList.contains("dragover__top") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || ""
const undoPreviousID = sourceElement.previousElementSibling?.getAttribute("data-id") || "";
if (previousID !== undoPreviousID && previousID !== sourceId) {
transaction(options.protyle, [{
action: "sortAttrViewCol",
avID,
previousID: (targetElement.classList.contains("dragover__top") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
previousID,
id: sourceId,
blockID,
}], [{
action: "sortAttrViewCol",
avID,
previousID: sourceElement.previousElementSibling?.getAttribute("data-id") || "",
previousID: undoPreviousID,
id: sourceId,
blockID
}]);
@ -419,7 +423,10 @@ export const openMenuPanel = (options: {
return true;
}
});
}
menuElement.innerHTML = getPropertiesHTML(data.view);
return;
}
});
let dragoverElement: HTMLElement;
avPanelElement.addEventListener("dragover", (event: DragEvent) => {

View file

@ -843,6 +843,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
}
}
}
if (previousID !== oldPreviousID && previousID !== gutterTypes[2]) {
transaction(protyle, [{
action: "sortAttrViewCol",
avID,
@ -857,6 +858,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
blockID: blockElement.dataset.nodeId,
}]);
}
}
} else if (targetElement.classList.contains("av__row")) {
// 拖拽到属性视图内
const blockElement = hasClosestBlock(targetElement);
@ -874,7 +876,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
const undoOperations: IOperation[] = [];
const undoPreviousId = blockElement.querySelector(`[data-id="${selectedIds[0]}"]`).previousElementSibling.getAttribute("data-id") || "";
selectedIds.reverse().forEach(item => {
if (previousID !== item) {
if (previousID !== item && undoPreviousId !== previousID) {
doOperations.push({
action: "sortAttrViewRow",
avID,