diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index a692b0255..9b5ab05de 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -264,32 +264,6 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi type: "submenu", submenu: copySubMenu(blockId) }); - menu.addItem({ - label: window.siyuan.languages.addToDatabase, - icon: "iconDatabase", - click() { - openSearchAV(blockElement.getAttribute("data-av-id"), rowElements[0] as HTMLElement, (listItemElement) => { - const sourceIds: string[] = [blockId]; - const avID = listItemElement.dataset.avId; - transaction(protyle, [{ - action: "insertAttrViewBlock", - avID, - ignoreFillFilter: true, - srcIDs: sourceIds, - isDetached: false, - blockID: listItemElement.dataset.nodeId - }, { - action: "doUpdateUpdated", - id: listItemElement.dataset.nodeId, - data: dayjs().format("YYYYMMDDHHmmss"), - }], [{ - action: "removeAttrViewBlock", - srcIDs: sourceIds, - avID, - }]); - }); - } - }); menu.addItem({ label: window.siyuan.languages.unbindBlock, icon: "iconLinkOff", @@ -298,6 +272,38 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi } }); } + menu.addItem({ + label: window.siyuan.languages.addToDatabase, + icon: "iconDatabase", + click() { + openSearchAV(blockElement.getAttribute("data-av-id"), rowElements[0] as HTMLElement, (listItemElement) => { + const srcs: { id: string, content: string }[] = []; + rowElements.forEach(item => { + srcs.push({ + content: item.querySelector(".av__cell[data-block-id] .av__celltext").textContent.trim(), + id: item.getAttribute("data-id") + }); + }) + const avID = listItemElement.dataset.avId; + transaction(protyle, [{ + action: "insertAttrViewBlock", + avID, + ignoreFillFilter: true, + srcs, + isDetached: false, + blockID: listItemElement.dataset.nodeId + }, { + action: "doUpdateUpdated", + id: listItemElement.dataset.nodeId, + data: dayjs().format("YYYYMMDDHHmmss"), + }], [{ + action: "removeAttrViewBlock", + srcIDs: sourceIds, + avID, + }]); + }); + } + }); if (!protyle.disabled) { if (rowElements.length === 1) { if (keyCellElement.getAttribute("data-detached") !== "true") { diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 6af8a10e5..a41140c06 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -479,7 +479,8 @@ interface IOperation { nextID?: string // insert 专享 isDetached?: boolean // insertAttrViewBlock 专享 ignoreFillFilter?: boolean // insertAttrViewBlock 专享 - srcIDs?: string[] // insertAttrViewBlock 专享 + srcIDs?: string[] // removeAttrViewBlock 专享 + srcs?: { id: string, content: string }[] // insertAttrViewBlock 专享 name?: string // addAttrViewCol 专享 type?: TAVCol // addAttrViewCol 专享 deckID?: string // add/removeFlashcards 专享