From c5b1d44fe09da53922a1c100b76a024ee1c82409 Mon Sep 17 00:00:00 2001 From: mic Date: Mon, 14 Oct 2024 22:39:38 +0200 Subject: [PATCH] filtering placeholders by type in autocomplete. see #157 --- customprompts/mzta-custom-prompts.html | 2 +- customprompts/mzta-custom-prompts.js | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/customprompts/mzta-custom-prompts.html b/customprompts/mzta-custom-prompts.html index 6293cac8..0da8e41d 100644 --- a/customprompts/mzta-custom-prompts.html +++ b/customprompts/mzta-custom-prompts.html @@ -42,7 +42,7 @@
- diff --git a/customprompts/mzta-custom-prompts.js b/customprompts/mzta-custom-prompts.js index 9a571fe9..6e72b4a3 100644 --- a/customprompts/mzta-custom-prompts.js +++ b/customprompts/mzta-custom-prompts.js @@ -114,11 +114,11 @@ document.addEventListener('DOMContentLoaded', async () => { } const textareas = document.querySelectorAll('.editor'); - autocompleteSuggestions = (await getPlaceholders(true)).map(p => '{%'+p.id+'%}'); + autocompleteSuggestions = (await getPlaceholders(true)).map(p => ({command: '{%'+p.id+'%}', type: p.type})); // console.log('>>>>>>>>>>> suggestions: ' + JSON.stringify(suggestions)); - textareas.forEach(textarea => textareaAutocomplete(textarea, autocompleteSuggestions, textarea.closest('.type_selector')?.value)); + textareas.forEach(textarea => textareaAutocomplete(textarea, autocompleteSuggestions)); // document.addEventListener('click', (e) => { // // Check if the click was outside the textarea or suggestion list @@ -299,7 +299,7 @@ function showItemRowEditor(tr) { tr.querySelector('.name_show').style.display = 'none'; const text_output = tr.querySelector('.text_output'); text_output.style.display = 'inline'; - textareaAutocomplete(text_output, autocompleteSuggestions, tr.closest('.type_selector').value) + textareaAutocomplete(text_output, autocompleteSuggestions) tr.querySelector('.text_show').style.display = 'none'; tr.querySelector('.type_output').style.display = 'inline'; tr.querySelector('.type_show').style.display = 'none'; @@ -425,7 +425,7 @@ function loadPromptsList(values){
- ` + type_output + ` + ` + type_output + `