diff --git a/app/src/ai/actions.ts b/app/src/ai/actions.ts
index 5cc00ec31..24bbd00b4 100644
--- a/app/src/ai/actions.ts
+++ b/app/src/ai/actions.ts
@@ -32,7 +32,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
ids.push(item.getAttribute("data-node-id"));
});
const customMenu: IMenu[] = [{
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiCustomAction,
click() {
const dialog = new Dialog({
@@ -92,7 +92,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
}
window.siyuan.storage[Constants.LOCAL_AI].forEach((item: { name: string, memo: string }) => {
customMenu.push({
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
action: "iconEdit",
label: `
${escapeHtml(item.name)}
`,
bind: (element) => {
@@ -172,7 +172,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
label: window.siyuan.languages.ai,
type: "submenu",
submenu: [{
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiContinueWrite,
click() {
fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Continue writing"}, (response) => {
@@ -180,11 +180,11 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
});
}
}, {
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiTranslate,
type: "submenu",
submenu: [{
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiTranslate_zh_Hans,
click() {
fetchPost("/api/ai/chatGPTWithAction", {
@@ -195,7 +195,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
});
}
}, {
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiTranslate_zh_Hant,
click() {
fetchPost("/api/ai/chatGPTWithAction", {
@@ -206,7 +206,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
});
}
}, {
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiTranslate_ja_JP,
click() {
fetchPost("/api/ai/chatGPTWithAction", {
@@ -217,7 +217,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
});
}
}, {
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiTranslate_ko_KR,
click() {
fetchPost("/api/ai/chatGPTWithAction", {
@@ -228,7 +228,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
});
}
}, {
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiTranslate_en_US,
click() {
fetchPost("/api/ai/chatGPTWithAction", {
@@ -239,7 +239,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
});
}
}, {
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiTranslate_es_ES,
click() {
fetchPost("/api/ai/chatGPTWithAction", {
@@ -250,7 +250,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
});
}
}, {
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiTranslate_fr_FR,
click() {
fetchPost("/api/ai/chatGPTWithAction", {
@@ -261,7 +261,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
});
}
}, {
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiTranslate_de_DE,
click() {
fetchPost("/api/ai/chatGPTWithAction", {
@@ -273,7 +273,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
}
}]
}, {
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiExtractSummary,
click() {
fetchPost("/api/ai/chatGPTWithAction", {
@@ -284,7 +284,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
});
}
}, {
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiBrainStorm,
click() {
fetchPost("/api/ai/chatGPTWithAction", {
@@ -295,7 +295,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
});
}
}, {
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
label: window.siyuan.languages.aiFixGrammarSpell,
click() {
fetchPost("/api/ai/chatGPTWithAction", {
@@ -306,7 +306,18 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
});
}
}, {
- iconHTML: Constants.ZWSP,
+ iconHTML: "",
+ label: window.siyuan.languages.aiFixGrammarSpell,
+ click() {
+ fetchPost("/api/ai/chatGPTWithAction", {
+ ids,
+ action: "Clear context"
+ }, (response) => {
+ fillContent(protyle, response.data, elements);
+ });
+ }
+ }, {
+ iconHTML: "",
label: window.siyuan.languages.custom,
type: "submenu",
submenu: customMenu
diff --git a/app/src/ai/chat.ts b/app/src/ai/chat.ts
index 92f03bfd3..a2cd79345 100644
--- a/app/src/ai/chat.ts
+++ b/app/src/ai/chat.ts
@@ -23,15 +23,19 @@ export const AIChat = (protyle: IProtyle, element: Element) => {
dialog.destroy();
});
btnsElement[1].addEventListener("click", () => {
+ let inputValue = inputElement.value;
fetchPost("/api/ai/chatGPT", {
- msg: inputElement.value,
+ msg: inputValue,
}, (response) => {
dialog.destroy();
let respContent = "";
if (response.data && "" !== response.data) {
respContent = "\n\n" + response.data;
}
- fillContent(protyle, `${inputElement.value}${respContent}`, [element]);
+ if (inputValue === "Clear context") {
+ inputValue = "";
+ }
+ fillContent(protyle, `${inputValue}${respContent}`, [element]);
});
});
};