diff --git a/public/index.html b/public/index.html index 15ae9a976..3b619ccaf 100644 --- a/public/index.html +++ b/public/index.html @@ -6400,9 +6400,6 @@ -
-
-
diff --git a/public/script.js b/public/script.js index a596ebcee..d0b95707b 100644 --- a/public/script.js +++ b/public/script.js @@ -513,9 +513,6 @@ let optionsPopper = Popper.createPopper(document.getElementById('options_button' let exportPopper = Popper.createPopper(document.getElementById('export_button'), document.getElementById('export_format_popup'), { placement: 'left', }); -let rawPromptPopper = Popper.createPopper(document.getElementById('dialogue_popup'), document.getElementById('rawPromptPopup'), { - placement: 'right', -}); // Saved here for performance reasons const messageTemplate = $('#message_template .mes'); @@ -4890,14 +4887,44 @@ async function promptItemize(itemizedPrompts, requestedMesId) { const params = await itemizedParams(itemizedPrompts, thisPromptSet); - if (params.this_main_api == 'openai') { - const template = await renderTemplateAsync('itemizationChat', params); - callPopup(template, 'text'); + const template = params.this_main_api == 'openai' + ? await renderTemplateAsync('itemizationChat', params) + : await renderTemplateAsync('itemizationText', params); - } else { - const template = await renderTemplateAsync('itemizationText', params); - callPopup(template, 'text'); - } + const popup = new Popup(template, POPUP_TYPE.TEXT); + + popup.dlg.querySelector('#copyPromptToClipboard').addEventListener('click', function () { + let rawPrompt = itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt; + let rawPromptValues = rawPrompt; + + if (Array.isArray(rawPrompt)) { + rawPromptValues = rawPrompt.map(x => x.content).join('\n'); + } + + navigator.clipboard.writeText(rawPromptValues); + toastr.info('Copied!'); + }); + + popup.dlg.querySelector('#showRawPrompt').addEventListener('click', function () { + //console.log(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt); + console.log(PromptArrayItemForRawPromptDisplay); + console.log(itemizedPrompts); + console.log(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt); + + let rawPrompt = itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt; + let rawPromptValues = rawPrompt; + + if (Array.isArray(rawPrompt)) { + rawPromptValues = rawPrompt.map(x => x.content).join('\n'); + } + + //let DisplayStringifiedPrompt = JSON.stringify(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt).replace(/\n+/g, '
'); + const rawPromptWrapper = document.getElementById('rawPromptWrapper'); + rawPromptWrapper.innerText = rawPromptValues; + $('#rawPromptPopup').slideToggle(); + }); + + await popup.show(); } function setInContextMessages(lastmsg, type) { @@ -9223,9 +9250,6 @@ jQuery(async function () { } } - rawPromptPopper.update(); - $('#rawPromptPopup').hide(); - if (dialogueResolve) { if (popup_type == 'input') { dialogueResolve($('#dialogue_popup_input').val()); @@ -9816,45 +9840,14 @@ jQuery(async function () { }); } - $(document).on('pointerup', '.mes_prompt', function () { + $(document).on('pointerup', '.mes_prompt', async function () { let mesIdForItemization = $(this).closest('.mes').attr('mesId'); console.log(`looking for mesID: ${mesIdForItemization}`); if (itemizedPrompts.length !== undefined && itemizedPrompts.length !== 0) { - promptItemize(itemizedPrompts, mesIdForItemization); + await promptItemize(itemizedPrompts, mesIdForItemization); } }); - $(document).on('pointerup', '#copyPromptToClipboard', function () { - let rawPrompt = itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt; - let rawPromptValues = rawPrompt; - - if (Array.isArray(rawPrompt)) { - rawPromptValues = rawPrompt.map(x => x.content).join('\n'); - } - - navigator.clipboard.writeText(rawPromptValues); - toastr.info('Copied!', '', { timeOut: 2000 }); - }); - - $(document).on('pointerup', '#showRawPrompt', function () { - //console.log(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt); - console.log(PromptArrayItemForRawPromptDisplay); - console.log(itemizedPrompts); - console.log(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt); - - let rawPrompt = itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt; - let rawPromptValues = rawPrompt; - - if (Array.isArray(rawPrompt)) { - rawPromptValues = rawPrompt.map(x => x.content).join('\n'); - } - - //let DisplayStringifiedPrompt = JSON.stringify(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt).replace(/\n+/g, '
'); - $('#rawPromptWrapper').text(rawPromptValues); - rawPromptPopper.update(); - $('#rawPromptPopup').toggle(); - }); - //******************** //***Message Editor*** $(document).on('click', '.mes_edit', async function () { diff --git a/public/scripts/templates/itemizationChat.html b/public/scripts/templates/itemizationChat.html index d5a8de41f..969a31757 100644 --- a/public/scripts/templates/itemizationChat.html +++ b/public/scripts/templates/itemizationChat.html @@ -127,3 +127,6 @@ API Used: {{this_main_api}}

+
+
+
diff --git a/public/scripts/templates/itemizationText.html b/public/scripts/templates/itemizationText.html index efd9f84c1..b3855e027 100644 --- a/public/scripts/templates/itemizationText.html +++ b/public/scripts/templates/itemizationText.html @@ -107,3 +107,6 @@ API Used: {{this_main_api}}

+
+
+
diff --git a/public/style.css b/public/style.css index da3b29c9f..b097aac3c 100644 --- a/public/style.css +++ b/public/style.css @@ -256,10 +256,6 @@ input[type='checkbox']:focus-visible { color: var(--SmartThemeEmColor); } -#rawPromptWrapper { - white-space: pre-wrap; -} - .tokenGraph { border-radius: 10px; border: 1px solid var(--SmartThemeBorderColor); @@ -4367,8 +4363,7 @@ a { text-decoration: none; } -#export_format_popup, -#rawPromptPopup { +#export_format_popup { display: none; z-index: 9999; } @@ -4376,7 +4371,7 @@ a { #rawPromptPopup { inset: 0px auto auto 0px; margin: 0px; - transform: translate(909px, 47px); + transform: translate(500px, 0px); display: block; overflow-wrap: break-word; white-space: normal; @@ -4395,7 +4390,8 @@ a { display: none; } -#rawPopupWrapper { +#rawPromptWrapper { + white-space: pre-wrap; word-wrap: break-word; width: 100%; text-align: start;