Add markdown preview and export options in App component
This commit is contained in:
54
src/App.tsx
54
src/App.tsx
@@ -887,7 +887,7 @@ export default function App() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="editor__textarea-wrap">
|
<div className="editor__textarea-wrap">
|
||||||
{showLineNumbers ? (
|
{showLineNumbersActive ? (
|
||||||
<div className="line-measure" ref={measureRef} aria-hidden="true">
|
<div className="line-measure" ref={measureRef} aria-hidden="true">
|
||||||
{lines.map((line, index) => (
|
{lines.map((line, index) => (
|
||||||
<div key={index} className="line-measure__line">
|
<div key={index} className="line-measure__line">
|
||||||
@@ -896,7 +896,7 @@ export default function App() {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{showLineNumbers ? (
|
{showLineNumbersActive ? (
|
||||||
<div className="line-numbers" ref={lineNumbersRef}>
|
<div className="line-numbers" ref={lineNumbersRef}>
|
||||||
{lineNumbers.map((line, index) => (
|
{lineNumbers.map((line, index) => (
|
||||||
<div
|
<div
|
||||||
@@ -909,22 +909,48 @@ export default function App() {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<textarea
|
{markdownPreview ? (
|
||||||
ref={textareaRef}
|
<div
|
||||||
className="editor__textarea"
|
className="markdown-preview md-root"
|
||||||
value={body}
|
dangerouslySetInnerHTML={{ __html: markdownToHTML(body) }}
|
||||||
onChange={(event) => setBody(event.target.value)}
|
/>
|
||||||
onScroll={handleTextareaScroll}
|
) : (
|
||||||
placeholder="Write your text here…"
|
<textarea
|
||||||
readOnly={isViewingHistory}
|
ref={textareaRef}
|
||||||
/>
|
className="editor__textarea"
|
||||||
|
value={body}
|
||||||
|
onChange={(event) => setBody(event.target.value)}
|
||||||
|
onScroll={handleTextareaScroll}
|
||||||
|
placeholder="Write your text here…"
|
||||||
|
readOnly={isViewingHistory}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="editor__footer">
|
<div className="editor__footer">
|
||||||
{hasText ? (
|
{hasText ? (
|
||||||
<button className="button" onClick={handleExportText}>
|
<>
|
||||||
Export Text
|
<button className="button" onClick={handleExportText}>
|
||||||
</button>
|
Export Text
|
||||||
|
</button>
|
||||||
|
{markdownPreview ? (
|
||||||
|
<>
|
||||||
|
<button className="button" type="button">
|
||||||
|
Export PDF
|
||||||
|
</button>
|
||||||
|
<button className="button" type="button">
|
||||||
|
Print
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
<button
|
||||||
|
className="button"
|
||||||
|
type="button"
|
||||||
|
onClick={() => setMarkdownPreview((value) => !value)}
|
||||||
|
>
|
||||||
|
{markdownPreview ? "Edit" : "Preview Markdown"}
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{hasDraft && !isViewingHistory ? (
|
{hasDraft && !isViewingHistory ? (
|
||||||
<button
|
<button
|
||||||
|
|||||||
Reference in New Issue
Block a user