diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index e92180429..588bf3146 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -162,10 +162,10 @@ export const avContextmenu = (protyle: IProtyle, event: MouseEvent & { detail: a transaction(protyle, [{ action: "removeAttrViewBlock", srcIDs: blockIds, - parentID: blockElement.getAttribute("data-av-id"), + avID: blockElement.getAttribute("data-av-id"), }], [{ action: "insertAttrViewBlock", - parentID: blockElement.getAttribute("data-av-id"), + avID: blockElement.getAttribute("data-av-id"), previousID: rowElement.previousElementSibling?.getAttribute("data-id") || "", srcIDs: rowIds, }]); diff --git a/app/src/protyle/render/av/addCol.ts b/app/src/protyle/render/av/addCol.ts index 401b53647..98c92c7f0 100644 --- a/app/src/protyle/render/av/addCol.ts +++ b/app/src/protyle/render/av/addCol.ts @@ -3,6 +3,8 @@ import {transaction} from "../../wysiwyg/transaction"; export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => { const menu = new Menu("av-header-add"); + const avID = blockElement.getAttribute("data-av-id"); + const viewID = blockElement.querySelector(".item--focus").getAttribute("data-id"); menu.addItem({ icon: "iconAlignLeft", label: window.siyuan.languages.text, @@ -11,13 +13,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => { transaction(protyle, [{ action: "addAttrViewCol", name: "Text", - parentID: blockElement.getAttribute("data-av-id"), + avID, + viewID, type: "text", id }], [{ action: "removeAttrViewCol", id, - parentID: blockElement.getAttribute("data-av-id"), + avID, + viewID, }]); } }); @@ -29,13 +33,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => { transaction(protyle, [{ action: "addAttrViewCol", name: "Number", - parentID: blockElement.getAttribute("data-av-id"), + avID, + viewID, type: "number", id }], [{ action: "removeAttrViewCol", id, - parentID: blockElement.getAttribute("data-av-id"), + avID, + viewID, }]); } }); @@ -47,13 +53,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => { transaction(protyle, [{ action: "addAttrViewCol", name: "Select", - parentID: blockElement.getAttribute("data-av-id"), + avID, + viewID, type: "select", id }], [{ action: "removeAttrViewCol", id, - parentID: blockElement.getAttribute("data-av-id"), + avID, + viewID, }]); } }); @@ -65,13 +73,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => { transaction(protyle, [{ action: "addAttrViewCol", name: "Multi-select", - parentID: blockElement.getAttribute("data-av-id"), + avID, + viewID, type: "mSelect", id }], [{ action: "removeAttrViewCol", id, - parentID: blockElement.getAttribute("data-av-id"), + avID, + viewID, }]); } }); @@ -83,13 +93,15 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => { transaction(protyle, [{ action: "addAttrViewCol", name: "Date", - parentID: blockElement.getAttribute("data-av-id"), + avID, + viewID, type: "date", id }], [{ action: "removeAttrViewCol", id, - parentID: blockElement.getAttribute("data-av-id"), + avID, + viewID, }]); } }); diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts index 6bed834b3..b2792e42d 100644 --- a/app/src/protyle/render/av/col.ts +++ b/app/src/protyle/render/av/col.ts @@ -75,13 +75,15 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl transaction(protyle, [{ action: "updateAttrViewCol", id: colId, - parentID: avId, + avID: avId, + viewID: viewId, name: newValue, type, }], [{ action: "updateAttrViewCol", id: colId, - parentID: avId, + avID: avId, + viewID: viewId, name: cellElement.textContent.trim(), type, }]); @@ -110,14 +112,14 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl avID: response.data.id, viewID: response.data.viewID, data: [{ - column: colId, - order: "ASC" - }] + column: colId, + order: "ASC" + }] }], [{ action: "setAttrViewSorts", avID: response.data.id, viewID: response.data.viewID, - data: response.data.view.sorts + data: response.data.view.sorts }]); }); } @@ -131,10 +133,10 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl action: "setAttrViewSorts", avID: response.data.id, viewID: response.data.viewID, - data: [{ - column: colId, - order: "DESC" - }] + data: [{ + column: colId, + order: "DESC" + }] }], [{ action: "setAttrViewSorts", avID: response.data.id, @@ -168,7 +170,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl action: "setAttrViewFilters", avID: avId, viewID: avData.viewID, - data: [filter] + data: [filter] }], [{ action: "setAttrViewFilters", avID: avId, @@ -220,11 +222,13 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl transaction(protyle, [{ action: "removeAttrViewCol", id: colId, - parentID: avId, + avID: avId, + viewID: viewId, }], [{ action: "addAttrViewCol", name: cellElement.textContent.trim(), - parentID: avId, + avID: avId, + viewID: viewId, type: type, id: colId }]); diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts index afed25de1..482b56da5 100644 --- a/app/src/protyle/render/av/openMenuPanel.ts +++ b/app/src/protyle/render/av/openMenuPanel.ts @@ -188,12 +188,14 @@ export const openMenuPanel = (protyle: IProtyle, } transaction(protyle, [{ action: "sortAttrViewCol", - parentID: avId, + avID: avId, + viewID: data.viewID, previousID: (targetElement.classList.contains("dragover__top") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "", id: sourceId, }], [{ action: "sortAttrViewCol", - parentID: avId, + avID: avId, + viewID: data.viewID, previousID: sourceElement.previousElementSibling?.getAttribute("data-id") || "", id: sourceId, }]); diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 27df81280..77fc85c49 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -823,15 +823,18 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { if (!blockElement) { return; } - const avId = blockElement.getAttribute("data-av-id"); + const avID = blockElement.getAttribute("data-av-id"); + const viewID = blockElement.querySelector(".item--focus").getAttribute("data-av-id"); transaction(protyle, [{ action: "sortAttrViewCol", - parentID: avId, + avID, + viewID, previousID: (targetElement.classList.contains("dragover__left") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "", id: gutterTypes[2], }], [{ action: "sortAttrViewCol", - parentID: avId, + avID, + viewID, previousID: targetElement.parentElement.querySelector(`[data-id="${gutterTypes[2]}"`).previousElementSibling?.getAttribute("data-id") || "", id: gutterTypes[2], }]); @@ -849,7 +852,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { } else { previousID = targetElement.previousElementSibling?.getAttribute("data-id") || ""; } - const avId = blockElement.getAttribute("data-av-id"); + const avID = blockElement.getAttribute("data-av-id"); + const viewID = blockElement.querySelector(".item--focus").getAttribute("data-id"); if (gutterTypes[0] === "nodeattributeview" && gutterTypes[1] === "row") { // 行内拖拽 const doOperations: IOperation[] = []; @@ -858,13 +862,15 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { selectedIds.reverse().forEach(item => { doOperations.push({ action: "sortAttrViewRow", - parentID: avId, + avID, + viewID, previousID, id: item, }); undoOperations.push({ action: "sortAttrViewRow", - parentID: avId, + avID, + viewID, previousID: undoPreviousId, id: item, }); @@ -873,13 +879,13 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { } else { transaction(protyle, [{ action: "insertAttrViewBlock", - parentID: avId, + avID, previousID, srcIDs: sourceIds, }], [{ action: "removeAttrViewBlock", srcIDs: sourceIds, - parentID: avId, + avID, }]); } return; diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 67be7120a..031f58e1d 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -309,7 +309,7 @@ interface IOperation { avID?: string, // av viewID?: string, // av data?: any, // updateAttr 时为 { old: IObject, new: IObject }, updateAttrViewCell 时为 {TAVCol: {content: string}} - parentID?: string // 为 insertAttrViewBlock 传 avid + parentID?: string previousID?: string retData?: any nextID?: string // insert 专享