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

22 lines
564 B
TypeScript
Raw Normal View History

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