mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-26 01:30:20 +01:00
Add chat keyboard shortcuts
This commit is contained in:
parent
df592adff5
commit
fc11d1eff0
@ -483,8 +483,13 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
background: transparent !important;
|
background: transparent !important;
|
||||||
border-radius: 0px !important;
|
border-radius: 0px !important;
|
||||||
|
justify-content: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hover-menu button:hover {
|
.hover-menu button:hover {
|
||||||
background: var(--button-secondary-background-fill-hover) !important;
|
background: var(--button-secondary-background-fill-hover) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.transparent-substring {
|
||||||
|
opacity: 0.333;
|
||||||
|
}
|
||||||
|
49
js/main.js
49
js/main.js
@ -44,7 +44,7 @@ document.addEventListener("keydown", function(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show chat controls on Ctrl+S pressed
|
// Show chat controls on Ctrl + S
|
||||||
else if (event.ctrlKey && event.key == "s") {
|
else if (event.ctrlKey && event.key == "s") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
@ -57,6 +57,42 @@ document.addEventListener("keydown", function(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regenerate on Ctrl + Enter
|
||||||
|
else if (event.ctrlKey && event.key === 'Enter') {
|
||||||
|
event.preventDefault();
|
||||||
|
document.getElementById('Regenerate').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Continue on Ctrl + Right
|
||||||
|
else if (event.ctrlKey && event.key === 'ArrowRight') {
|
||||||
|
event.preventDefault();
|
||||||
|
document.getElementById('Continue').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove last on Ctrl + Up
|
||||||
|
else if (event.ctrlKey && event.key === 'ArrowUp') {
|
||||||
|
event.preventDefault();
|
||||||
|
document.getElementById('Remove-last').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy last on Ctrl + Shift + K
|
||||||
|
else if (event.ctrlKey && event.shiftKey && event.key === 'K') {
|
||||||
|
event.preventDefault();
|
||||||
|
document.getElementById('Copy-last').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace last on Ctrl + Shift + L
|
||||||
|
else if (event.ctrlKey && event.shiftKey && event.key === 'L') {
|
||||||
|
event.preventDefault();
|
||||||
|
document.getElementById('Replace-last').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Impersonate last on Ctrl + Shift + M
|
||||||
|
else if (event.ctrlKey && event.shiftKey && event.key === 'M') {
|
||||||
|
event.preventDefault();
|
||||||
|
document.getElementById('Impersonate').click();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
@ -232,6 +268,17 @@ for (let i = 14; i >= 2; i--) {
|
|||||||
hideMenu();
|
hideMenu();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const buttonText = thisButton.textContent;
|
||||||
|
const matches = buttonText.match(/(\(.*?\))/);
|
||||||
|
|
||||||
|
if (matches && matches.length > 1) {
|
||||||
|
// Apply the transparent-substring class to the matched substring
|
||||||
|
const substring = matches[1];
|
||||||
|
const newText = buttonText.replace(substring, ` <span class="transparent-substring">${substring}</span>`);
|
||||||
|
thisButton.innerHTML = newText;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMouseOverButtonOrMenu() {
|
function isMouseOverButtonOrMenu() {
|
||||||
|
@ -38,12 +38,12 @@ def create_ui():
|
|||||||
shared.gradio['Generate'] = gr.Button('▶', elem_id='Generate', variant='primary')
|
shared.gradio['Generate'] = gr.Button('▶', elem_id='Generate', variant='primary')
|
||||||
|
|
||||||
# Hover menu buttons
|
# Hover menu buttons
|
||||||
shared.gradio['Regenerate'] = gr.Button('Regenerate')
|
shared.gradio['Regenerate'] = gr.Button('Regenerate (Ctrl + Enter)', elem_id='Regenerate')
|
||||||
shared.gradio['Continue'] = gr.Button('Continue')
|
shared.gradio['Continue'] = gr.Button('Continue (Ctrl + Right)', elem_id='Continue')
|
||||||
shared.gradio['Remove last'] = gr.Button('Remove last reply')
|
shared.gradio['Remove last'] = gr.Button('Remove last reply (Ctrl + Up)', elem_id='Remove-last')
|
||||||
shared.gradio['Replace last reply'] = gr.Button('Replace last reply')
|
shared.gradio['Replace last reply'] = gr.Button('Replace last reply (Ctrl + Shift + L)', elem_id='Replace-last')
|
||||||
shared.gradio['Copy last reply'] = gr.Button('Copy last reply')
|
shared.gradio['Copy last reply'] = gr.Button('Copy last reply (Ctrl + Shift + K)', elem_id='Copy-last')
|
||||||
shared.gradio['Impersonate'] = gr.Button('Impersonate')
|
shared.gradio['Impersonate'] = gr.Button('Impersonate (Ctrl + Shift + M)', elem_id='Impersonate')
|
||||||
shared.gradio['Send dummy message'] = gr.Button('Send dummy message')
|
shared.gradio['Send dummy message'] = gr.Button('Send dummy message')
|
||||||
shared.gradio['Send dummy reply'] = gr.Button('Send dummy reply')
|
shared.gradio['Send dummy reply'] = gr.Button('Send dummy reply')
|
||||||
shared.gradio['Clear history'] = gr.Button('Clear history')
|
shared.gradio['Clear history'] = gr.Button('Clear history')
|
||||||
|
Loading…
Reference in New Issue
Block a user