mirror of
https://github.com/open-webui/open-webui
synced 2024-11-17 22:12:51 +00:00
refac
This commit is contained in:
parent
c2e6e44714
commit
c5ed3452d2
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
export const formatPythonCodeHandler = async () => {
|
export const formatPythonCodeHandler = async () => {
|
||||||
if (codeEditor) {
|
if (codeEditor) {
|
||||||
console.log('formatPythonCodeHandler');
|
|
||||||
const res = await formatPythonCode(value).catch((error) => {
|
const res = await formatPythonCode(value).catch((error) => {
|
||||||
toast.error(error);
|
toast.error(error);
|
||||||
return null;
|
return null;
|
||||||
@ -111,11 +110,16 @@
|
|||||||
// Add a keyboard shortcut to format the code when Ctrl/Cmd + S is pressed
|
// Add a keyboard shortcut to format the code when Ctrl/Cmd + S is pressed
|
||||||
// Override the default browser save functionality
|
// Override the default browser save functionality
|
||||||
|
|
||||||
const handleSave = (e) => {
|
const handleSave = async (e) => {
|
||||||
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
|
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
formatPythonCodeHandler();
|
const res = await formatPythonCodeHandler().catch((error) => {
|
||||||
dispatch('save');
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
dispatch('save');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
let loading = false;
|
let loading = false;
|
||||||
|
|
||||||
|
let name = '';
|
||||||
|
|
||||||
let codeEditor;
|
let codeEditor;
|
||||||
|
|
||||||
const submitHandler = async () => {
|
const submitHandler = async () => {
|
||||||
@ -22,18 +24,39 @@
|
|||||||
<div class=" flex flex-col justify-between w-full overflow-y-auto h-full">
|
<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="mx-auto w-full md:px-0 h-full">
|
||||||
<div class=" flex flex-col max-h-[100dvh] 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="">
|
||||||
<CodeEditor bind:this={codeEditor} />
|
<div class="flex justify-between items-center">
|
||||||
|
<div class=" text-lg font-semibold self-center">{$i18n.t('Tools')}</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="pb-3">
|
|
||||||
<button
|
<hr class=" dark:border-gray-850 my-2" />
|
||||||
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={() => {
|
<div class="flex flex-col flex-1 overflow-auto h-0 rounded-lg">
|
||||||
submitHandler();
|
<div class="w-full mb-2">
|
||||||
}}
|
<!-- Toolkit Name Input -->
|
||||||
>
|
<input
|
||||||
{$i18n.t('Save')}
|
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"
|
||||||
</button>
|
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 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={() => {
|
||||||
|
submitHandler();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{$i18n.t('Save')}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user