diff --git a/client/app/(posts)/components/preview/index.tsx b/client/app/(posts)/components/preview/index.tsx index d9a30610..5fe9b75d 100644 --- a/client/app/(posts)/components/preview/index.tsx +++ b/client/app/(posts)/components/preview/index.tsx @@ -14,10 +14,10 @@ type Props = { const MarkdownPreview = ({ height = 500, fileId, - content: initial = "", + content = "", title }: Props) => { - const [content, setPreview] = useState(initial) + const [preview, setPreview] = useState(content) const [isLoading, setIsLoading] = useState(true) useEffect(() => { async function fetchPost() { @@ -28,7 +28,7 @@ const MarkdownPreview = ({ ? undefined : JSON.stringify({ title: title || "", - content: initial + content: content }) const resp = await fetch(path, { @@ -47,14 +47,14 @@ const MarkdownPreview = ({ setIsLoading(false) } fetchPost() - }, [initial, fileId, title]) + }, [content, fileId, title]) return ( <> {isLoading ? ( <> ) : ( - + )} ) @@ -63,16 +63,17 @@ const MarkdownPreview = ({ export default memo(MarkdownPreview) export const StaticPreview = ({ - content, + preview, height = 500 }: { - content: string + preview: string height: string | number }) => { + console.log("content", preview) return (
) => void + onPaste?: (e: any) => void + title?: string + content?: string + preview?: string +} + +export default function DocumentTabs({ + isEditing, + defaultTab, + handleOnContentChange, + onPaste, + title, + content, + preview, + ...props +}: Props) { + const codeEditorRef = useRef(null) + + const handleTabChange = (newTab: string) => { + if (newTab === "preview") { + codeEditorRef.current?.focus() + } + } + + return ( + + + + {isEditing ? "Edit" : "Raw"} + + + {isEditing ? "Preview" : "Rendered"} + + + + +
+ + */} -
- - */} -
-