This commit is contained in:
Vanessa 2022-09-02 23:04:07 +08:00
parent bd5cc648b8
commit 71678ad217
2 changed files with 4 additions and 9 deletions

View file

@ -476,10 +476,9 @@ export const openBy = (url: string, type: "folder" | "app") => {
} else { } else {
address = url.replace("file://", ""); address = url.replace("file://", "");
} }
// 拖入文件名包含 `)` 、`(` 的文件以 `file://` 插入后链接解析错误 https://github.com/siyuan-note/siyuan/issues/5786
address = address.replace(/\\\)/g, ")").replace(/\\\(/g, "(");
if (type === "app") { if (type === "app") {
// 拖入文件名包含 `)` 的文件以 `file://` 插入后链接解析错误 https://github.com/siyuan-note/siyuan/issues/5786
address = address.replace(/\\\)/g, ")")
shell.openPath(address); shell.openPath(address);
} else if (type === "folder") { } else if (type === "folder") {
shell.showItemInFolder(address); shell.showItemInFolder(address);

View file

@ -717,13 +717,9 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
if (event.altKey) { if (event.altKey) {
let fileText = ""; let fileText = "";
files.forEach((item) => { files.forEach((item) => {
fileText += `[${path.basename(item)}](file://${item})\n`; // 拖入文件名包含 `)` 或 `]` 的文件以 `file://` 插入后链接解析错误 https://github.com/siyuan-note/siyuan/issues/5786
fileText += `[${path.basename(item.replace(/\]/g, "\\]").replace(/\[/g, "\\["))}](file://${item.replace(/\)/g, "\\)").replace(/\(/g, "\\(")})\n`;
}); });
// 拖入文件名包含 `)` 的文件以 `file://` 插入后链接解析错误 https://github.com/siyuan-note/siyuan/issues/5786
fileText = fileText.replace(/\)/g, "\\)");
fileText = fileText.substring(0, fileText.length - 3) + ")"
insertHTML(protyle.lute.SpinBlockDOM(fileText), protyle); insertHTML(protyle.lute.SpinBlockDOM(fileText), protyle);
} else { } else {
uploadLocalFiles(files, protyle); uploadLocalFiles(files, protyle);