diff --git a/app/src/constants.ts b/app/src/constants.ts
index 21d2e35ff..e595f9d0e 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 54a58dd51..f224c8d83 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 ``;
- } else {
+ } else if (marker) {
return `${marker}`;
}
};
@@ -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: `
${window.siyuan.languages.aiWriting}
`,
+ html: `${window.siyuan.languages.aiWriting}${getHotkeyOrMarker(window.siyuan.config.keymap.editor.general.aiWriting.custom, "")}
`,
}, {
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 88013a2aa..a28eabb08 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();