Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/11048

Vanessa3f0c6675a9e4
diff --git a/app/src/protyle/render/av/blockAttr.ts b/app/src/protyle/render/av/blockAttr.ts
index e80ed1a3b3..18dd642709 100644
--- a/app/src/protyle/render/av/blockAttr.ts
+++ b/app/src/protyle/render/av/blockAttr.ts
@@ -215,23 +215,27 @@ 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");
- transaction(protyle, [{
- action: "sortAttrViewCol",
- avID: dragBlockElement.dataset.avId,
- previousID: isBottom ? targetElement.dataset.colId : targetElement.previousElementSibling?.getAttribute("data-col-id"),
- id: window.siyuan.dragElement.dataset.colId,
- blockID: id
- }, {
- action: "sortAttrViewCol",
- avID: dragBlockElement.dataset.avId,
- previousID: window.siyuan.dragElement.previousElementSibling?.getAttribute("data-col-id"),
- id,
- blockID: id
- }]);
- if (isBottom) {
- targetElement.after(window.siyuan.dragElement);
- } else {
- targetElement.before(window.siyuan.dragElement);
+ 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,
+ id: window.siyuan.dragElement.dataset.colId,
+ blockID: id
+ }, {
+ action: "sortAttrViewCol",
+ avID: dragBlockElement.dataset.avId,
+ previousID: undoPreviousID,
+ id,
+ blockID: id
+ }]);
+ if (isBottom) {
+ targetElement.after(window.siyuan.dragElement);
+ } else {
+ targetElement.before(window.siyuan.dragElement);
+ }
}
targetElement.classList.remove("dragover__bottom", "dragover__top");
}
diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts
index a2f4432eff..91789c89f8 100644
--- a/app/src/protyle/render/av/openMenuPanel.ts
+++ b/app/src/protyle/render/av/openMenuPanel.ts
@@ -389,37 +389,44 @@ export const openMenuPanel = (options: {
return;
}
- transaction(options.protyle, [{
- action: "sortAttrViewCol",
- avID,
- previousID: (targetElement.classList.contains("dragover__top") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
- id: sourceId,
- blockID,
- }], [{
- action: "sortAttrViewCol",
- avID,
- previousID: sourceElement.previousElementSibling?.getAttribute("data-id") || "",
- id: sourceId,
- blockID
- }]);
- let column: IAVColumn;
- data.view.columns.find((item, index: number) => {
- if (item.id === sourceId) {
- column = data.view.columns.splice(index, 1)[0];
- return true;
- }
- });
- data.view.columns.find((item, index: number) => {
- if (item.id === targetId) {
- if (isTop) {
- data.view.columns.splice(index, 0, column);
- } else {
- data.view.columns.splice(index + 1, 0, column);
- }
- return true;
+ 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,
+ id: sourceId,
+ blockID,
+ }], [{
+ action: "sortAttrViewCol",
+ avID,
+ previousID: undoPreviousID,
+ id: sourceId,
+ blockID
+ }]);
+ let column: IAVColumn;
+ data.view.columns.find((item, index: number) => {
+ if (item.id === sourceId) {
+ column = data.view.columns.splice(index, 1)[0];
+ return true;
+ }
+ });
+ data.view.columns.find((item, index: number) => {
+ if (item.id === targetId) {
+ if (isTop) {
+ data.view.columns.splice(index, 0, column);
+ } else {
+ data.view.columns.splice(index + 1, 0, column);
+ }
+ return true;
+ }
+ });
}
- });
- menuElement.innerHTML = getPropertiesHTML(data.view);
+ menuElement.innerHTML = getPropertiesHTML(data.view);
+ return;
+ }
});
let dragoverElement: HTMLElement;
avPanelElement.addEventListener("dragover", (event: DragEvent) => {
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index e1c9cb3eda..ca4746f670 100644
--- a/app/src/protyle/util/editorCommonEvent.ts
+++ b/app/src/protyle/util/editorCommonEvent.ts
@@ -843,19 +843,21 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
}
}
}
- transaction(protyle, [{
- action: "sortAttrViewCol",
- avID,
- previousID,
- id: gutterTypes[2],
- blockID: blockElement.dataset.nodeId,
- }], [{
- action: "sortAttrViewCol",
- avID,
- previousID: oldPreviousID,
- id: gutterTypes[2],
- blockID: blockElement.dataset.nodeId,
- }]);
+ if (previousID !== oldPreviousID && previousID !== gutterTypes[2]) {
+ transaction(protyle, [{
+ action: "sortAttrViewCol",
+ avID,
+ previousID,
+ id: gutterTypes[2],
+ blockID: blockElement.dataset.nodeId,
+ }], [{
+ action: "sortAttrViewCol",
+ avID,
+ previousID: oldPreviousID,
+ id: gutterTypes[2],
+ blockID: blockElement.dataset.nodeId,
+ }]);
+ }
}
} else if (targetElement.classList.contains("av__row")) {
// 拖拽到属性视图内
@@ -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,