Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/13894

Vanessa74f5aa08ac0d
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 21d2e35ff7..e595f9d0e6 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -464,6 +464,7 @@ export abstract class Constants {
switchAdjust: {default: "", custom: ""},
rtl: {default: "", custom: ""},
ltr: {default: "", custom: ""},
+ aiWriting: {default: "", custom: ""},
},
insert: {
appearance: {default: "⌥⌘X", custom: "⌥⌘X"},
diff --git a/app/src/protyle/hint/extend.ts b/app/src/protyle/hint/extend.ts
index 54a58dd511..f224c8d834 100644
--- a/app/src/protyle/hint/extend.ts
+++ b/app/src/protyle/hint/extend.ts
@@ -24,7 +24,7 @@ import {avRender} from "../render/av/render";
const getHotkeyOrMarker = (hotkey: string, marker: string) => {
if (hotkey) {
return `<span class="b3-menu__accelerator">${updateHotkeyTip(hotkey)}</span>`;
- } else {
+ } else if (marker) {
return `<span class="b3-list-item__meta">${marker}</span>`;
}
};
@@ -59,7 +59,7 @@ export const hintSlash = (key: string, protyle: IProtyle) => {
filter: [window.siyuan.languages.aiWriting, "ai writing", "ai编写", "aibianxie", "aibx", "人工智能", "rengongzhineng", "rgzn"],
id: "aiWriting",
value: Constants.ZWSP + 5,
- html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconSparkles"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.aiWriting}</span></div>`,
+ html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconSparkles"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.aiWriting}</span>${getHotkeyOrMarker(window.siyuan.config.keymap.editor.general.aiWriting.custom, "")}</div>`,
}, {
filter: [window.siyuan.languages.database, "database", "db", "数据库", "shujuku", "sjk", "视图", "view"],
id: "database",
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 88013a2aa5..a28eabb086 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -69,6 +69,7 @@ import {checkFold} from "../../util/noRelyPCFunction";
import {AIActions} from "../../ai/actions";
import {openLink} from "../../editor/openLink";
import {onlyProtyleCommand} from "../../boot/globalEvent/command/protyle";
+import {AIChat} from "../../ai/chat";
export const getContentByInlineHTML = (range: Range, cb: (content: string) => void) => {
let html = "";
@@ -1704,6 +1705,13 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return;
}
+ if (!event.repeat && matchHotKey(window.siyuan.config.keymap.editor.general.aiWriting.custom, event)) {
+ event.preventDefault();
+ event.stopPropagation();
+ AIChat(protyle, nodeElement);
+ return;
+ }
+
// tab 需等待 list 和 table 处理完成
if (event.key === "Tab" && isNotCtrl(event) && !event.altKey) {
event.preventDefault();