Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/10832

Vanessa748d7f158580
diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts
index 21e7396ca5..5c14dbfa55 100644
--- a/app/src/protyle/header/Title.ts
+++ b/app/src/protyle/header/Title.ts
@@ -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",
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts
index 2ef31f37ea..1224501225 100644
--- a/app/src/protyle/util/paste.ts
+++ b/app/src/protyle/util/paste.ts
@@ -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);