diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts index 1c9fd109b..4f39fc566 100644 --- a/app/src/layout/dock/Files.ts +++ b/app/src/layout/dock/Files.ts @@ -349,10 +349,16 @@ export class Files extends Model { } let ids = ""; const ghostElement = document.createElement("ul"); - selectElements.forEach((item: HTMLElement) => { + selectElements.forEach((item: HTMLElement, index) => { ghostElement.append(item.cloneNode(true)); item.style.opacity = "0.1"; - ids += (item.getAttribute("data-node-id") || "") + ","; + const itemNodeId = item.getAttribute("data-node-id") || "" + if (itemNodeId) { + ids += itemNodeId; + if (index < selectElements.length - 1) { + ids += ","; + } + } }); ghostElement.setAttribute("style", `width: 219px;position: fixed;top:-${selectElements.length * 30}px`); ghostElement.setAttribute("class", "b3-list b3-list--background"); diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index ed671ad03..219ae2439 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -917,6 +917,31 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { // 文件树拖拽 const scrollTop = protyle.contentElement.scrollTop; const ids = event.dataTransfer.getData(Constants.SIYUAN_DROP_FILE).split(","); + if (targetElement.classList.contains("av__row")) { + // 拖拽到属性视图内 + const blockElement = hasClosestBlock(targetElement); + if (!blockElement) { + return; + } + let previousID = ""; + if (targetElement.classList.contains("dragover__bottom")) { + previousID = targetElement.getAttribute("data-id") || ""; + } else { + previousID = targetElement.previousElementSibling?.getAttribute("data-id") || ""; + } + const avID = blockElement.getAttribute("data-av-id"); + transaction(protyle, [{ + action: "insertAttrViewBlock", + avID, + previousID, + srcIDs: ids, + }], [{ + action: "removeAttrViewBlock", + srcIDs: ids, + avID, + }]); + return; + } for (let i = 0; i < ids.length; i++) { if (ids[i]) { await fetchSyncPost("/api/filetree/doc2Heading", {