From d1ed86efe79baaf0826091c2d09030c836ccf814 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 7 May 2025 13:02:00 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/14625 --- app/src/menus/protyle.ts | 2 +- app/src/protyle/util/paste.ts | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index 375a1d8a1..4c882af05 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -631,7 +631,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => { label: window.siyuan.languages.copy, icon: "iconCopy", click() { - writeText(protyle.lute.BlockDOM2StdMd(element.outerHTML)); + writeText(protyle.lute.BlockDOM2StdMd(element.outerHTML).trim()); } }).element); if (!protyle.disabled) { diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts index 589b76677..675b87f0d 100644 --- a/app/src/protyle/util/paste.ts +++ b/app/src/protyle/util/paste.ts @@ -398,12 +398,22 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven // 编辑器内部粘贴 const tempElement = document.createElement("div"); tempElement.innerHTML = siyuanHTML; - if (tempElement.childElementCount === 1 && ((tempElement.firstElementChild as HTMLElement).dataset?.type || "").split(" ").includes("block-ref")) { - protyle.toolbar.setInlineMark(protyle, "block-ref", "range", { - type: "id", - color: `${(tempElement.firstElementChild as HTMLElement).dataset.id}${Constants.ZWSP}s${Constants.ZWSP}${range.toString()}` - }); - return; + if (tempElement.childElementCount === 1) { + const types = ((tempElement.firstElementChild as HTMLElement).dataset?.type || "").split(" ") + if(types.includes("block-ref")) { + protyle.toolbar.setInlineMark(protyle, "block-ref", "range", { + type: "id", + color: `${(tempElement.firstElementChild as HTMLElement).dataset.id}${Constants.ZWSP}s${Constants.ZWSP}${range.toString()}` + }); + return; + } + if(types.includes("a")) { + protyle.toolbar.setInlineMark(protyle, "a", "range", { + type: "a", + color: `${(tempElement.firstElementChild as HTMLElement).dataset.href}${Constants.ZWSP}${range.toString()}` + }); + return; + } } let isBlock = false; tempElement.querySelectorAll("[data-node-id]").forEach((e) => {