From 6697d56370dc2f7657fef41e53bb042cda068133 Mon Sep 17 00:00:00 2001 From: Stan Ke <156306548@qq.com> Date: Mon, 28 Oct 2024 23:54:31 +0800 Subject: [PATCH] update document --- app/components/DocumentPreview.tsx | 37 ++++++++++++++++++++++++++++++ app/page.tsx | 4 ---- 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 app/components/DocumentPreview.tsx diff --git a/app/components/DocumentPreview.tsx b/app/components/DocumentPreview.tsx new file mode 100644 index 0000000..310f07d --- /dev/null +++ b/app/components/DocumentPreview.tsx @@ -0,0 +1,37 @@ +import React from 'react'; +import { Button } from "@/components/ui/button" +import { Textarea } from './ui/textarea'; + + +type Props = { + content: string; +}; +const DocumentPreview: React.FC = ({ content }) => { + const handleCopyContent = () => { + navigator.clipboard.writeText(content); + }; + + const handleDownload = () => { + const blob = new Blob([content], { type: 'text/plain' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = 'generated_document.txt'; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + }; + + return ( +
+