From c29b4b335295da9929b88a835a43534fa074bb77 Mon Sep 17 00:00:00 2001 From: mic Date: Wed, 11 Feb 2026 21:45:48 +0100 Subject: [PATCH] userInput is now an array. see #525 #554 --- api_webchat/controller.js | 11 +++++++++-- js/mzta-menus.js | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/api_webchat/controller.js b/api_webchat/controller.js index 8b722a25..2525069e 100644 --- a/api_webchat/controller.js +++ b/api_webchat/controller.js @@ -262,7 +262,7 @@ browser.runtime.onMessage.addListener((message, sender, sendResponse) => { } break; case 'api_send_custom_text': - let userInput = message.custom_text; + let userInput = message.custom_text; // From version 4.0.0 this is an array if(userInput !== null) { if(!placeholdersUtils.hasPlaceholder(promptData.prompt, 'additional_text')){ // no additional_text placeholder, do as usual @@ -270,7 +270,14 @@ browser.runtime.onMessage.addListener((message, sender, sendResponse) => { }else{ // we have the additional_text placeholder, do the magic! let finalSubs = {}; - finalSubs["additional_text"] = userInput; + + if (Array.isArray(userInput)) { + userInput.forEach(obj => { + finalSubs[obj.placeholder.replace(/^{%|%}$/g, '').trim()] = obj.custom_text; + }); + } else { + finalSubs["additional_text"] = userInput; + } promptData.prompt = placeholdersUtils.replacePlaceholders({ text: promptData.prompt, replacements: finalSubs, diff --git a/js/mzta-menus.js b/js/mzta-menus.js index 4d04dcaf..b29ad6cc 100644 --- a/js/mzta-menus.js +++ b/js/mzta-menus.js @@ -192,6 +192,13 @@ export class mzta_Menus { only_quoted_text: only_quoted_text, tags_full_list: tags_full_list }); + + curr_prompt.custom_text_array = {}; + + if(placeholdersUtils.hasPlaceholder(curr_prompt.text, 'additional_text')){ + curr_prompt.custom_text_array = placeholdersUtils.getPlaceholdersAdditionalTextArray(curr_prompt.text); + } + console.log(">>>>>>>>>>>>>>>>>>> curr_prompt.custom_text_array: " + JSON.stringify(curr_prompt.custom_text_array)); switch(curr_prompt.id){ case 'prompt_translate_this':