From 8b372637382a6cdc1ff0bbbca6713e7cb6ab1d5d Mon Sep 17 00:00:00 2001 From: mic Date: Sun, 15 Dec 2024 20:27:40 +0100 Subject: [PATCH] checkPromptsConfigForPlaceholders binded to the onInput event for the text area --- pages/customprompts/mzta-custom-prompts.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pages/customprompts/mzta-custom-prompts.js b/pages/customprompts/mzta-custom-prompts.js index 155c93a2..a6b6a4e5 100644 --- a/pages/customprompts/mzta-custom-prompts.js +++ b/pages/customprompts/mzta-custom-prompts.js @@ -118,7 +118,16 @@ document.addEventListener('DOMContentLoaded', async () => { // console.log('>>>>>>>>>>> suggestions: ' + JSON.stringify(suggestions)); - textareas.forEach(textarea => textareaAutocomplete(textarea, autocompleteSuggestions)); + textareas.forEach(textarea => { + textareaAutocomplete(textarea, autocompleteSuggestions); +textareas.forEach(textarea => { + textarea.addEventListener('input', (e) => { + checkPromptsConfigForPlaceholders(e.target); + }); + textareaAutocomplete(textarea, autocompleteSuggestions); +}); + + }); // document.addEventListener('click', (e) => { // // Check if the click was outside the textarea or suggestion list @@ -690,8 +699,6 @@ 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;