Vanessa 2025-02-20 13:06:40 +08:00
parent ca1c8af16d
commit 74f5aa08ac
3 changed files with 11 additions and 2 deletions

View file

@ -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"},

View file

@ -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",

View file

@ -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();