parent
b1282c9562
commit
c29b4b3352
2 changed files with 16 additions and 2 deletions
|
|
@ -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 = {};
|
||||
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -193,6 +193,13 @@ export class mzta_Menus {
|
|||
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':
|
||||
let prefs2 = await browser.storage.sync.get({default_chatgpt_lang: getLanguageDisplayName(browser.i18n.getUILanguage())});
|
||||
|
|
|
|||
Loading…
Reference in a new issue