From 69fe9319a14d5ba91ff105ab3371d92fadd5903b Mon Sep 17 00:00:00 2001 From: Jeffrey Chen <78434827+TCOTC@users.noreply.github.com> Date: Sun, 2 Feb 2025 22:48:21 +0800 Subject: [PATCH] fix: Remove ZWSP when copying inline elements fix https://github.com/siyuan-note/siyuan/issues/13882 --- app/src/protyle/wysiwyg/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 8b2493d6c0f..31bc98b99ef 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -416,9 +416,9 @@ export class WYSIWYG { } // 不能使用 commonAncestorContainer https://ld246.com/article/1643282894693 if (hasClosestByAttribute(range.startContainer, "data-type", "NodeCodeBlock")) { - textPlain = tempElement.textContent.replace(Constants.ZWSP, "").replace(/\n$/, ""); + textPlain = tempElement.textContent.replace(new RegExp(Constants.ZWSP, "g"), "").replace(/\n$/, ""); } else if (hasClosestByMatchTag(range.startContainer, "CODE")) { - textPlain = tempElement.textContent.replace(Constants.ZWSP, ""); + textPlain = tempElement.textContent.replace(new RegExp(Constants.ZWSP, "g"), ""); } else { textPlain = range.toString(); } @@ -429,6 +429,7 @@ export class WYSIWYG { } textPlain = textPlain || protyle.lute.BlockDOM2StdMd(html).trimEnd(); textPlain = textPlain.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382 + textPlain = textPlain.replace(new RegExp(Constants.ZWSP, "g"), ""); // Remove ZWSP when copying inline elements https://github.com/siyuan-note/siyuan/issues/13882 event.clipboardData.setData("text/plain", textPlain); event.clipboardData.setData("text/html", selectTableElement ? html : protyle.lute.BlockDOM2HTML(selectAVElement ? textPlain : html)); event.clipboardData.setData("text/siyuan", selectTableElement ? protyle.lute.HTML2BlockDOM(html) : html);