'use client' import { useEditor, EditorContent } from '@tiptap/react' import StarterKit from '@tiptap/starter-kit' import { useState } from 'react' import { cn } from '@/lib/utils' import { Copy, Eye, Pencil } from 'lucide-react' export default function XiaohongshuEditor() { const [preview, setPreview] = useState(false) const editor = useEditor({ extensions: [StarterKit], content: '

开始编辑小红书笔记...

', editorProps: { attributes: { class: 'prose prose-sm sm:prose lg:prose-lg xl:prose-2xl mx-auto focus:outline-none min-h-[500px] max-w-none', }, }, }) const getPreviewContent = () => { if (!editor) return '' return editor.getHTML() .replace(/

/g, '

') .replace(/

/g, '

') } const copyContent = () => { const content = getPreviewContent() navigator.clipboard.writeText(content) .then(() => alert('内容已复制到剪贴板')) .catch(err => console.error('复制失败:', err)) } return (

{preview && ( )}
{preview ? (
) : (
)}
) }