diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 817bfe66..c6aacb70 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -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": "" diff --git a/pages/get-calendar-event/mzta-get-calendar-event.js b/pages/get-calendar-event/mzta-get-calendar-event.js index 7dc9a0e9..ca3c8ef7 100644 --- a/pages/get-calendar-event/mzta-get-calendar-event.js +++ b/pages/get-calendar-event/mzta-get-calendar-event.js @@ -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"});