diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts index 7f6aea10d..0b1bc7acc 100644 --- a/app/src/protyle/render/av/col.ts +++ b/app/src/protyle/render/av/col.ts @@ -911,33 +911,41 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen export const removeCol = (options: { protyle: IProtyle, data: IAV, - previousID: string, - colData: IAVColumn, avID: string, blockID: string, isCustomAttr: boolean menuElement: HTMLElement, blockElement: Element avPanelElement: Element - tabRect: DOMRect + tabRect: DOMRect, + isTwoWay: boolean }) => { const colId = options.menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id"); + let previousID = ""; + const colData = options.data.view.columns.find((item: IAVColumn, index) => { + if (item.id === colId) { + previousID = options.data.view.columns[index - 1]?.id; + options.data.view.columns.splice(index, 1); + return true; + } + }); const newUpdated = dayjs().format("YYYYMMDDHHmmss"); transaction(options.protyle, [{ action: "removeAttrViewCol", id: colId, avID: options.avID, + removeDest: options.isTwoWay }, { action: "doUpdateUpdated", id: options.blockID, data: newUpdated, }], [{ action: "addAttrViewCol", - name: options.colData.name, + name: colData.name, avID: options.avID, - type: options.colData.type, + type: colData.type, id: colId, - previousID:options.previousID + previousID: previousID }, { action: "doUpdateUpdated", id: options.blockID, diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts index 7ec66dac4..1dbc8a0b4 100644 --- a/app/src/protyle/render/av/openMenuPanel.ts +++ b/app/src/protyle/render/av/openMenuPanel.ts @@ -1083,33 +1083,72 @@ export const openMenuPanel = (options: { event.stopPropagation(); break; } else if (type === "removeCol") { - tabRect = options.blockElement.querySelector(".av__views").getBoundingClientRect(); + if (!isCustomAttr) { + tabRect = options.blockElement.querySelector(".av__views").getBoundingClientRect(); + } const colId = menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id"); - let previousID = ""; - const colData = data.view.columns.find((item: IAVColumn, index) => { + const colData = data.view.columns.find((item: IAVColumn) => { if (item.id === colId) { - previousID = data.view.columns[index - 1]?.id; - data.view.columns.splice(index, 1); return true; } }); - if (isCustomAttr || (colData.type === "relation" && colData.relation.isTwoWay)) { + const isTwoWay = colData.type === "relation" && colData.relation?.isTwoWay + if (isCustomAttr || isTwoWay) { const dialog = new Dialog({ - title: window.siyuan.languages.removeCol.replace("${x}", menuElement.querySelector("input").value), + title: isTwoWay ? window.siyuan.languages.removeCol.replace("${x}", menuElement.querySelector("input").value) : window.siyuan.languages.deleteOpConfirm, content: `