mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-15 05:08:51 +01:00
♻️ Rename function code160to32 to nbsp2space
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
869849ce1b
commit
a7514554e1
6 changed files with 14 additions and 14 deletions
|
|
@ -7,7 +7,7 @@ import {isWindow} from "../../util/functions";
|
|||
import {writeText} from "../../protyle/util/compatibility";
|
||||
import {showMessage} from "../../dialog/message";
|
||||
import {cancelDrag} from "./dragover";
|
||||
import {code160to32} from "../../protyle/util/code160to32";
|
||||
import {nbsp2space} from "../../protyle/util/nbsp2space";
|
||||
|
||||
export const globalClickHideMenu = (element: HTMLElement) => {
|
||||
if (!window.siyuan.menus.menu.element.contains(element) && !hasClosestByAttribute(element, "data-menu", "true")) {
|
||||
|
|
@ -43,7 +43,7 @@ export const globalClick = (event: MouseEvent & { target: HTMLElement }) => {
|
|||
const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy");
|
||||
if (copyElement) {
|
||||
let text = copyElement.parentElement.nextElementSibling.textContent.replace(/\n$/, "");
|
||||
text = code160to32(text) // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382
|
||||
text = nbsp2space(text) // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382
|
||||
// https://github.com/siyuan-note/siyuan/issues/14800
|
||||
text = text.replace(/\u200D```/g, "```");
|
||||
writeText(text);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import {mobileKeydown} from "./util/keydown";
|
|||
import {correctHotkey} from "../boot/globalEvent/commonHotkey";
|
||||
import {processIOSPurchaseResponse} from "../util/iOSPurchase";
|
||||
import {updateControlAlt} from "../protyle/util/hotKey";
|
||||
import {code160to32} from "../protyle/util/code160to32";
|
||||
import {nbsp2space} from "../protyle/util/nbsp2space";
|
||||
|
||||
class App {
|
||||
public plugins: import("../plugin").Plugin[] = [];
|
||||
|
|
@ -78,7 +78,7 @@ class App {
|
|||
const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy");
|
||||
if (copyElement) {
|
||||
let text = copyElement.parentElement.nextElementSibling.textContent.trimEnd();
|
||||
text = code160to32(text); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382
|
||||
text = nbsp2space(text); // 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();
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ import * as fs from "node:fs";
|
|||
/// #endif
|
||||
import {checkFold} from "../../util/noRelyPCFunction";
|
||||
import {clearSelect} from "../util/clear";
|
||||
import {code160to32} from "../util/code160to32";
|
||||
import {nbsp2space} from "../util/nbsp2space";
|
||||
|
||||
export class Gutter {
|
||||
public element: HTMLElement;
|
||||
|
|
@ -1586,7 +1586,7 @@ export class Gutter {
|
|||
element.addEventListener("click", async () => {
|
||||
const hljsElement = nodeElement.querySelector(".hljs") as HTMLElement;
|
||||
let code = hljsElement?.textContent || "";
|
||||
code = code160to32(code);
|
||||
code = nbsp2space(code);
|
||||
// https://github.com/siyuan-note/siyuan/issues/14800
|
||||
code = code.replace(/\u200D```/g, "```");
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import {openFileById} from "../../editor/util";
|
|||
import {setTitle} from "../../dialog/processSystem";
|
||||
import {getContenteditableElement, getNoContainerElement} from "../wysiwyg/getBlock";
|
||||
import {commonHotkey} from "../wysiwyg/commonHotkey";
|
||||
import {code160to32} from "../util/code160to32";
|
||||
import {nbsp2space} from "../util/nbsp2space";
|
||||
import {genEmptyElement} from "../../block/util";
|
||||
import {transaction} from "../wysiwyg/transaction";
|
||||
import {hideTooltip} from "../../dialog/tooltip";
|
||||
|
|
@ -336,17 +336,17 @@ export class Title {
|
|||
public setTitle(title: string) {
|
||||
/// #if MOBILE
|
||||
if (this.editElement) {
|
||||
if (code160to32(title) !== code160to32(this.editElement.textContent)) {
|
||||
if (nbsp2space(title) !== nbsp2space(this.editElement.textContent)) {
|
||||
this.editElement.textContent = title === window.siyuan.languages.untitled ? "" : title;
|
||||
}
|
||||
} else {
|
||||
const inputElement = document.getElementById("toolbarName") as HTMLInputElement;
|
||||
if (code160to32(title) !== code160to32(inputElement.value)) {
|
||||
if (nbsp2space(title) !== nbsp2space(inputElement.value)) {
|
||||
inputElement.value = title === window.siyuan.languages.untitled ? "" : title;
|
||||
}
|
||||
}
|
||||
/// #else
|
||||
if (code160to32(title) !== code160to32(this.editElement.textContent)) {
|
||||
if (nbsp2space(title) !== nbsp2space(this.editElement.textContent)) {
|
||||
this.editElement.textContent = title === window.siyuan.languages.untitled ? "" : title;
|
||||
}
|
||||
/// #endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export const code160to32 = (text: string) => {
|
||||
export const nbsp2space = (text: string) => {
|
||||
// 非打断空格转换为空格
|
||||
return text.replace(/\u00A0/g, " ");
|
||||
};
|
||||
|
|
@ -102,7 +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";
|
||||
import {nbsp2space} from "../util/nbsp2space";
|
||||
|
||||
export class WYSIWYG {
|
||||
public lastHTMLs: { [key: string]: string } = {};
|
||||
|
|
@ -485,7 +485,7 @@ export class WYSIWYG {
|
|||
html = getEnableHTML(html);
|
||||
}
|
||||
textPlain = textPlain || protyle.lute.BlockDOM2StdMd(html).trimEnd();
|
||||
textPlain = code160to32(textPlain) // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382
|
||||
textPlain = nbsp2space(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);
|
||||
|
|
@ -2075,7 +2075,7 @@ export class WYSIWYG {
|
|||
textPlain = textPlain.endsWith("\n") ? textPlain.replace(/\n$/, "") : textPlain;
|
||||
}
|
||||
}
|
||||
textPlain = code160to32(textPlain); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382
|
||||
textPlain = nbsp2space(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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue