mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 00:50:13 +01:00
🐛 macos 无法粘贴文件夹
This commit is contained in:
parent
3387b01b70
commit
5ef314e148
1 changed files with 20 additions and 4 deletions
|
|
@ -2,6 +2,9 @@ import {Constants} from "../../constants";
|
||||||
import {uploadFiles, uploadLocalFiles} from "../upload";
|
import {uploadFiles, uploadLocalFiles} from "../upload";
|
||||||
import {processPasteCode, processRender} from "./processCode";
|
import {processPasteCode, processRender} from "./processCode";
|
||||||
import {writeText} from "./compatibility";
|
import {writeText} from "./compatibility";
|
||||||
|
/// #if !BROWSER
|
||||||
|
import {clipboard} from "electron";
|
||||||
|
/// #endif
|
||||||
import {hasClosestBlock} from "./hasClosest";
|
import {hasClosestBlock} from "./hasClosest";
|
||||||
import {focusByWbr, getEditorRange} from "./selection";
|
import {focusByWbr, getEditorRange} from "./selection";
|
||||||
import {blockRender} from "../markdown/blockRender";
|
import {blockRender} from "../markdown/blockRender";
|
||||||
|
|
@ -82,7 +85,19 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
if (!textHTML && !textPlain && ("clipboardData" in event) && "darwin" !== window.siyuan.config.system.os) {
|
if (!textHTML && !textPlain && ("clipboardData" in event)) {
|
||||||
|
if ("darwin" === window.siyuan.config.system.os) {
|
||||||
|
const xmlString = clipboard.read("NSFilenamesPboardType");
|
||||||
|
const domParser = new DOMParser();
|
||||||
|
const xmlDom = domParser.parseFromString(xmlString, "application/xml");
|
||||||
|
const localFiles: string[] = [];
|
||||||
|
Array.from(xmlDom.getElementsByTagName("string")).forEach(item => {
|
||||||
|
localFiles.push(item.childNodes[0].nodeValue);
|
||||||
|
});
|
||||||
|
uploadLocalFiles(localFiles, protyle);
|
||||||
|
writeText("");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
const xmlString = await fetchSyncPost("/api/clipboard/readFilePaths", {});
|
const xmlString = await fetchSyncPost("/api/clipboard/readFilePaths", {});
|
||||||
if (xmlString.data.length > 0) {
|
if (xmlString.data.length > 0) {
|
||||||
uploadLocalFiles(xmlString.data, protyle);
|
uploadLocalFiles(xmlString.data, protyle);
|
||||||
|
|
@ -90,6 +105,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
|
|
||||||
// 浏览器地址栏拷贝处理
|
// 浏览器地址栏拷贝处理
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue