Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
aa7d2560
Commit
aa7d2560
authored
Jun 10, 2024
by
Timothy J. Baek
Browse files
refac
parent
0bae7ca6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
src/lib/components/common/CodeEditor.svelte
src/lib/components/common/CodeEditor.svelte
+9
-6
No files found.
src/lib/components/common/CodeEditor.svelte
View file @
aa7d2560
...
@@ -110,21 +110,24 @@
...
@@ -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',
h
andle
Save
);
document.addEventListener('keydown',
keydownH
andle
r
);
return () => {
return () => {
observer.disconnect();
observer.disconnect();
document.removeEventListener('keydown',
h
andle
Save
);
document.removeEventListener('keydown',
keydownH
andle
r
);
};
};
});
});
</script>
</script>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment