mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
33c933c440
commit
deecebe12e
5 changed files with 49 additions and 0 deletions
|
|
@ -1,5 +1,8 @@
|
|||
document.body.insertAdjacentHTML('afterBegin', `<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<symbol id="iconSparkles" viewBox="0 0 32 32">
|
||||
<path d="M25.96 10.739l-1.464-3.405-3.541-1.566 3.541-1.532 1.464-3.235 1.464 3.235 3.541 1.532-3.541 1.566-1.464 3.405zM25.96 31l-1.464-3.269-3.541-1.532 3.541-1.532 1.464-3.439 1.464 3.439 3.541 1.532-3.541 1.532-1.464 3.269zM11.011 25.756l-3.133-6.708-6.844-3.065 6.844-3.065 3.133-6.674 3.167 6.674 6.81 3.065-6.81 3.065-3.167 6.708zM11.011 20.716l1.635-3.269 3.337-1.464-3.337-1.464-1.635-3.269-1.6 3.269-3.371 1.464 3.371 1.464 1.6 3.269z"></path>
|
||||
</symbol>
|
||||
<symbol id="iconDatabase" viewBox="0 0 32 32">
|
||||
<path d="M16 14.278q-6.932 0-11.216-2.11t-4.284-4.779q0-2.712 4.284-4.801t11.216-2.088 11.216 2.088 4.284 4.801q0 2.669-4.284 4.779t-11.216 2.11zM16 22.889q-6.286 0-10.893-1.894t-4.607-4.564v-4.306q0 1.679 1.615 2.906t4.004 2.024 5.081 1.163 4.801 0.366q2.153 0 4.822-0.366t5.059-1.141 4.004-2.002 1.615-2.949v4.306q0 2.669-4.607 4.564t-10.893 1.894zM16 31.5q-6.286 0-10.893-1.894t-4.607-4.564v-4.306q0 1.679 1.615 2.906t4.004 2.024 5.081 1.163 4.801 0.366q2.153 0 4.822-0.366t5.059-1.141 4.004-2.002 1.615-2.949v4.306q0 2.669-4.607 4.564t-10.893 1.894z"></path>
|
||||
</symbol>
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@
|
|||
<body>
|
||||
<h2>SiYuan</h2>
|
||||
<div class="fn__clear">
|
||||
<div>
|
||||
<svg>
|
||||
<use xlink:href="#iconSparkles"></use>
|
||||
</svg>
|
||||
iconSparkles
|
||||
</div>
|
||||
<div>
|
||||
<svg>
|
||||
<use xlink:href="#iconDatabase"></use>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
document.body.insertAdjacentHTML('afterbegin', `<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<symbol id="iconSparkles" viewBox="0 0 32 32">
|
||||
<path d="M25.96 10.739l-1.464-3.405-3.541-1.566 3.541-1.532 1.464-3.235 1.464 3.235 3.541 1.532-3.541 1.566-1.464 3.405zM25.96 31l-1.464-3.269-3.541-1.532 3.541-1.532 1.464-3.439 1.464 3.439 3.541 1.532-3.541 1.532-1.464 3.269zM11.011 25.756l-3.133-6.708-6.844-3.065 6.844-3.065 3.133-6.674 3.167 6.674 6.81 3.065-6.81 3.065-3.167 6.708zM11.011 20.716l1.635-3.269 3.337-1.464-3.337-1.464-1.635-3.269-1.6 3.269-3.371 1.464 3.371 1.464 1.6 3.269z"></path>
|
||||
</symbol>
|
||||
<symbol id="iconDatabase" viewBox="0 0 32 32">
|
||||
<path d="M16 14.278q-6.932 0-11.216-2.11t-4.284-4.779q0-2.712 4.284-4.801t11.216-2.088 11.216 2.088 4.284 4.801q0 2.669-4.284 4.779t-11.216 2.11zM16 22.889q-6.286 0-10.893-1.894t-4.607-4.564v-4.306q0 1.679 1.615 2.906t4.004 2.024 5.081 1.163 4.801 0.366q2.153 0 4.822-0.366t5.059-1.141 4.004-2.002 1.615-2.949v4.306q0 2.669-4.607 4.564t-10.893 1.894zM16 31.5q-6.286 0-10.893-1.894t-4.607-4.564v-4.306q0 1.679 1.615 2.906t4.004 2.024 5.081 1.163 4.801 0.366q2.153 0 4.822-0.366t5.059-1.141 4.004-2.002 1.615-2.949v4.306q0 2.669-4.607 4.564t-10.893 1.894z"></path>
|
||||
</symbol>
|
||||
|
|
|
|||
|
|
@ -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