diff --git a/.vscode/settings.json b/.vscode/settings.json index e5718298..defcf50b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -50,6 +50,7 @@ "forceatlas", "Grammeme", "Grammemes", + "Keymap", "lezer", "moprho", "nooverlap", diff --git a/rsconcept/frontend/src/components/RSInput/RSInput.tsx b/rsconcept/frontend/src/components/RSInput/RSInput.tsx index 7d9cb850..da706072 100644 --- a/rsconcept/frontend/src/components/RSInput/RSInput.tsx +++ b/rsconcept/frontend/src/components/RSInput/RSInput.tsx @@ -6,7 +6,7 @@ import { createTheme } from '@uiw/codemirror-themes'; import CodeMirror, { BasicSetupOptions, ReactCodeMirrorProps, ReactCodeMirrorRef } from '@uiw/react-codemirror'; import clsx from 'clsx'; import { EditorView } from 'codemirror'; -import { RefObject, useCallback, useMemo, useRef } from 'react'; +import { forwardRef, useCallback, useMemo, useRef } from 'react'; import Label from '@/components/Common/Label'; import { useRSForm } from '@/context/RSFormContext'; @@ -53,25 +53,22 @@ extends Pick | undefined onChange?: (newValue: string) => void onAnalyze?: () => void } -function RSInput({ - id, label, innerref, onChange, onAnalyze, - disabled, noTooltip, - className, style, - ...restProps -}: RSInputProps) { +const RSInput = forwardRef( + ({ + id, label, onChange, onAnalyze, + disabled, noTooltip, + className, style, + ...restProps + }, ref) => { const { darkMode, colors } = useConceptTheme(); const { schema } = useRSForm(); const internalRef = useRef(null); - const thisRef = useMemo( - () => { - return innerref ?? internalRef; - }, [internalRef, innerref]); + const thisRef = useMemo(() => (!ref || typeof ref === 'function' ? internalRef : ref), [internalRef, ref]); const cursor = useMemo(() => !disabled ? 'cursor-text': 'cursor-default', [disabled]); const customTheme: Extension = useMemo( @@ -90,7 +87,7 @@ function RSInput({ { tag: tags.keyword, color: colors.fgBlue }, // keywords { tag: tags.literal, color: colors.fgBlue }, // literals { tag: tags.controlKeyword, fontWeight: '500'}, // R | I | D - { tag: tags.unit, fontSize: '0.75rem' }, // indicies + { tag: tags.unit, fontSize: '0.75rem' }, // indices { tag: tags.brace, color:colors.fgPurple, fontWeight: '700' }, // braces (curly brackets) ] }), [disabled, colors, darkMode]); @@ -150,6 +147,6 @@ function RSInput({ {...restProps} /> ); -} +}); export default RSInput; \ No newline at end of file diff --git a/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx b/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx index 91d486d7..4739ee76 100644 --- a/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx +++ b/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx @@ -7,7 +7,7 @@ import CodeMirror, { BasicSetupOptions, ReactCodeMirrorProps, ReactCodeMirrorRef import clsx from 'clsx'; import { EditorView } from 'codemirror'; import { AnimatePresence } from 'framer-motion'; -import { RefObject, useCallback, useMemo, useRef, useState } from 'react'; +import { forwardRef, useCallback, useMemo, useRef, useState } from 'react'; import Label from '@/components/Common/Label'; import { useRSForm } from '@/context/RSFormContext'; @@ -54,7 +54,6 @@ extends Pick { label?: string - innerref?: RefObject | undefined onChange?: (newValue: string) => void items?: IConstituenta[] disabled?: boolean @@ -64,12 +63,13 @@ extends Pick( + ({ + id, label, disabled, items, + initialValue, value, resolved, + onFocus, onBlur, onChange, + ...restProps + }, ref) => { const { darkMode, colors } = useConceptTheme(); const { schema } = useRSForm(); @@ -83,10 +83,7 @@ function RefsInput({ const [mainRefs, setMainRefs] = useState([]); const internalRef = useRef(null); - const thisRef = useMemo( - () => { - return innerref ?? internalRef; - }, [internalRef, innerref]); + const thisRef = useMemo(() => (!ref || typeof ref === 'function' ? internalRef : ref), [internalRef, ref]); const cursor = useMemo(() => !disabled ? 'cursor-text': 'cursor-default', [disabled]); const customTheme: Extension = useMemo( @@ -204,6 +201,6 @@ function RefsInput({ /> ); -} +}); export default RefsInput; \ No newline at end of file diff --git a/rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/EditorRSExpression.tsx b/rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/EditorRSExpression.tsx index 75348148..ffce1d6b 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/EditorRSExpression.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/EditorRSExpression.tsx @@ -173,7 +173,7 @@ function EditorRSExpression({ /> -

Ошибок: {errorCount} | Предупреждений: {warningsCount}

{data?.errors.map( diff --git a/rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/RSEditControls.tsx b/rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/RSEditControls.tsx index fe0f39c2..5cf454a8 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/RSEditControls.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/RSEditControls.tsx @@ -90,7 +90,7 @@ interface RSEditorControlsProps { function RSEditorControls({ isOpen, disabled, onEdit }: RSEditorControlsProps) { return (