diff --git a/public/scripts/extensions/quick-reply/html/qrEditor.html b/public/scripts/extensions/quick-reply/html/qrEditor.html
index 736b87f69..8ed195520 100644
--- a/public/scripts/extensions/quick-reply/html/qrEditor.html
+++ b/public/scripts/extensions/quick-reply/html/qrEditor.html
@@ -25,6 +25,10 @@
Tab size:
+
diff --git a/public/scripts/extensions/quick-reply/src/QuickReply.js b/public/scripts/extensions/quick-reply/src/QuickReply.js
index 609290d02..3e6ea982b 100644
--- a/public/scripts/extensions/quick-reply/src/QuickReply.js
+++ b/public/scripts/extensions/quick-reply/src/QuickReply.js
@@ -44,6 +44,11 @@ export class QuickReply {
/**@type {HTMLInputElement}*/ settingsDomLabel;
/**@type {HTMLTextAreaElement}*/ settingsDomMessage;
+ /**@type {HTMLElement}*/ editorExecuteBtn;
+ /**@type {HTMLElement}*/ editorExecuteErrors;
+ /**@type {HTMLInputElement}*/ editorExecuteHide;
+ /**@type {Promise}*/ editorExecutePromise;
+
get hasContext() {
return this.contextList && this.contextList.length > 0;
@@ -231,6 +236,12 @@ export class QuickReply {
localStorage.setItem('qr--tabSize', JSON.stringify(Number(tabSize.value)));
updateTabSize();
});
+ /**@type {HTMLInputElement}*/
+ const executeShortcut = dom.querySelector('#qr--modal-executeShortcut');
+ executeShortcut.checked = JSON.parse(localStorage.getItem('qr--executeShortcut') ?? 'true');
+ executeShortcut.addEventListener('click', () => {
+ localStorage.setItem('qr--executeShortcut', JSON.stringify(executeShortcut.checked));
+ });
/**@type {HTMLTextAreaElement}*/
const message = dom.querySelector('#qr--modal-message');
updateWrap();
@@ -268,6 +279,12 @@ export class QuickReply {
message.selectionStart = start - 1;
message.selectionEnd = end - count;
this.updateMessage(message.value);
+ } else if (evt.key == 'Enter' && evt.ctrlKey && !evt.shiftKey && !evt.altKey) {
+ evt.stopPropagation();
+ evt.preventDefault();
+ if (executeShortcut.checked) {
+ this.executeFromEditor();
+ }
}
});
@@ -396,27 +413,15 @@ export class QuickReply {
/**@type {HTMLElement}*/
const executeErrors = dom.querySelector('#qr--modal-executeErrors');
+ this.editorExecuteErrors = executeErrors;
/**@type {HTMLInputElement}*/
const executeHide = dom.querySelector('#qr--modal-executeHide');
- let executePromise;
+ this.editorExecuteHide = executeHide;
/**@type {HTMLElement}*/
const executeBtn = dom.querySelector('#qr--modal-execute');
+ this.editorExecuteBtn = executeBtn;
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.execute();
- await executePromise;
- } catch (ex) {
- executeErrors.textContent = ex.message;
- }
- executePromise = null;
- executeBtn.classList.remove('qr--busy');
- document.querySelector('#shadow_popup').classList.remove('qr--hide');
+ await this.executeFromEditor();
});
await popupResult;
@@ -425,6 +430,24 @@ export class QuickReply {
}
}
+ async executeFromEditor() {
+ if (this.editorExecutePromise) return;
+ this.editorExecuteBtn.classList.add('qr--busy');
+ this.editorExecuteErrors.innerHTML = '';
+ if (this.editorExecuteHide.checked) {
+ document.querySelector('#shadow_popup').classList.add('qr--hide');
+ }
+ try {
+ this.editorExecutePromise = this.execute();
+ await this.editorExecutePromise;
+ } catch (ex) {
+ this.editorExecuteErrors.textContent = ex.message;
+ }
+ this.editorExecutePromise = null;
+ this.editorExecuteBtn.classList.remove('qr--busy');
+ document.querySelector('#shadow_popup').classList.remove('qr--hide');
+ }
+