mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add Popup.show.text
This commit is contained in:
@ -101,6 +101,21 @@ const showPopupHelper = {
|
|||||||
if (typeof result === 'string' || typeof result === 'boolean') throw new Error(`Invalid popup result. CONFIRM popups only support numbers, or null. Result: ${result}`);
|
if (typeof result === 'string' || typeof result === 'boolean') throw new Error(`Invalid popup result. CONFIRM popups only support numbers, or null. Result: ${result}`);
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Asynchronously displays a text popup with the given header and text, returning the clicked result button value.
|
||||||
|
*
|
||||||
|
* @param {string?} header - The header text for the popup.
|
||||||
|
* @param {string?} text - The main text for the popup.
|
||||||
|
* @param {PopupOptions} [popupOptions={}] - Options for the popup.
|
||||||
|
* @return {Promise<POPUP_RESULT>} A Promise that resolves with the result of the user's interaction.
|
||||||
|
*/
|
||||||
|
text: async (header, text, popupOptions = {}) => {
|
||||||
|
const content = PopupUtils.BuildTextWithHeader(header, text);
|
||||||
|
const popup = new Popup(content, POPUP_TYPE.TEXT, null, popupOptions);
|
||||||
|
const result = await popup.show();
|
||||||
|
if (typeof result === 'string' || typeof result === 'boolean') throw new Error(`Invalid popup result. TEXT popups only support numbers, or null. Result: ${result}`);
|
||||||
|
return result;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export class Popup {
|
export class Popup {
|
||||||
|
Reference in New Issue
Block a user