mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-21 07:46:09 +01:00
This commit is contained in:
parent
33c933c440
commit
deecebe12e
5 changed files with 49 additions and 0 deletions
|
|
@ -37,6 +37,10 @@ export const hintSlash = (key: string, protyle: IProtyle) => {
|
|||
value: "{{",
|
||||
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconSQL"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.blockEmbed}</span><span class="b3-list-item__meta">{{</span></div>`,
|
||||
}, {
|
||||
filter: ["AI Chat"],
|
||||
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">AI Chat</span></div>',
|
||||
},{
|
||||
filter: ["属性试图", "shuxingshitu", "sxst", "attribute view"],
|
||||
value: '<div data-type="NodeAttributeView" data-av-type="table"></div>',
|
||||
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconDatabase"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.attributeView}</span></div>`,
|
||||
|
|
|
|||
|
|
@ -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)}</button>`;
|
|||
/// #endif
|
||||
});
|
||||
return;
|
||||
} else if (value === Constants.ZWSP + 5) {
|
||||
const dialog = new Dialog({
|
||||
title: "AI Chat",
|
||||
content: `<div class="b3-dialog__content"><input class="b3-text-field fn__block" value=""></div>
|
||||
<div class="b3-dialog__action">
|
||||
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
||||
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
|
||||
</div>`,
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue