mirror of
https://github.com/open-webui/open-webui.git
synced 2026-02-24 04:00:31 +01:00
feat: dictation toggle
This commit is contained in:
@@ -824,6 +824,19 @@
|
||||
shiftKey = true;
|
||||
}
|
||||
|
||||
// Cmd/Ctrl+Shift+L to toggle dictation
|
||||
if (e.key.toLowerCase() === 'l' && (e.metaKey || e.ctrlKey) && e.shiftKey) {
|
||||
e.preventDefault();
|
||||
if (recording) {
|
||||
// Confirm and stop recording
|
||||
document.getElementById('confirm-recording-button')?.click();
|
||||
} else {
|
||||
// Start recording (same logic as voice-input-button click)
|
||||
document.getElementById('voice-input-button')?.click();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.key === 'Escape') {
|
||||
console.log('Escape');
|
||||
dragged = false;
|
||||
|
||||
@@ -368,7 +368,17 @@
|
||||
let maxVisibleItems = 300;
|
||||
$: maxVisibleItems = Math.floor(containerWidth / 5); // 2px width + 0.5px gap
|
||||
|
||||
const handleKeyDown = (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault();
|
||||
stopRecording();
|
||||
onCancel();
|
||||
}
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
|
||||
// listen to width changes
|
||||
resizeObserver = new ResizeObserver(() => {
|
||||
VISUALIZER_BUFFER_LENGTH = Math.floor(window.innerWidth / 4);
|
||||
@@ -385,6 +395,7 @@
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
window.removeEventListener('keydown', handleKeyDown);
|
||||
// remove resize observer
|
||||
resizeObserver.disconnect();
|
||||
});
|
||||
@@ -547,6 +558,7 @@
|
||||
</div>
|
||||
{:else}
|
||||
<button
|
||||
id="confirm-recording-button"
|
||||
type="button"
|
||||
class="p-1.5 bg-indigo-500 text-white dark:bg-indigo-500 dark:text-blue-950 rounded-full"
|
||||
on:click={async () => {
|
||||
|
||||
@@ -17,6 +17,7 @@ export enum Shortcut {
|
||||
NEW_TEMPORARY_CHAT = 'newTemporaryChat',
|
||||
DELETE_CHAT = 'deleteChat',
|
||||
OPEN_MODEL_SELECTOR = 'openModelSelector',
|
||||
TOGGLE_DICTATION = 'toggleDictation',
|
||||
|
||||
//Global
|
||||
SEARCH = 'search',
|
||||
@@ -64,6 +65,11 @@ export const shortcuts: ShortcutRegistry = {
|
||||
keys: ['mod', 'shift', 'M'],
|
||||
category: 'Chat'
|
||||
},
|
||||
[Shortcut.TOGGLE_DICTATION]: {
|
||||
name: 'Toggle Dictation',
|
||||
keys: ['mod', 'shift', 'L'],
|
||||
category: 'Chat'
|
||||
},
|
||||
|
||||
//Global
|
||||
[Shortcut.SEARCH]: {
|
||||
|
||||
Reference in New Issue
Block a user