Vanessa 2024-08-09 22:32:38 +08:00
parent d15865975f
commit e53fe42a46
7 changed files with 20 additions and 3 deletions

View file

@ -1,4 +1,5 @@
{
"clearContextSucc": "The context has been cleared",
"emptyPlaceholder": "Write something, '/' for commands",
"publish": "Publish",
"publishService": "Publish service",

View file

@ -1,4 +1,5 @@
{
"clearContextSucc": "Se ha borrado el contexto",
"emptyPlaceholder": "Escribe algo, '/' para los comandos",
"publish": "Publicar",
"publishService": "Publicar servicio",

View file

@ -1,4 +1,5 @@
{
"clearContextSucc": "Le contexte a été effacé",
"emptyPlaceholder": "Écrivez quelque chose, '/' pour les commandes",
"publish": "Publier",
"publishService": "Publier le service",

View file

@ -1,4 +1,5 @@
{
"clearContextSucc": "コンテキストがクリアされました",
"emptyPlaceholder": "何か書いてください。コマンドの場合は「/」",
"publish": "公開する",
"publishService": "サービスを公開",

View file

@ -1,4 +1,5 @@
{
"clearContextSucc": "上下文已清空",
"emptyPlaceholder": "寫點什麼,或按下 '/' 查看指令",
"publish": "發布",
"publishService": "發布服務",

View file

@ -1,4 +1,5 @@
{
"clearContextSucc": "上下文已清空",
"emptyPlaceholder": "写点什么,或按下 '/' 查看命令",
"publish": "发布",
"publishService": "发布服务",

View file

@ -174,6 +174,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
if (customHTML) {
customHTML = `<div class="b3-menu__separator"></div>${customHTML}`;
}
const clearContext = "Clear context"
menu.addItem({
iconHTML: "",
type: "empty",
@ -194,7 +195,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
<div class="b3-list-item b3-list-item--narrow" data-action="${window.siyuan.languages.aiFixGrammarSpell}">
${window.siyuan.languages.aiFixGrammarSpell}
</div>
<div class="b3-list-item b3-list-item--narrow" data-action="Clear context">
<div class="b3-list-item b3-list-item--narrow" data-action="${clearContext}">
${window.siyuan.languages.clearContext}
</div>
<div class="b3-menu__separator"></div>
@ -227,6 +228,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
const currentElement = listElement.querySelector(".b3-list-item--focus") as HTMLElement;
if (currentElement.dataset.type === "custom") {
customDialog(protyle, ids, elements);
menu.close();
} else {
fetchPost("/api/ai/chatGPTWithAction", {
ids,
@ -234,8 +236,12 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
}, (response) => {
fillContent(protyle, response.data, elements);
});
if (currentElement.dataset.action === clearContext) {
showMessage(window.siyuan.languages.clearContextSucc)
} else {
menu.close();
}
}
menu.close();
}
});
inputElement.addEventListener("compositionend", () => {
@ -260,12 +266,17 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
} else if (target.classList.contains("b3-list-item")) {
if (target.dataset.type === "custom") {
customDialog(protyle, ids, elements);
menu.close();
} else {
fetchPost("/api/ai/chatGPTWithAction", {ids, action: target.dataset.action}, (response) => {
fillContent(protyle, response.data, elements);
});
if (target.dataset.action === clearContext) {
showMessage(window.siyuan.languages.clearContextSucc)
} else {
menu.close();
}
}
menu.close();
event.stopPropagation();
event.preventDefault();
break;