瀏覽代碼

:bug: Drag and drop to insert asset fails https://github.com/siyuan-note/siyuan/issues/12791

Daniel 8 月之前
父節點
當前提交
61c849af56
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      app/src/protyle/util/editorCommonEvent.ts

+ 5 - 2
app/src/protyle/util/editorCommonEvent.ts

@@ -28,6 +28,9 @@ import {insertAttrViewBlockAnimation} from "../render/av/row";
 import {dragUpload} from "../render/av/asset";
 import {dragUpload} from "../render/av/asset";
 import * as dayjs from "dayjs";
 import * as dayjs from "dayjs";
 import {zoomOut} from "../../menus/protyle";
 import {zoomOut} from "../../menus/protyle";
+/// #if !BROWSER
+import {webUtils} from "electron";
+/// #endif
 
 
 const moveToNew = (protyle: IProtyle, sourceElements: Element[], targetElement: Element, newSourceElement: Element,
 const moveToNew = (protyle: IProtyle, sourceElements: Element[], targetElement: Element, newSourceElement: Element,
                    isSameDoc: boolean, isBottom: boolean, isCopy: boolean) => {
                    isSameDoc: boolean, isBottom: boolean, isCopy: boolean) => {
@@ -1124,7 +1127,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
                 if (event.dataTransfer.types[0] === "Files" && !isBrowser()) {
                 if (event.dataTransfer.types[0] === "Files" && !isBrowser()) {
                     const files: string[] = [];
                     const files: string[] = [];
                     for (let i = 0; i < event.dataTransfer.files.length; i++) {
                     for (let i = 0; i < event.dataTransfer.files.length; i++) {
-                        files.push(event.dataTransfer.files[i].path);
+                        files.push(webUtils.getPathForFile(event.dataTransfer.files[i]));
                     }
                     }
                     uploadLocalFiles(files, protyle, !event.altKey);
                     uploadLocalFiles(files, protyle, !event.altKey);
                 } else {
                 } else {
@@ -1137,7 +1140,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
                     if (cellType === "mAsset" && event.dataTransfer.types[0] === "Files" && !isBrowser()) {
                     if (cellType === "mAsset" && event.dataTransfer.types[0] === "Files" && !isBrowser()) {
                         const files: string[] = [];
                         const files: string[] = [];
                         for (let i = 0; i < event.dataTransfer.files.length; i++) {
                         for (let i = 0; i < event.dataTransfer.files.length; i++) {
-                            files.push(event.dataTransfer.files[i].path);
+                            files.push(webUtils.getPathForFile(event.dataTransfer.files[i]));
                         }
                         }
                         dragUpload(files, protyle, cellElement);
                         dragUpload(files, protyle, cellElement);
                     }
                     }