diff --git a/app/appearance/icons/ant/icon.js b/app/appearance/icons/ant/icon.js index 79e4afbcc..1c2766362 100644 --- a/app/appearance/icons/ant/icon.js +++ b/app/appearance/icons/ant/icon.js @@ -1,5 +1,8 @@ document.body.insertAdjacentHTML('afterBegin', ` + + + diff --git a/app/appearance/icons/index.html b/app/appearance/icons/index.html index 18f6023a0..e23b01702 100644 --- a/app/appearance/icons/index.html +++ b/app/appearance/icons/index.html @@ -28,6 +28,12 @@

SiYuan

+
+ + + + iconSparkles +
diff --git a/app/appearance/icons/material/icon.js b/app/appearance/icons/material/icon.js index 58f11e2a1..e66b707b7 100644 --- a/app/appearance/icons/material/icon.js +++ b/app/appearance/icons/material/icon.js @@ -1,5 +1,8 @@ document.body.insertAdjacentHTML('afterbegin', ` + + + diff --git a/app/src/protyle/hint/extend.ts b/app/src/protyle/hint/extend.ts index f54ef61c3..fdcc40d9f 100644 --- a/app/src/protyle/hint/extend.ts +++ b/app/src/protyle/hint/extend.ts @@ -37,6 +37,10 @@ export const hintSlash = (key: string, protyle: IProtyle) => { value: "{{", html: `
${window.siyuan.languages.blockEmbed}{{
`, }, { + filter: ["AI Chat"], + value: Constants.ZWSP + 5, + html: '
AI Chat
', + },{ filter: ["属性试图", "shuxingshitu", "sxst", "attribute view"], value: '
', html: `
${window.siyuan.languages.attributeView}
`, diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts index 216242545..ae2f95072 100644 --- a/app/src/protyle/hint/index.ts +++ b/app/src/protyle/hint/index.ts @@ -30,6 +30,9 @@ import {openMobileFileById} from "../../mobile/editor"; import {getIconByType} from "../../editor/getIcon"; import {processRender} from "../util/processCode"; import {getEventName} from "../util/compatibility"; +import {Dialog} from "../../dialog"; +import {isMobile} from "../../util/functions"; +import {progressLoading} from "../../dialog/processSystem"; export class Hint { public timeId: number; @@ -542,6 +545,36 @@ ${unicode2Emoji(emoji.unicode, true)}`; /// #endif }); return; + } else if (value === Constants.ZWSP + 5) { + const dialog = new Dialog({ + title: "AI Chat", + content: `
+
+
+ +
`, + width: isMobile() ? "80vw" : "520px", + }) + const inputElement = dialog.element.querySelector("input") as HTMLInputElement; + const btnsElement = dialog.element.querySelectorAll(".b3-button"); + dialog.bindInput(inputElement, () => { + (btnsElement[1] as HTMLButtonElement).click(); + }); + inputElement.focus(); + btnsElement[0].addEventListener("click", () => { + dialog.destroy(); + }); + btnsElement[1].addEventListener("click", () => { + progressLoading({code: 1, cmd:"", data:"", msg:"", sid:""}); + fetchPost("/api/ai/chatGPT", { + msg: inputElement.value, + }, (response) => { + insertHTML(response.data, protyle, true); + progressLoading({code: 2, cmd:"", data:"", msg:"", sid:""}); + dialog.destroy(); + }); + }); + return; } else if (Constants.INLINE_TYPE.includes(value)) { range.deleteContents(); focusByRange(range);