From a8a985adfffe9690fe023574c460cbaac1ede29e Mon Sep 17 00:00:00 2001 From: Yann Bizeul Date: Fri, 6 Sep 2024 10:56:52 +0200 Subject: [PATCH] Full implementation of messages templates --- .../MarkdownEditor/FullHeightTextArea.tsx | 28 ++++----- .../MarkdownEditor/MarkdownEditor.tsx | 22 ++++--- html/src/Components/ShareEditor.tsx | 63 +++++-------------- html/src/Components/TemplatesMenu.tsx | 49 +++++++++++++++ html/src/hupload.ts | 10 +-- hupload/handlers.go | 2 +- 6 files changed, 99 insertions(+), 75 deletions(-) create mode 100644 html/src/Components/TemplatesMenu.tsx diff --git a/html/src/Components/MarkdownEditor/FullHeightTextArea.tsx b/html/src/Components/MarkdownEditor/FullHeightTextArea.tsx index a4c68fd..b7427fb 100644 --- a/html/src/Components/MarkdownEditor/FullHeightTextArea.tsx +++ b/html/src/Components/MarkdownEditor/FullHeightTextArea.tsx @@ -1,26 +1,24 @@ -import { Textarea, TextareaProps } from "@mantine/core"; -import { ChangeEvent, useState } from "react"; +import { Textarea } from "@mantine/core"; import classes from './FullHeightTextArea.module.css'; +import { useUncontrolled } from "@mantine/hooks"; -// interface FullHeightTextAreaProps extends TextareaProps { -// value: string | number | readonly string[]; -// label: string; -// onChange: ChangeEventHandler; -// } -export function FullHeightTextArea(props: TextareaProps) { +interface FullHeightTextAreaProps { + value?: string; + onChange?: (value: string) => void; +} +export function FullHeightTextArea(props: FullHeightTextAreaProps) { const { value, onChange } = props; - const [_value, setValue] = useState(value); - function notifyChange(v: ChangeEvent) { - setValue(v.target.value) - onChange && onChange(v) - } + const [_value, handleChange] = useUncontrolled({ + value, + onChange, + }); return ( -