You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
694 B
28 lines
694 B
import React, { useState } from "react";
|
|
import ReactMarkdown from "react-markdown";
|
|
import { noop } from "../../state";
|
|
|
|
import "./EditableNoteArea.css";
|
|
|
|
export default function EditableNoteArea({
|
|
content = null,
|
|
onSave = noop,
|
|
preview = false
|
|
}) {
|
|
const updateContent = ({ target: { value } }) => {
|
|
onSave(value);
|
|
};
|
|
|
|
return (
|
|
<section className="EditableNoteArea">
|
|
{!preview ? (
|
|
<textarea value={content} onChange={updateContent} />
|
|
) : (
|
|
<div className="markdownPreview">
|
|
<ReactMarkdown source={content} />
|
|
</div>
|
|
)}
|
|
</section>
|
|
);
|
|
}
|