From dfb47c00ff651695bb3d691b93d1ba731248fe22 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 2 Sep 2022 22:27:24 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=8B=96=E5=85=A5=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E5=8C=85=E5=90=AB=20`)`=20=E7=9A=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BB=A5=20`file://`=20=E6=8F=92=E5=85=A5=E5=90=8E=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E8=A7=A3=E6=9E=90=E9=94=99=E8=AF=AF=20Fix=20https://g?= =?UTF-8?q?ithub.com/siyuan-note/siyuan/issues/5786?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/editor/util.ts | 3 +++ app/src/protyle/util/editorCommonEvent.ts | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts index 29b91b49b..86c882f9b 100644 --- a/app/src/editor/util.ts +++ b/app/src/editor/util.ts @@ -477,6 +477,9 @@ export const openBy = (url: string, type: "folder" | "app") => { address = url.replace("file://", ""); } if (type === "app") { + // 拖入文件名包含 `)` 的文件以 `file://` 插入后链接解析错误 https://github.com/siyuan-note/siyuan/issues/5786 + address = address.replace(/\\\)/g, ")") + shell.openPath(address); } else if (type === "folder") { shell.showItemInFolder(address); diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 2e11f10be..0775b8e40 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -1,4 +1,4 @@ -import {focusBlock, focusByWbr, focusByRange} from "./selection"; +import {focusBlock, focusByRange, focusByWbr} from "./selection"; import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "./hasClosest"; import {Constants} from "../../constants"; import {paste} from "./paste"; @@ -719,6 +719,11 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { files.forEach((item) => { fileText += `[${path.basename(item)}](file://${item})\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); } else { uploadLocalFiles(files, protyle);