Merge pull request #221 from micz/issue196
Added new mail_typed_text data placeholder
This commit is contained in:
commit
f188a245c2
6 changed files with 40 additions and 5 deletions
|
|
@ -8,6 +8,7 @@
|
|||
<h2>Version 3.1.0 - ??/??/2025</h2>
|
||||
<ul>
|
||||
<li>Added Google Gemini API support [<a href="https://github.com/micz/ThunderAI/issues/204">#204</a>, <a href="https://github.com/micz/ThunderAI/issues/217">#2174</a>].</li>
|
||||
<li>Added <i>{%mail_typed_text%}</i> data placeholder to get the text inserted before the quoted mail body when replying [<a href="https://github.com/micz/ThunderAI/issues/196">#196</a>].</li>
|
||||
<li>Added an info text about using the new <i>{%tags_full_list%}</i> placeholder in the "Add Tags Prompt" page [<a href="https://github.com/micz/ThunderAI/issues/215">#215</a>].</li>
|
||||
<li>...</li>
|
||||
</ul>
|
||||
|
|
@ -15,8 +16,8 @@
|
|||
<ul>
|
||||
<li><i>[ChatGPT API][Ollama API][OpenAI Comp API]</i> Added a special prompt to apply tags to emails [<a href="https://github.com/micz/ThunderAI/issues/183">#183</a>].</li>
|
||||
<li>Default prompts text has been translated [<a href="https://github.com/micz/ThunderAI/issues/185">#185</a>].</li>
|
||||
<li>Data placeholder <i>{%tags_full_list%}</i> for the full available tags list added [<a href="https://github.com/micz/ThunderAI/issues/197">#197</a>].</li>
|
||||
<li>Data placeholder <i>{%tags_current_email%}</i> for the single mail tags list added [<a href="https://github.com/micz/ThunderAI/issues/198">#198</a>].</li>
|
||||
<li>Added <i>{%tags_full_list%}</i> data placeholder for the full available tags list added [<a href="https://github.com/micz/ThunderAI/issues/197">#197</a>].</li>
|
||||
<li>Added <i>{%tags_current_email%}</i> data placeholder for the single mail tags list added [<a href="https://github.com/micz/ThunderAI/issues/198">#198</a>].</li>
|
||||
<li>User <a href="https://forms.gle/1qK2wcbuhaRzhwyt9">survey link</a> added [<a href="https://github.com/micz/ThunderAI/issues/202">#202</a>].</li>
|
||||
<li><i>[OpenAI Comp API]</i> Added a button in the options page to manually insert the model [<a href="https://github.com/micz/ThunderAI/issues/205">#205</a>].</li>
|
||||
<li>Polish (pl) translation added, thanks to <a href="https://github.com/neexpl">neexpl</a>.</li>
|
||||
|
|
|
|||
|
|
@ -950,5 +950,9 @@
|
|||
"prefs_OptionText_btnManagePrompts_infoline3": {
|
||||
"message": "You can use the {%tags_full_list%} data placeholder in the prompt to list the available tags. With an appropriate prompt, you could then force the tags to be chosen only from the list of those already existing.",
|
||||
"description": ""
|
||||
},
|
||||
"placeholder_mail_typed_text": {
|
||||
"message": "Typed text before the quoted mail body",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ switch (message.command) {
|
|||
return Promise.resolve(true);
|
||||
break;
|
||||
|
||||
case "getText":
|
||||
case "getText": {
|
||||
let t = '';
|
||||
const children = window.document.body.childNodes;
|
||||
for (const node of children) {
|
||||
|
|
@ -51,6 +51,7 @@ switch (message.command) {
|
|||
t += node.textContent;
|
||||
}
|
||||
return Promise.resolve(t);
|
||||
}
|
||||
|
||||
case "getTextOnly":
|
||||
return Promise.resolve(window.document.body.innerText);
|
||||
|
|
@ -58,6 +59,21 @@ switch (message.command) {
|
|||
case "getFullHtml":
|
||||
return Promise.resolve(window.document.body.innerHTML);
|
||||
|
||||
case "getOnlyTypedText": {
|
||||
// TODO: add support for moz-cite-prefix
|
||||
let t = '';
|
||||
const children = window.document.body.childNodes;
|
||||
for (const node of children) {
|
||||
if (node instanceof Element) {
|
||||
if (node.classList.contains('moz-cite-prefix')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
t += node.textContent;
|
||||
}
|
||||
return Promise.resolve(t);
|
||||
}
|
||||
|
||||
case 'sendAlert':
|
||||
//console.log(">>>>>> message.curr_tab_type: " + JSON.stringify(message.curr_tab_type));
|
||||
if(message.curr_tab_type == 'mail'){ // workaround for Thunderbird bug not showing the alert
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ export class mzta_Menus {
|
|||
selection: await browser.tabs.sendMessage(tabs[0].id, { command: "getSelectedText" }),
|
||||
text: await browser.tabs.sendMessage(tabs[0].id, { command: "getTextOnly" }),
|
||||
html: await browser.tabs.sendMessage(tabs[0].id, { command: "getFullHtml" }),
|
||||
only_typed_text: await browser.tabs.sendMessage(tabs[0].id, { command: "getOnlyTypedText" })
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -99,8 +100,10 @@ export class mzta_Menus {
|
|||
|
||||
let body_text = '';
|
||||
let selection_text = '';
|
||||
let only_typed_text = '';
|
||||
selection_text = msg_text.selection.replace(/\s+/g, ' ').trim();
|
||||
body_text = msg_text.text.replace(/\s+/g, ' ').trim();
|
||||
only_typed_text = msg_text.only_typed_text.replace(/\s+/g, ' ').trim();
|
||||
//open chatgpt window
|
||||
//console.log("Click menu item...");
|
||||
let chatgpt_lang = '';
|
||||
|
|
@ -150,6 +153,9 @@ export class mzta_Menus {
|
|||
case 'mail_html_body':
|
||||
finalSubs['mail_html_body'] = msg_text.html;
|
||||
break;
|
||||
case 'mail_typed_text':
|
||||
finalSubs['mail_typed_text'] = only_typed_text;
|
||||
break;
|
||||
case 'mail_subject':
|
||||
let mail_subject = await getMailSubject(tabs[0]);
|
||||
finalSubs['mail_subject'] = mail_subject;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,13 @@ const defaultPlaceholders = [
|
|||
type: 0,
|
||||
is_default: "1",
|
||||
},
|
||||
{
|
||||
id: 'mail_typed_text',
|
||||
name: "__MSG_placeholder_mail_typed_text__",
|
||||
default_value: "",
|
||||
type: 2,
|
||||
is_default: "1",
|
||||
},
|
||||
{
|
||||
id: 'mail_subject',
|
||||
name: "__MSG_placeholder_mail_subject__",
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
<h2>Version 3.1.0 - ??/??/2025</h2>
|
||||
<ul>
|
||||
<li>Added Google Gemini API support [<a href="https://github.com/micz/ThunderAI/issues/204">#204</a>, <a href="https://github.com/micz/ThunderAI/issues/217">#2174</a>].</li>
|
||||
<li>Added <i>{%mail_typed_text%}</i> data placeholder to get the text inserted before the quoted mail body when replying [<a href="https://github.com/micz/ThunderAI/issues/196">#196</a>].</li>
|
||||
<li>Added an info text about using the new <i>{%tags_full_list%}</i> placeholder in the "Add Tags Prompt" page [<a href="https://github.com/micz/ThunderAI/issues/215">#215</a>].</li>
|
||||
<li>...</li>
|
||||
</ul>
|
||||
|
|
@ -17,8 +18,8 @@
|
|||
<ul>
|
||||
<li><i>[ChatGPT API][Ollama API][OpenAI Comp API]</i> Added a special prompt to apply tags to emails [<a href="https://github.com/micz/ThunderAI/issues/183">#183</a>].</li>
|
||||
<li>Default prompts text has been translated [<a href="https://github.com/micz/ThunderAI/issues/185">#185</a>].</li>
|
||||
<li>Data placeholder <i>{%tags_full_list%}</i> for the full available tags list added [<a href="https://github.com/micz/ThunderAI/issues/197">#197</a>].</li>
|
||||
<li>Data placeholder <i>{%tags_current_email%}</i> for the single mail tags list added [<a href="https://github.com/micz/ThunderAI/issues/198">#198</a>].</li>
|
||||
<li>Added <i>{%tags_full_list%}</i> data placeholder for the full available tags list added [<a href="https://github.com/micz/ThunderAI/issues/197">#197</a>].</li>
|
||||
<li>Added <i>{%tags_current_email%}</i> data placeholder for the single mail tags list added [<a href="https://github.com/micz/ThunderAI/issues/198">#198</a>].</li>
|
||||
<li>User <a href="https://forms.gle/1qK2wcbuhaRzhwyt9">survey link</a> added [<a href="https://github.com/micz/ThunderAI/issues/202">#202</a>].</li>
|
||||
<li>Polish (pl) translation added, thanks to <a href="https://github.com/neexpl">neexpl</a>.</li>
|
||||
<li><i>[OpenAI Comp API]</i> Added a button in the options page to manually insert the model [<a href="https://github.com/micz/ThunderAI/issues/205">#205</a>].</li>
|
||||
|
|
|
|||
Loading…
Reference in a new issue