mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-15 13:55:19 +00:00
refac
This commit is contained in:
parent
0bae7ca615
commit
aa7d25600f
1 changed files with 9 additions and 6 deletions
|
|
@ -110,21 +110,24 @@
|
||||||
attributeFilter: ['class']
|
attributeFilter: ['class']
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add a keyboard shortcut to format the code when Ctrl/Cmd + S is pressed
|
const keydownHandler = async (e) => {
|
||||||
// Override the default browser save functionality
|
|
||||||
|
|
||||||
const handleSave = async (e) => {
|
|
||||||
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
|
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
dispatch('save');
|
dispatch('save');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Format code when Ctrl + Shift + F is pressed
|
||||||
|
if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key === 'f') {
|
||||||
|
e.preventDefault();
|
||||||
|
await formatPythonCodeHandler();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('keydown', handleSave);
|
document.addEventListener('keydown', keydownHandler);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
document.removeEventListener('keydown', handleSave);
|
document.removeEventListener('keydown', keydownHandler);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue