From 31542c67f2f5f46f7295833f7172a5b23576a4c4 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 6 May 2024 12:13:56 +0800 Subject: [PATCH] :bug: The file name encoding is abnormal after copying the image and pasting it https://github.com/siyuan-note/siyuan/issues/11246 --- app/src/menus/protyle.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index 204728cde..93b412657 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -946,7 +946,10 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme accelerator: "⌘C", icon: "iconCopy", click() { - writeText(protyle.lute.BlockDOM2StdMd(assetElement.outerHTML)); + let content = protyle.lute.BlockDOM2StdMd(assetElement.outerHTML); + // The file name encoding is abnormal after copying the image and pasting it https://github.com/siyuan-note/siyuan/issues/11246 + content = content.replace(/%20/g, " "); + writeText(content); } }).element); window.siyuan.menus.menu.append(new MenuItem({ @@ -963,7 +966,10 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme accelerator: "⌘X", label: window.siyuan.languages.cut, click() { - writeText(protyle.lute.BlockDOM2StdMd(assetElement.outerHTML)); + let content = protyle.lute.BlockDOM2StdMd(assetElement.outerHTML); + // The file name encoding is abnormal after copying the image and pasting it https://github.com/siyuan-note/siyuan/issues/11246 + content = content.replace(/%20/g, " "); + writeText(content); (assetElement as HTMLElement).outerHTML = ""; nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); updateTransaction(protyle, id, nodeElement.outerHTML, html);