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 -5Ignore whitespace
public/css/mobile-styles.css+0 -2
@@ -216,8 +216,6 @@
216216
217217 }
218218
219- #showRawPrompt,
220- #copyPromptToClipboard,
221219 #groupCurrentMemberPopoutButton,
222220 #summaryExtensionPopoutButton {
223221 display: none;
public/css/popup.css+4 -0
@@ -72,6 +72,10 @@ dialog {
7272 overflow-x: auto;
7373}
7474
75+.popup.left_aligned_dialogue_popup .popup-content {
76+ text-align: start;
77+}
78+
7579/* Opening animation */
7680.popup[opening] {
7781 animation: pop-in var(--popup-animation-speed) ease-in-out;
public/script.js+12 -1
@@ -5577,7 +5577,7 @@ async function promptItemize(itemizedPrompts, requestedMesId) {
55775577 toastr.info(t`Copied!`);
55785578 });
55795579
55805580 popup.dlg.querySelector('#showRawPrompt').addEventListener('click', async function () {
55815581 //console.log(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt);
55825582 console.log(PromptArrayItemForRawPromptDisplay);
55835583 console.log(itemizedPrompts);
@@ -5585,6 +5585,17 @@ async function promptItemize(itemizedPrompts, requestedMesId) {
55855585
55865586 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+
55885599 //let DisplayStringifiedPrompt = JSON.stringify(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt).replace(/\n+/g, '<br>');
55895600 const rawPromptWrapper = document.getElementById('rawPromptWrapper');
55905601 rawPromptWrapper.innerText = rawPrompt;
public/scripts/popup.js+3 -1
@@ -46,6 +46,7 @@ export const POPUP_RESULT = {
4646 * @property {boolean?} [transparent=false] - Whether to display the popup in transparent mode (no background, border, shadow or anything, only its content)
4747 * @property {boolean?} [allowHorizontalScrolling=false] - Whether to allow horizontal scrolling in the popup
4848 * @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
4950 * @property {'slow'|'fast'|'none'?} [animation='slow'] - Animation speed for the popup (opening, closing, ...)
5051 * @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`.
5152 * @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 {
173174 * @param {string} [inputValue=''] - The initial value of the input field
174175 * @param {PopupOptions} [options={}] - Additional options for the popup
175176 */
176177 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 } = {}) {
177178 Popup.util.popups.push(this);
178179
179180 // Make this popup uniquely identifiable
@@ -218,6 +219,7 @@ export class Popup {
218219 if (transparent) this.dlg.classList.add('transparent_dialogue_popup');
219220 if (allowHorizontalScrolling) this.dlg.classList.add('horizontal_scrolling_dialogue_popup');
220221 if (allowVerticalScrolling) this.dlg.classList.add('vertical_scrolling_dialogue_popup');
222+ if (leftAlign) this.dlg.classList.add('left_aligned_dialogue_popup');
221223 if (animation) this.dlg.classList.add('popup--animation-' + animation);
222224
223225 // If custom button captions are provided, we set them beforehand
public/scripts/templates/itemizationChat.html+1 -1
@@ -146,5 +146,5 @@
146146</div>
147147<hr>
148148<div id="rawPromptPopup" class="list-group">
149149 <div id="rawPromptWrapper" class="tokenItemizingSubclasstokenItemizingMaintext"></div>
150150</div>
public/style.css+4 -0
@@ -262,6 +262,10 @@ input[type='checkbox']:focus-visible {
262262 color: var(--SmartThemeEmColor);
263263}
264264
265+.tokenItemizingMaintext {
266+ font-size: calc(var(--mainFontSize) * 0.8);
267+}
268+
265269.tokenGraph {
266270 border-radius: 10px;
267271 border: 1px solid var(--SmartThemeBorderColor);