import { forwardRef, useMemo, useRef, } from 'react'; import type { ReactCodeMirrorProps } from '@uiw/react-codemirror'; import { GlobalCodeMirrorEditorKey } from '../consts'; import { useCodeMirrorEditorIsolated } from '../stores'; import style from './CodeMirrorEditor.module.scss'; const CodeMirrorEditorContainer = forwardRef((props, ref) => { return (
); }); type Props = { editorKey: string | GlobalCodeMirrorEditorKey, onChange?: (value: string) => void, } export const CodeMirrorEditor = (props: Props): JSX.Element => { const { editorKey, onChange, } = props; const containerRef = useRef(null); const cmProps = useMemo(() => { return { onChange, }; }, [onChange]); useCodeMirrorEditorIsolated(editorKey, containerRef.current, cmProps); return ; };