1
0
Fork 0
mirror of https://github.com/kou029w/quot.git synced 2025-01-19 16:38:06 +00:00
quot/app/src/components/editor.tsx
2022-08-24 12:49:02 +09:00

21 lines
564 B
TypeScript

import type Pages from "../protocol/pages";
import "./editor.css";
export default (props: {
id: number;
onUpdatePage: (content: Pages.RequestContentPage) => void;
}) => {
return (
<textarea
id={String(props.id)}
class="editor"
autofocus
onInput={(e) => {
const text = e.currentTarget.value;
const lines = text.split("\n");
props.onUpdatePage({ id: props.id, title: lines[0] ?? "", text });
e.currentTarget.setAttribute("rows", String(Math.max(2, lines.length)));
}}
></textarea>
);
};