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>
|
|
|
|
);
|
|
|
|
};
|