mirror of
https://github.com/NovaOSS/nova-betterchat.git
synced 2024-11-25 21:23:58 +01:00
parent
4e0b31cb1b
commit
78bf777365
|
@ -35,5 +35,6 @@
|
||||||
},
|
},
|
||||||
"newFolder": "Ny mappe",
|
"newFolder": "Ny mappe",
|
||||||
"cloneChat": "Clone Chat",
|
"cloneChat": "Clone Chat",
|
||||||
"cloned": "Cloned"
|
"cloned": "Cloned",
|
||||||
|
"enterToSubmit": "Enter to submit"
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,6 @@
|
||||||
},
|
},
|
||||||
"newFolder": "New Folder",
|
"newFolder": "New Folder",
|
||||||
"cloneChat": "Clone Chat",
|
"cloneChat": "Clone Chat",
|
||||||
"cloned": "Cloned"
|
"cloned": "Cloned",
|
||||||
|
"enterToSubmit": "Enter to submit"
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,6 @@
|
||||||
},
|
},
|
||||||
"newFolder": "Nueva Carpeta",
|
"newFolder": "Nueva Carpeta",
|
||||||
"cloneChat": "Clone Chat",
|
"cloneChat": "Clone Chat",
|
||||||
"cloned": "Cloned"
|
"cloned": "Cloned",
|
||||||
|
"enterToSubmit": "Enter to submit"
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,6 @@
|
||||||
},
|
},
|
||||||
"newFolder": "Nouveau Dossier",
|
"newFolder": "Nouveau Dossier",
|
||||||
"cloneChat": "Clone Chat",
|
"cloneChat": "Clone Chat",
|
||||||
"cloned": "Cloned"
|
"cloned": "Cloned",
|
||||||
|
"enterToSubmit": "Enter to submit"
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,6 @@
|
||||||
},
|
},
|
||||||
"newFolder": "新しいフォルダー",
|
"newFolder": "新しいフォルダー",
|
||||||
"cloneChat": "Clone Chat",
|
"cloneChat": "Clone Chat",
|
||||||
"cloned": "Cloned"
|
"cloned": "Cloned",
|
||||||
|
"enterToSubmit": "Enter to submit"
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,6 @@
|
||||||
},
|
},
|
||||||
"newFolder": "Folder Baru",
|
"newFolder": "Folder Baru",
|
||||||
"cloneChat": "Clone Chat",
|
"cloneChat": "Clone Chat",
|
||||||
"cloned": "Cloned"
|
"cloned": "Cloned",
|
||||||
|
"enterToSubmit": "Enter to submit"
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,6 @@
|
||||||
},
|
},
|
||||||
"newFolder": "Ny mappe",
|
"newFolder": "Ny mappe",
|
||||||
"cloneChat": "Clone Chat",
|
"cloneChat": "Clone Chat",
|
||||||
"cloned": "Cloned"
|
"cloned": "Cloned",
|
||||||
|
"enterToSubmit": "Enter to submit"
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,6 @@
|
||||||
},
|
},
|
||||||
"newFolder": "Ny mapp",
|
"newFolder": "Ny mapp",
|
||||||
"cloneChat": "Clone Chat",
|
"cloneChat": "Clone Chat",
|
||||||
"cloned": "Cloned"
|
"cloned": "Cloned",
|
||||||
|
"enterToSubmit": "Enter to submit"
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,6 @@
|
||||||
},
|
},
|
||||||
"newFolder": "新文件夹",
|
"newFolder": "新文件夹",
|
||||||
"cloneChat": "Clone Chat",
|
"cloneChat": "Clone Chat",
|
||||||
"cloned": "Cloned"
|
"cloned": "Cloned",
|
||||||
|
"enterToSubmit": "Enter to submit"
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,6 @@
|
||||||
},
|
},
|
||||||
"newFolder": "新資料夾",
|
"newFolder": "新資料夾",
|
||||||
"cloneChat": "Clone Chat",
|
"cloneChat": "Clone Chat",
|
||||||
"cloned": "Cloned"
|
"cloned": "Cloned",
|
||||||
|
"enterToSubmit": "Enter to submit"
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,6 @@
|
||||||
},
|
},
|
||||||
"newFolder": "新資料夾",
|
"newFolder": "新資料夾",
|
||||||
"cloneChat": "Clone Chat",
|
"cloneChat": "Clone Chat",
|
||||||
"cloned": "Cloned"
|
"cloned": "Cloned",
|
||||||
|
"enterToSubmit": "Enter to submit"
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,12 +342,20 @@ const EditView = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||||
if ((e.ctrlKey || e.shiftKey) && e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
e.preventDefault();
|
const enterToSubmit = useStore.getState().enterToSubmit;
|
||||||
if (sticky) {
|
if (sticky) {
|
||||||
|
if (
|
||||||
|
(enterToSubmit && !e.shiftKey) ||
|
||||||
|
(!enterToSubmit && (e.ctrlKey || e.shiftKey))
|
||||||
|
) {
|
||||||
|
e.preventDefault();
|
||||||
handleSaveAndSubmit();
|
handleSaveAndSubmit();
|
||||||
resetTextAreaHeight();
|
resetTextAreaHeight();
|
||||||
} else handleSave();
|
}
|
||||||
|
} else if (e.ctrlKey || e.shiftKey) {
|
||||||
|
handleSave();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
28
src/components/SettingsMenu/EnterToSubmitToggle.tsx
Normal file
28
src/components/SettingsMenu/EnterToSubmitToggle.tsx
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import useStore from '@store/store';
|
||||||
|
import Toggle from '@components/Toggle';
|
||||||
|
|
||||||
|
const EnterToSubmitToggle = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const setEnterToSubmit = useStore((state) => state.setEnterToSubmit);
|
||||||
|
|
||||||
|
const [isChecked, setIsChecked] = useState<boolean>(
|
||||||
|
useStore.getState().enterToSubmit
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setEnterToSubmit(isChecked);
|
||||||
|
}, [isChecked]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Toggle
|
||||||
|
label={t('enterToSubmit') as string}
|
||||||
|
isChecked={isChecked}
|
||||||
|
setIsChecked={setIsChecked}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EnterToSubmitToggle;
|
|
@ -9,6 +9,7 @@ import LanguageSelector from '@components/LanguageSelector';
|
||||||
import AutoTitleToggle from './AutoTitleToggle';
|
import AutoTitleToggle from './AutoTitleToggle';
|
||||||
import PromptLibraryMenu from '@components/PromptLibraryMenu';
|
import PromptLibraryMenu from '@components/PromptLibraryMenu';
|
||||||
import ChatConfigMenu from '@components/ChatConfigMenu';
|
import ChatConfigMenu from '@components/ChatConfigMenu';
|
||||||
|
import EnterToSubmitToggle from './EnterToSubmitToggle';
|
||||||
|
|
||||||
const SettingsMenu = () => {
|
const SettingsMenu = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -38,7 +39,10 @@ const SettingsMenu = () => {
|
||||||
<div className='p-6 border-b border-gray-200 dark:border-gray-600 flex flex-col items-center gap-4'>
|
<div className='p-6 border-b border-gray-200 dark:border-gray-600 flex flex-col items-center gap-4'>
|
||||||
<LanguageSelector />
|
<LanguageSelector />
|
||||||
<ThemeSwitcher />
|
<ThemeSwitcher />
|
||||||
|
<div className='flex flex-col gap-3'>
|
||||||
<AutoTitleToggle />
|
<AutoTitleToggle />
|
||||||
|
<EnterToSubmitToggle />
|
||||||
|
</div>
|
||||||
<PromptLibraryMenu />
|
<PromptLibraryMenu />
|
||||||
<ChatConfigMenu />
|
<ChatConfigMenu />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,6 +11,7 @@ export interface ConfigSlice {
|
||||||
defaultChatConfig: ConfigInterface;
|
defaultChatConfig: ConfigInterface;
|
||||||
defaultSystemMessage: string;
|
defaultSystemMessage: string;
|
||||||
hideSideMenu: boolean;
|
hideSideMenu: boolean;
|
||||||
|
enterToSubmit: boolean;
|
||||||
setOpenConfig: (openConfig: boolean) => void;
|
setOpenConfig: (openConfig: boolean) => void;
|
||||||
setTheme: (theme: Theme) => void;
|
setTheme: (theme: Theme) => void;
|
||||||
setAutoTitle: (autoTitle: boolean) => void;
|
setAutoTitle: (autoTitle: boolean) => void;
|
||||||
|
@ -18,6 +19,7 @@ export interface ConfigSlice {
|
||||||
setDefaultSystemMessage: (defaultSystemMessage: string) => void;
|
setDefaultSystemMessage: (defaultSystemMessage: string) => void;
|
||||||
setHideMenuOptions: (hideMenuOptions: boolean) => void;
|
setHideMenuOptions: (hideMenuOptions: boolean) => void;
|
||||||
setHideSideMenu: (hideSideMenu: boolean) => void;
|
setHideSideMenu: (hideSideMenu: boolean) => void;
|
||||||
|
setEnterToSubmit: (enterToSubmit: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createConfigSlice: StoreSlice<ConfigSlice> = (set, get) => ({
|
export const createConfigSlice: StoreSlice<ConfigSlice> = (set, get) => ({
|
||||||
|
@ -26,6 +28,7 @@ export const createConfigSlice: StoreSlice<ConfigSlice> = (set, get) => ({
|
||||||
hideMenuOptions: false,
|
hideMenuOptions: false,
|
||||||
hideSideMenu: false,
|
hideSideMenu: false,
|
||||||
autoTitle: false,
|
autoTitle: false,
|
||||||
|
enterToSubmit: true,
|
||||||
defaultChatConfig: _defaultChatConfig,
|
defaultChatConfig: _defaultChatConfig,
|
||||||
defaultSystemMessage: _defaultSystemMessage,
|
defaultSystemMessage: _defaultSystemMessage,
|
||||||
setOpenConfig: (openConfig: boolean) => {
|
setOpenConfig: (openConfig: boolean) => {
|
||||||
|
@ -70,4 +73,10 @@ export const createConfigSlice: StoreSlice<ConfigSlice> = (set, get) => ({
|
||||||
hideSideMenu: hideSideMenu,
|
hideSideMenu: hideSideMenu,
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
setEnterToSubmit: (enterToSubmit: boolean) => {
|
||||||
|
set((prev: ConfigSlice) => ({
|
||||||
|
...prev,
|
||||||
|
enterToSubmit: enterToSubmit,
|
||||||
|
}));
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -61,6 +61,7 @@ const useStore = create<StoreState>()(
|
||||||
hideSideMenu: state.hideSideMenu,
|
hideSideMenu: state.hideSideMenu,
|
||||||
foldersName: state.foldersName,
|
foldersName: state.foldersName,
|
||||||
foldersExpanded: state.foldersExpanded,
|
foldersExpanded: state.foldersExpanded,
|
||||||
|
enterToSubmit: state.enterToSubmit,
|
||||||
}),
|
}),
|
||||||
version: 7,
|
version: 7,
|
||||||
migrate: (persistedState, version) => {
|
migrate: (persistedState, version) => {
|
||||||
|
|
Loading…
Reference in a new issue