made simplier editor, added color coding

This commit is contained in:
Fedor Katurov 2023-04-25 20:01:46 +06:00
parent 601eda17de
commit c1533e9cb9
15 changed files with 287 additions and 43 deletions

View file

@ -0,0 +1,41 @@
import { ChangeEvent, FC, useCallback, useMemo } from "react";
import styles from "./styles.module.scss";
import { useTheme } from "~/modules/theme/context/ThemeContext";
interface ReactMarkdownEditorProps {
value: string;
onChange: (val: string) => void;
}
const ReactMarkdownEditor: FC<ReactMarkdownEditorProps> = ({
value,
onChange,
}) => {
const changeHandler = useCallback(
(event: ChangeEvent<HTMLTextAreaElement>) => {
onChange(event.target.value);
},
[onChange]
);
const { paddingHorizontal, paddingVertical } = useTheme();
const style = useMemo(
() => ({
padding: `${paddingVertical}px ${paddingHorizontal}px`,
}),
[paddingHorizontal, paddingVertical]
);
return (
<textarea
onChange={changeHandler}
className={styles.textarea}
style={style}
>
{value}
</textarea>
);
};
export { ReactMarkdownEditor };