🎨 Clean code

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2026-01-04 21:15:12 +08:00
parent 12456ce23a
commit 950d419b91
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 9 additions and 6 deletions

View file

@ -1,4 +1,4 @@
export const code160to32 = (text: string) => {
// 非打断空格转换为空格
return text.replace(/\u00a0/g, " ");
return text.replace(/\u00A0/g, " ");
};

View file

@ -66,7 +66,7 @@ import {openGlobalSearch} from "../../search/util";
import {popSearch} from "../../mobile/menu/search";
/// #endif
import {BlockPanel} from "../../block/Panel";
import {copyPlainText, isInIOS, isMac, isOnlyMeta, readClipboard, encodeBase64} from "../util/compatibility";
import {copyPlainText, encodeBase64, isInIOS, isMac, isOnlyMeta, readClipboard} from "../util/compatibility";
import {MenuItem} from "../../menus/Menu";
import {fetchPost, fetchSyncPost} from "../../util/fetch";
import {onGet} from "../util/onGet";
@ -102,6 +102,7 @@ import {openGalleryItemMenu} from "../render/av/gallery/util";
import {clearSelect} from "../util/clear";
import {chartRender} from "../render/chartRender";
import {updateCalloutType} from "./callout";
import {code160to32} from "../util/code160to32";
export class WYSIWYG {
public lastHTMLs: { [key: string]: string } = {};
@ -484,7 +485,7 @@ export class WYSIWYG {
html = getEnableHTML(html);
}
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 = code160to32(textPlain) // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382
// Remove ZWSP when copying inline elements https://github.com/siyuan-note/siyuan/issues/13882
.replace(new RegExp(Constants.ZWSP, "g"), "");
event.clipboardData.setData("text/plain", textPlain);
@ -2074,7 +2075,7 @@ export class WYSIWYG {
textPlain = textPlain.endsWith("\n") ? textPlain.replace(/\n$/, "") : textPlain;
}
}
textPlain = textPlain.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382
textPlain = code160to32(textPlain); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382
event.clipboardData.setData("text/plain", textPlain);
if (!isInCodeBlock) {