From d228a6528686052061342e6284406a8889bb5d56 Mon Sep 17 00:00:00 2001 From: tianyaxiang Date: Sat, 1 Feb 2025 16:57:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=A7=BB=E5=8A=A8=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/editor/WechatEditor.tsx | 39 ++++++++++++++++++++------ 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/components/editor/WechatEditor.tsx b/src/components/editor/WechatEditor.tsx index 96b5be0..71a9dba 100644 --- a/src/components/editor/WechatEditor.tsx +++ b/src/components/editor/WechatEditor.tsx @@ -15,7 +15,7 @@ import { MarkdownToolbar } from './components/MarkdownToolbar' import { type PreviewSize } from './constants' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { WechatStylePicker } from '@/components/template/WechatStylePicker' -import { Copy, Clock, Type } from 'lucide-react' +import { Copy, Clock, Type, Trash2 } from 'lucide-react' // 计算阅读时间(假设每分钟阅读300字) const calculateReadingTime = (text: string): string => { @@ -395,6 +395,19 @@ export default function WechatEditor() { const isScrolling = useRef(false) + // 清除编辑器内容 + const handleClear = useCallback(() => { + if (window.confirm('确定要清除所有内容吗?')) { + setValue('') + handleEditorChange('') + toast({ + title: "已清除", + description: "编辑器内容已清除", + duration: 2000 + }) + } + }, [handleEditorChange, toast]) + return (
@@ -426,13 +439,23 @@ export default function WechatEditor() { onSelect={handleTemplateSelect} />
- +
+ + +