checking for the correct placeholder before activating the no selection option in get calendar event. see #670

This commit is contained in:
mic 2026-02-22 22:39:59 +01:00
parent 67a922ee02
commit 470b78ce90
2 changed files with 13 additions and 0 deletions

View file

@ -1881,6 +1881,10 @@
"message": "If checked there is no need to select some text. The full message body will be used to get the calendar event.",
"description": ""
},
"prefs_OptionText_calendar_no_selection_missing_placeholder": {
"message": "The prompt must contain the placeholder {%mail_text_body_or_selected%} or {%mail_html_body_or_selected%} to enable this option. Please add one of these placeholders to the prompt or reset it to the default.",
"description": ""
},
"customPrompts_btnCopy": {
"message": "Copy",
"description": ""

View file

@ -98,6 +98,15 @@ document.addEventListener('DOMContentLoaded', async () => {
});
get_calendar_event_no_selection.addEventListener('change', async (event) => {
if (event.target.checked) {
const currentPromptText = get_calendar_event_textarea.value;
const hasBodyOrSelected = currentPromptText.includes('{%mail_text_body_or_selected%}') || currentPromptText.includes('{%mail_html_body_or_selected%}');
if (!hasBodyOrSelected) {
alert(browser.i18n.getMessage('prefs_OptionText_calendar_no_selection_missing_placeholder'));
event.target.checked = false;
return;
}
}
specialPrompts.find(prompt => prompt.id === 'prompt_get_calendar_event').need_selected = event.target.checked ? '0' : '1';
await setSpecialPrompts(specialPrompts);
browser.runtime.sendMessage({command: "reload_menus"});