mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
add execute button to QR editor
This commit is contained in:
@ -63,5 +63,17 @@
|
|||||||
<span><i class="fa-solid fa-fw fa-message"></i> Execute on opening chat</span>
|
<span><i class="fa-solid fa-fw fa-message"></i> Execute on opening chat</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Testing</h3>
|
||||||
|
<div id="qr--modal-execute" class="menu_button" title="Execute the quick reply now">
|
||||||
|
<i class="fa-solid fa-play"></i>
|
||||||
|
Execute
|
||||||
|
</div>
|
||||||
|
<label class="checkbox_label">
|
||||||
|
<input type="checkbox" id="qr--modal-executeHide">
|
||||||
|
<span> Hide editor while executing</span>
|
||||||
|
</label>
|
||||||
|
<div id="qr--modal-executeErrors"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -345,6 +345,32 @@ export class QuickReply {
|
|||||||
this.updateContext();
|
this.updateContext();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**@type {HTMLElement}*/
|
||||||
|
const executeErrors = dom.querySelector('#qr--modal-executeErrors');
|
||||||
|
/**@type {HTMLInputElement}*/
|
||||||
|
const executeHide = dom.querySelector('#qr--modal-executeHide');
|
||||||
|
let executePromise;
|
||||||
|
/**@type {HTMLElement}*/
|
||||||
|
const executeBtn = dom.querySelector('#qr--modal-execute');
|
||||||
|
executeBtn.addEventListener('click', async()=>{
|
||||||
|
if (executePromise) return;
|
||||||
|
executeBtn.classList.add('qr--busy');
|
||||||
|
executeErrors.innerHTML = '';
|
||||||
|
if (executeHide.checked) {
|
||||||
|
document.querySelector('#shadow_popup').classList.add('qr--hide');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
executePromise = this.onExecute();
|
||||||
|
await executePromise;
|
||||||
|
} catch (ex) {
|
||||||
|
executeErrors.textContent = ex.message;
|
||||||
|
}
|
||||||
|
executePromise = null;
|
||||||
|
executeBtn.classList.remove('qr--busy');
|
||||||
|
document.querySelector('#shadow_popup').classList.remove('qr--hide');
|
||||||
|
});
|
||||||
|
|
||||||
await popupResult;
|
await popupResult;
|
||||||
} else {
|
} else {
|
||||||
warn('failed to fetch qrEditor template');
|
warn('failed to fetch qrEditor template');
|
||||||
|
@ -255,3 +255,15 @@
|
|||||||
#dialogue_popup:has(#qr--modalEditor) #dialogue_popup_text > #qr--modalEditor > #qr--main > .qr--modal-messageContainer > #qr--modal-message {
|
#dialogue_popup:has(#qr--modalEditor) #dialogue_popup_text > #qr--modalEditor > #qr--main > .qr--modal-messageContainer > #qr--modal-message {
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
}
|
}
|
||||||
|
#dialogue_popup:has(#qr--modalEditor) #dialogue_popup_text > #qr--modalEditor #qr--modal-execute {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 0.5em;
|
||||||
|
}
|
||||||
|
#dialogue_popup:has(#qr--modalEditor) #dialogue_popup_text > #qr--modalEditor #qr--modal-execute.qr--busy {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: wait;
|
||||||
|
}
|
||||||
|
#shadow_popup.qr--hide {
|
||||||
|
opacity: 0 !important;
|
||||||
|
}
|
||||||
|
@ -281,6 +281,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#qr--modal-execute {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 0.5em;
|
||||||
|
&.qr--busy {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: wait;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#shadow_popup.qr--hide {
|
||||||
|
opacity: 0 !important;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user