diff --git a/src/App.tsx b/src/App.tsx index f3602e2..24c5af4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -113,6 +113,7 @@ import { enabledDevModeAtom, fullScreenAtom, hasSettingsChangedAtom, + isDisabledEditorEnterAtom, isUsingImportExportSettingsAtom, oldPinnedAppsAtom, settingsLocalLastUpdatedAtom, @@ -404,6 +405,7 @@ function App() { const [fullScreen, setFullScreen] = useRecoilState(fullScreenAtom); const [isEnabledDevMode, setIsEnabledDevMode] = useRecoilState(enabledDevModeAtom); + const setIsDisabledEditorEnter = useSetRecoilState(isDisabledEditorEnterAtom) const { toggleFullScreen } = useAppFullScreen(setFullScreen); const generatorRef = useRef(null) @@ -526,6 +528,20 @@ function App() { } }, [extState]); + useEffect(()=> { + try { + const val = localStorage.getItem('settings-disable-editor-enter'); + if(val){ + const parsedVal = JSON.parse(val) + if(parsedVal === false || parsedVal === true){ + setIsDisabledEditorEnter(parsedVal) + } + } + } catch (error) { + + } + }, []) + useEffect(() => { isFocusedRef.current = isFocused; }, [isFocused]); diff --git a/src/atoms/global.ts b/src/atoms/global.ts index fb4f74e..2aab4ef 100644 --- a/src/atoms/global.ts +++ b/src/atoms/global.ts @@ -154,4 +154,9 @@ export const addressInfoKeySelector = selectorFamily({ const userInfo = get(addressInfoControllerAtom); return userInfo[key] || null; // Return the value for the key or null if not found }, +}); + +export const isDisabledEditorEnterAtom = atom({ + key: 'isDisabledEditorEnterAtom', + default: false, }); \ No newline at end of file diff --git a/src/components/Chat/TipTap.tsx b/src/components/Chat/TipTap.tsx index 234d66e..4493482 100644 --- a/src/components/Chat/TipTap.tsx +++ b/src/components/Chat/TipTap.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo, useRef, useState } from "react"; +import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { EditorProvider, useCurrentEditor, useEditor } from "@tiptap/react"; import StarterKit from "@tiptap/starter-kit"; import { Color } from "@tiptap/extension-color"; @@ -34,6 +34,9 @@ import ListItemButton from '@mui/material/ListItemButton'; import ListItemText from '@mui/material/ListItemText'; import { ReactRenderer } from '@tiptap/react' import MentionList from './MentionList.jsx' +import { useRecoilState } from "recoil"; +import { isDisabledEditorEnterAtom } from "../../atoms/global.js"; +import { Box, Checkbox, Typography } from "@mui/material"; function textMatcher(doc, from) { const textBeforeCursor = doc.textBetween(0, from, ' ', ' '); @@ -44,7 +47,7 @@ function textMatcher(doc, from) { const query = match[0]; return { start, query }; } -const MenuBar = ({ setEditorRef, isChat }) => { +const MenuBar = ({ setEditorRef, isChat, isDisabledEditorEnter, setIsDisabledEditorEnter }) => { const { editor } = useCurrentEditor(); const fileInputRef = useRef(null); @@ -120,7 +123,9 @@ const MenuBar = ({ setEditorRef, isChat }) => { return (