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
c5ed3452
Commit
c5ed3452
authored
Jun 10, 2024
by
Timothy J. Baek
Browse files
refac
parent
c2e6e447
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
15 deletions
+42
-15
src/lib/components/common/CodeEditor.svelte
src/lib/components/common/CodeEditor.svelte
+8
-4
src/lib/components/workspace/Tools.svelte
src/lib/components/workspace/Tools.svelte
+34
-11
No files found.
src/lib/components/common/CodeEditor.svelte
View file @
c5ed3452
...
...
@@ -26,7 +26,6 @@
export const formatPythonCodeHandler = async () => {
if (codeEditor) {
console.log('formatPythonCodeHandler');
const res = await formatPythonCode(value).catch((error) => {
toast.error(error);
return null;
...
...
@@ -111,12 +110,17 @@
// Add a keyboard shortcut to format the code when Ctrl/Cmd + S is pressed
// Override the default browser save functionality
const handleSave = (e) => {
const handleSave =
async
(e) => {
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
e.preventDefault();
formatPythonCodeHandler();
const res = await formatPythonCodeHandler().catch((error) => {
return null;
});
if (res) {
dispatch('save');
}
}
};
document.addEventListener('keydown', handleSave);
...
...
src/lib/components/workspace/Tools.svelte
View file @
c5ed3452
...
...
@@ -7,6 +7,8 @@
let loading = false;
let name = '';
let codeEditor;
const submitHandler = async () => {
...
...
@@ -22,10 +24,30 @@
<div class=" flex flex-col justify-between w-full overflow-y-auto h-full">
<div class="mx-auto w-full md:px-0 h-full">
<div class=" flex flex-col max-h-[100dvh] h-full">
<div class="mb-2.5 flex-1 overflow-auto h-0 rounded-lg">
<div class="">
<div class="flex justify-between items-center">
<div class=" text-lg font-semibold self-center">{$i18n.t('Tools')}</div>
</div>
</div>
<hr class=" dark:border-gray-850 my-2" />
<div class="flex flex-col flex-1 overflow-auto h-0 rounded-lg">
<div class="w-full mb-2">
<!-- Toolkit Name Input -->
<input
class="w-full px-3 py-2 text-sm font-medium bg-gray-100 dark:bg-gray-850 dark:text-gray-200 rounded-lg outline-none"
type="text"
placeholder="Toolkit Name (e.g. my_toolkit)"
bind:value={name}
/>
</div>
<div class="mb-2 flex-1 overflow-auto h-0 rounded-lg">
<CodeEditor bind:this={codeEditor} />
</div>
<div class="pb-3">
<div class="pb-3 flex justify-end">
<button
class="px-3 py-1.5 text-sm font-medium bg-emerald-600 hover:bg-emerald-700 text-gray-50 transition rounded-lg"
on:click={() => {
...
...
@@ -37,4 +59,5 @@
</div>
</div>
</div>
</div>
</div>
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