mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
🎨 复制纯文本 时移除所有零宽空格 Fix https://github.com/siyuan-note/siyuan/issues/6674
This commit is contained in:
parent
3ab71117f6
commit
14a8b1f8a4
4 changed files with 13 additions and 7 deletions
|
|
@ -19,7 +19,7 @@ import {transaction, updateTransaction} from "../protyle/wysiwyg/transaction";
|
|||
import {openMenu} from "./commonMenuItem";
|
||||
import {fetchPost} from "../util/fetch";
|
||||
import {Constants} from "../constants";
|
||||
import {readText, writeText} from "../protyle/util/compatibility";
|
||||
import {copyPlainText, readText, writeText} from "../protyle/util/compatibility";
|
||||
import {preventScroll} from "../protyle/scroll/preventScroll";
|
||||
import {onGet} from "../protyle/util/onGet";
|
||||
import {getAllModels} from "../layout/getAll";
|
||||
|
|
@ -296,7 +296,7 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
|
|||
cloneContents.querySelectorAll('[data-type="backslash"]').forEach(item => {
|
||||
item.firstElementChild.remove();
|
||||
});
|
||||
writeText(cloneContents.textContent);
|
||||
copyPlainText(cloneContents.textContent);
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {getIconByType} from "../../editor/getIcon";
|
|||
import {iframeMenu, setFold, tableMenu, videoMenu, zoomOut} from "../../menus/protyle";
|
||||
import {MenuItem} from "../../menus/Menu";
|
||||
import {copySubMenu, openAttr, openWechatNotify} from "../../menus/commonMenuItem";
|
||||
import {updateHotkeyTip, writeText} from "../util/compatibility";
|
||||
import {copyPlainText, updateHotkeyTip, writeText} from "../util/compatibility";
|
||||
import {
|
||||
transaction,
|
||||
turnsIntoOneTransaction, turnsIntoTransaction,
|
||||
|
|
@ -591,7 +591,7 @@ export class Gutter {
|
|||
html += cloneNode.textContent + "\n";
|
||||
});
|
||||
});
|
||||
writeText(html.trimEnd());
|
||||
copyPlainText(html.trimEnd());
|
||||
}
|
||||
}, {
|
||||
label: window.siyuan.languages.copy + " HTML",
|
||||
|
|
@ -966,7 +966,7 @@ export class Gutter {
|
|||
});
|
||||
text += cloneNode.textContent + "\n";
|
||||
});
|
||||
writeText(text.trimEnd());
|
||||
copyPlainText(text.trimEnd());
|
||||
}
|
||||
}, {
|
||||
label: window.siyuan.languages.copy + " HTML",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {focusByRange} from "./selection";
|
||||
import {fetchPost} from "../../util/fetch";
|
||||
import {Constants} from "../../constants";
|
||||
|
||||
export const openByMobile = (uri: string) => {
|
||||
if (!uri) {
|
||||
|
|
@ -59,6 +60,11 @@ export const writeText = async (text: string) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const copyPlainText = async (text: string) => {
|
||||
text = text.replace(new RegExp(Constants.ZWSP, "g"), ""); // `复制纯文本` 时移除所有零宽空格 https://github.com/siyuan-note/siyuan/issues/6674
|
||||
await writeText(text);
|
||||
};
|
||||
|
||||
// 用户 iPhone 点击延迟/需要双击的处理
|
||||
export const getEventName = () => {
|
||||
if (navigator.userAgent.indexOf("iPhone") > -1) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {hideElements} from "../ui/hideElements";
|
||||
import {getEventName, isCtrl, isMac, writeText} from "../util/compatibility";
|
||||
import {copyPlainText, getEventName, isCtrl, isMac, writeText} from "../util/compatibility";
|
||||
import {
|
||||
focusBlock,
|
||||
focusByRange,
|
||||
|
|
@ -1372,7 +1372,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
html += cloneNode.textContent + "\n";
|
||||
});
|
||||
});
|
||||
writeText(html.trimEnd());
|
||||
copyPlainText(html.trimEnd());
|
||||
} else {
|
||||
const cloneContents = range.cloneContents();
|
||||
cloneContents.querySelectorAll('[data-type="backslash"]').forEach(item => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue