Vanessa 2024-04-02 23:22:56 +08:00
parent 299437d751
commit 748d7f1585
2 changed files with 21 additions and 1 deletions

View file

@ -83,6 +83,14 @@ export class Title {
if (commonHotkey(protyle, event)) {
return true;
}
if (matchHotKey("⇧⌘V", event)) {
navigator.clipboard.readText().then(textPlain => {
textPlain = textPlain.replace(/</g, ";;;lt;;;").replace(/>/g, ";;;gt;;;");
const content = protyle.lute.BlockDOM2EscapeMarkerContent(protyle.lute.Md2BlockDOM(textPlain));
document.execCommand("insertText", false, replaceFileName(content));
this.rename(protyle);
});
}
if (matchHotKey(window.siyuan.config.keymap.general.enterBack.custom, event)) {
const ids = protyle.path.split("/");
if (ids.length > 2) {
@ -211,6 +219,7 @@ export class Title {
}
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.paste,
icon: "iconPaste",
accelerator: "⌘V",
click: async () => {
focusByRange(getEditorRange(this.editElement));
@ -220,6 +229,18 @@ export class Title {
this.rename(protyle);
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.pasteAsPlainText,
accelerator: "⇧⌘V",
click: async () => {
navigator.clipboard.readText().then(textPlain => {
textPlain = textPlain.replace(/</g, ";;;lt;;;").replace(/>/g, ";;;gt;;;");
const content = protyle.lute.BlockDOM2EscapeMarkerContent(protyle.lute.Md2BlockDOM(textPlain));
document.execCommand("insertText", false, replaceFileName(content));
this.rename(protyle);
});
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.selectAll,
accelerator: "⌘A",

View file

@ -169,7 +169,6 @@ export const pasteAsPlainText = async (protyle: IProtyle) => {
// Inline-level elements support pasted as plain text https://github.com/siyuan-note/siyuan/issues/8010
navigator.clipboard.readText().then(textPlain => {
// 对 HTML 标签进行内部转移,避免被 Lute 解析以后变为小写 https://github.com/siyuan-note/siyuan/issues/10620
// 在
textPlain = textPlain.replace(/</g, ";;;lt;;;").replace(/>/g, ";;;gt;;;");
const content = protyle.lute.BlockDOM2EscapeMarkerContent(protyle.lute.Md2BlockDOM(textPlain));
insertHTML(content, protyle);