mirror of
https://github.com/muerwre/markdown-home-tab.git
synced 2025-05-04 21:36:40 +07:00
made simplier editor, added color coding
This commit is contained in:
parent
601eda17de
commit
c1533e9cb9
15 changed files with 287 additions and 43 deletions
41
src/modules/editor/components/ReactMarkdownEditor/index.tsx
Normal file
41
src/modules/editor/components/ReactMarkdownEditor/index.tsx
Normal 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 };
|
Loading…
Add table
Add a link
Reference in a new issue