diff --git a/customprompts/mzta-custom-prompts.css b/customprompts/mzta-custom-prompts.css index 5a8e9bb1..d96b29ca 100644 --- a/customprompts/mzta-custom-prompts.css +++ b/customprompts/mzta-custom-prompts.css @@ -199,8 +199,10 @@ table .sort.desc { .hidden { display: none; } - +.need_custom_text_span, .need_selected_span{ + padding-right: 2px; +} @media (prefers-color-scheme: dark) { body { diff --git a/customprompts/mzta-custom-prompts.html b/customprompts/mzta-custom-prompts.html index 0da8e41d..885501c1 100644 --- a/customprompts/mzta-custom-prompts.html +++ b/customprompts/mzta-custom-prompts.html @@ -49,11 +49,11 @@ - +

- +
diff --git a/customprompts/mzta-custom-prompts.js b/customprompts/mzta-custom-prompts.js index f105427d..36874407 100644 --- a/customprompts/mzta-custom-prompts.js +++ b/customprompts/mzta-custom-prompts.js @@ -385,6 +385,11 @@ function handleCheckboxChange(e) { e.preventDefault(); e.target.setAttribute('checked_val', e.target.checked ? '1' : '0'); //console.log('>>>>>>>> checked_val: ' + e.target.getAttribute('checked_val')); + if (e.target.classList.contains('need_selected') || e.target.classList.contains('need_custom_text') || e.target.classList.contains('need_selected_new') || e.target.classList.contains('need_custom_text_new')) { + let textarea = e.target.closest('tr').querySelector('.text_output'); + checkPromptsConfigForPlaceholders(textarea); + } + } // Enable save button on input change @@ -449,11 +454,11 @@ function loadPromptsList(values){ ` + `
- __MSG_customPrompts_form_label_need_selected__ + __MSG_customPrompts_form_label_need_selected__
__MSG_customPrompts_form_label_need_signature__
- __MSG_customPrompts_form_label_need_custom_text__ + __MSG_customPrompts_form_label_need_custom_text__
__MSG_customPrompts_form_label_define_response_lang__
@@ -685,6 +690,8 @@ function textareaAutocomplete(textarea, suggestions) { const text = textarea.value.substring(0, cursorPosition); const match = text.match(/{%[^\s]*$/); + checkPromptsConfigForPlaceholders(textarea); + if (match) { const lastWord = match[0]; const tr = textarea.parentNode.parentNode.parentNode; @@ -788,4 +795,26 @@ function textareaAutocomplete(textarea, suggestions) { } }); +} + +function checkPromptsConfigForPlaceholders(textarea){ + // check additional_text and selected_text placeholders presence and the corrispondent checkboxes + if(String(textarea.value).indexOf('{%additional_text%}') != -1){ + let tr_ancestor = textarea.closest('tr'); + let need_custom_text_element = tr_ancestor.querySelector('.need_custom_text') || tr_ancestor.querySelector('.need_custom_text_new'); + if(!need_custom_text_element.checked){ + need_custom_text_element.closest('.need_custom_text_span').style.border = '2px solid red'; + }else{ + need_custom_text_element.closest('.need_custom_text_span').style.border = ''; + } + } + if(String(textarea.value).indexOf('{%selected_text%}') != -1){ + let tr_ancestor = textarea.closest('tr'); + let selected_text_element = tr_ancestor.querySelector('.need_selected') || tr_ancestor.querySelector('.need_selected_new'); + if(!selected_text_element.checked){ + selected_text_element.closest('.need_selected_span').style.border = '2px solid red'; + }else{ + selected_text_element.closest('.need_selected_span').style.border = ''; + } + } } \ No newline at end of file