diff --git a/app/src/boot/globalEvent/click.ts b/app/src/boot/globalEvent/click.ts index e727f120c..f8f0a6594 100644 --- a/app/src/boot/globalEvent/click.ts +++ b/app/src/boot/globalEvent/click.ts @@ -41,7 +41,9 @@ export const globalClick = (event: MouseEvent & { target: HTMLElement }) => { const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy"); if (copyElement) { - writeText(copyElement.parentElement.nextElementSibling.textContent.trimEnd()); + let text = copyElement.parentElement.nextElementSibling.textContent.trimEnd() + text = text.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382 + writeText(text); showMessage(window.siyuan.languages.copied, 2000); event.preventDefault(); return; diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts index 0b37fe523..259b70321 100644 --- a/app/src/mobile/index.ts +++ b/app/src/mobile/index.ts @@ -64,7 +64,9 @@ class App { } const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy"); if (copyElement) { - writeText(copyElement.parentElement.nextElementSibling.textContent.trimEnd()); + let text = copyElement.parentElement.nextElementSibling.textContent.trimEnd() + text = text.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382 + writeText(text); showMessage(window.siyuan.languages.copied, 2000); event.preventDefault(); } diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts index d7e9ca2a4..bec8d4a1c 100644 --- a/app/src/protyle/export/index.ts +++ b/app/src/protyle/export/index.ts @@ -394,7 +394,9 @@ const renderPDF = (id: string) => { return; } } else if (target.classList.contains("protyle-action__copy")) { - navigator.clipboard.writeText(target.parentElement.nextElementSibling.textContent.trimEnd()); + let text = target.parentElement.nextElementSibling.textContent.trimEnd(); + text = text.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382 + navigator.clipboard.writeText(text); event.preventDefault(); event.stopPropagation(); break; @@ -626,7 +628,9 @@ const onExport = (data: IWebSocketData, filePath: string, type: string, removeAs Protyle.plantumlRender(previewElement, "stage/protyle"); document.querySelectorAll(".protyle-action__copy").forEach((item) => { item.addEventListener("click", (event) => { - navigator.clipboard.writeText(item.parentElement.nextElementSibling.textContent.trimEnd()); + let text = item.parentElement.nextElementSibling.textContent.trimEnd(); + text = text.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying + navigator.clipboard.writeText(text); event.preventDefault(); event.stopPropagation(); }) diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 4e03d597d..d3e2967b9 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -330,7 +330,9 @@ export class WYSIWYG { if (protyle.disabled) { html = getEnableHTML(html); } - event.clipboardData.setData("text/plain", textPlain || protyle.lute.BlockDOM2StdMd(html).trimEnd()); + 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 + event.clipboardData.setData("text/plain", textPlain); event.clipboardData.setData("text/html", protyle.lute.BlockDOM2HTML(html)); event.clipboardData.setData("text/siyuan", html); }); @@ -1245,7 +1247,9 @@ export class WYSIWYG { } } protyle.hint.render(protyle); - event.clipboardData.setData("text/plain", protyle.lute.BlockDOM2StdMd(html).trimEnd()); // 需要 trimEnd,否则 \n 会导致 https://github.com/siyuan-note/siyuan/issues/6218 + let 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); event.clipboardData.setData("text/html", protyle.lute.BlockDOM2HTML(html)); event.clipboardData.setData("text/siyuan", html); });