Merge pull request #3456 from SillyTavern/mobile-prompt-itemization Allow mobile to access the "Raw Prompt" in Prompt Itemization

c7958a4bb8048042c3ac8df9d8b2c8b2bc360012

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
6 files changed, +24 -5Showing whitespace changes
public/css/mobile-styles.css+0 -2
@@ -216,8 +216,6 @@
216216
217 }217 }
218218
219 #showRawPrompt,
220 #copyPromptToClipboard,
221 #groupCurrentMemberPopoutButton,219 #groupCurrentMemberPopoutButton,
222 #summaryExtensionPopoutButton {220 #summaryExtensionPopoutButton {
223 display: none;221 display: none;
public/css/popup.css+4 -0
@@ -72,6 +72,10 @@ dialog {
72 overflow-x: auto;72 overflow-x: auto;
73}73}
7474
75.popup.left_aligned_dialogue_popup .popup-content {
76 text-align: start;
77}
78
75/* Opening animation */79/* Opening animation */
76.popup[opening] {80.popup[opening] {
77 animation: pop-in var(--popup-animation-speed) ease-in-out;81 animation: pop-in var(--popup-animation-speed) ease-in-out;
public/script.js+12 -1
@@ -5577,7 +5577,7 @@ async function promptItemize(itemizedPrompts, requestedMesId) {
5577 toastr.info(t`Copied!`);5577 toastr.info(t`Copied!`);
5578 });5578 });
55795579
5580 popup.dlg.querySelector('#showRawPrompt').addEventListener('click', function () {5580 popup.dlg.querySelector('#showRawPrompt').addEventListener('click', async function () {
5581 //console.log(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt);5581 //console.log(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt);
5582 console.log(PromptArrayItemForRawPromptDisplay);5582 console.log(PromptArrayItemForRawPromptDisplay);
5583 console.log(itemizedPrompts);5583 console.log(itemizedPrompts);
@@ -5585,6 +5585,17 @@ async function promptItemize(itemizedPrompts, requestedMesId) {
55855585
5586 const rawPrompt = flatten(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt);5586 const rawPrompt = flatten(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt);
55875587
5588 // Mobile needs special handholding. The side-view on the popup wouldn't work,
5589 // so we just show an additional popup for this.
5590 if (isMobile()) {
5591 const content = document.createElement('div');
5592 content.classList.add('tokenItemizingMaintext');
5593 content.innerText = rawPrompt;
5594 const popup = new Popup(content, POPUP_TYPE.TEXT, null, { allowVerticalScrolling: true, leftAlign: true });
5595 await popup.show();
5596 return;
5597 }
5598
5588 //let DisplayStringifiedPrompt = JSON.stringify(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt).replace(/\n+/g, '<br>');5599 //let DisplayStringifiedPrompt = JSON.stringify(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt).replace(/\n+/g, '<br>');
5589 const rawPromptWrapper = document.getElementById('rawPromptWrapper');5600 const rawPromptWrapper = document.getElementById('rawPromptWrapper');
5590 rawPromptWrapper.innerText = rawPrompt;5601 rawPromptWrapper.innerText = rawPrompt;
public/scripts/popup.js+3 -1
@@ -46,6 +46,7 @@ export const POPUP_RESULT = {
46 * @property {boolean?} [transparent=false] - Whether to display the popup in transparent mode (no background, border, shadow or anything, only its content)46 * @property {boolean?} [transparent=false] - Whether to display the popup in transparent mode (no background, border, shadow or anything, only its content)
47 * @property {boolean?} [allowHorizontalScrolling=false] - Whether to allow horizontal scrolling in the popup47 * @property {boolean?} [allowHorizontalScrolling=false] - Whether to allow horizontal scrolling in the popup
48 * @property {boolean?} [allowVerticalScrolling=false] - Whether to allow vertical scrolling in the popup48 * @property {boolean?} [allowVerticalScrolling=false] - Whether to allow vertical scrolling in the popup
49 * @property {boolean?} [leftAlign=false] - Whether the popup content should be left-aligned by default
49 * @property {'slow'|'fast'|'none'?} [animation='slow'] - Animation speed for the popup (opening, closing, ...)50 * @property {'slow'|'fast'|'none'?} [animation='slow'] - Animation speed for the popup (opening, closing, ...)
50 * @property {POPUP_RESULT|number?} [defaultResult=POPUP_RESULT.AFFIRMATIVE] - The default result of this popup when Enter is pressed. Can be changed from `POPUP_RESULT.AFFIRMATIVE`.51 * @property {POPUP_RESULT|number?} [defaultResult=POPUP_RESULT.AFFIRMATIVE] - The default result of this popup when Enter is pressed. Can be changed from `POPUP_RESULT.AFFIRMATIVE`.
51 * @property {CustomPopupButton[]|string[]?} [customButtons=null] - Custom buttons to add to the popup. If only strings are provided, the buttons will be added with default options, and their result will be in order from `2` onward.52 * @property {CustomPopupButton[]|string[]?} [customButtons=null] - Custom buttons to add to the popup. If only strings are provided, the buttons will be added with default options, and their result will be in order from `2` onward.
@@ -173,7 +174,7 @@ export class Popup {
173 * @param {string} [inputValue=''] - The initial value of the input field174 * @param {string} [inputValue=''] - The initial value of the input field
174 * @param {PopupOptions} [options={}] - Additional options for the popup175 * @param {PopupOptions} [options={}] - Additional options for the popup
175 */176 */
176 constructor(content, type, inputValue = '', { okButton = null, cancelButton = null, rows = 1, wide = false, wider = false, large = false, transparent = false, allowHorizontalScrolling = false, allowVerticalScrolling = false, animation = 'fast', defaultResult = POPUP_RESULT.AFFIRMATIVE, customButtons = null, customInputs = null, onClosing = null, onClose = null, cropAspect = null, cropImage = null } = {}) {177 constructor(content, type, inputValue = '', { okButton = null, cancelButton = null, rows = 1, wide = false, wider = false, large = false, transparent = false, allowHorizontalScrolling = false, allowVerticalScrolling = false, leftAlign = false, animation = 'fast', defaultResult = POPUP_RESULT.AFFIRMATIVE, customButtons = null, customInputs = null, onClosing = null, onClose = null, cropAspect = null, cropImage = null } = {}) {
177 Popup.util.popups.push(this);178 Popup.util.popups.push(this);
178179
179 // Make this popup uniquely identifiable180 // Make this popup uniquely identifiable
@@ -218,6 +219,7 @@ export class Popup {
218 if (transparent) this.dlg.classList.add('transparent_dialogue_popup');219 if (transparent) this.dlg.classList.add('transparent_dialogue_popup');
219 if (allowHorizontalScrolling) this.dlg.classList.add('horizontal_scrolling_dialogue_popup');220 if (allowHorizontalScrolling) this.dlg.classList.add('horizontal_scrolling_dialogue_popup');
220 if (allowVerticalScrolling) this.dlg.classList.add('vertical_scrolling_dialogue_popup');221 if (allowVerticalScrolling) this.dlg.classList.add('vertical_scrolling_dialogue_popup');
222 if (leftAlign) this.dlg.classList.add('left_aligned_dialogue_popup');
221 if (animation) this.dlg.classList.add('popup--animation-' + animation);223 if (animation) this.dlg.classList.add('popup--animation-' + animation);
222224
223 // If custom button captions are provided, we set them beforehand225 // If custom button captions are provided, we set them beforehand
public/scripts/templates/itemizationChat.html+1 -1
@@ -146,5 +146,5 @@
146</div>146</div>
147<hr>147<hr>
148<div id="rawPromptPopup" class="list-group">148<div id="rawPromptPopup" class="list-group">
149 <div id="rawPromptWrapper" class="tokenItemizingSubclass"></div>149 <div id="rawPromptWrapper" class="tokenItemizingMaintext"></div>
150</div>150</div>
public/style.css+4 -0
@@ -262,6 +262,10 @@ input[type='checkbox']:focus-visible {
262 color: var(--SmartThemeEmColor);262 color: var(--SmartThemeEmColor);
263}263}
264264
265.tokenItemizingMaintext {
266 font-size: calc(var(--mainFontSize) * 0.8);
267}
268
265.tokenGraph {269.tokenGraph {
266 border-radius: 10px;270 border-radius: 10px;
267 border: 1px solid var(--SmartThemeBorderColor);271 border: 1px solid var(--SmartThemeBorderColor);