From 1a403ff7453a4df0c5b640a00ed7ebeec24ada9e Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 24 Mar 2024 23:46:11 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/10722 --- app/src/protyle/wysiwyg/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 2e67cc4d6..d81b08ce0 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1454,6 +1454,11 @@ export class WYSIWYG { } this.emojiToMd(tempElement); html = tempElement.innerHTML; + // https://github.com/siyuan-note/siyuan/issues/10722 + if (hasClosestByAttribute(range.startContainer, "data-type", "NodeCodeBlock") || + hasClosestByMatchTag(range.startContainer, "CODE")) { + textPlain = tempElement.textContent.replace(Constants.ZWSP, ""); + } // https://github.com/siyuan-note/siyuan/issues/4321 if (!nodeElement.classList.contains("table")) { const editableElement = getContenteditableElement(nodeElement); @@ -1474,7 +1479,7 @@ export class WYSIWYG { } protyle.hint.render(protyle); if (!selectAVElement) { - textPlain = protyle.lute.BlockDOM2StdMd(html).trimEnd(); // 需要 trimEnd,否则 \n 会导致 https://github.com/siyuan-note/siyuan/issues/6218 + textPlain = textPlain || protyle.lute.BlockDOM2StdMd(html).trimEnd(); // 需要 trimEnd,否则 \n 会导致 https://github.com/siyuan-note/siyuan/issues/6218 } textPlain = textPlain.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382 event.clipboardData.setData("text/plain", textPlain);