From f8538c4cf78c674d507e672002cddc3376c17108 Mon Sep 17 00:00:00 2001 From: dwindown Date: Thu, 13 Nov 2025 05:33:28 +0700 Subject: [PATCH] feat: Add card insert buttons toolbar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## ✨ New Feature: Card Insert Buttons! ### What's Added: **Card Insert Toolbar** above the rich text editor with 6 quick-insert buttons: 1. **Basic Card** - Plain card with default content 2. **Success Card** - Green checkmark, success message 3. **Info Card** - Blue info icon, informational content 4. **Warning Card** - Orange alert icon, warning message 5. **Hero Card** - Large text, background image support 6. **Button** - Call-to-action button with link ### Features: **Visual Toolbar:** ``` Insert Card: [Basic] [✓ Success] [ℹ Info] [⚠ Warning] [đŸ–ŧ Hero] | [+ Button] ``` **One-Click Insert:** - Click button → Card inserted at end of content - Pre-filled with sample content - Proper [card] syntax - Toast notification confirms insertion **Smart Behavior:** - Only shows in Visual Editor mode (hidden in Code Mode) - Styled toolbar with icons and colors - Responsive layout (wraps on mobile) - Separator between cards and button ### Card Types: **Basic:** ```html [card]

Card Title

Card content goes here...

[/card] ``` **Success:** ```html [card type="success"]

✅ Success!

Your action was successful.

[/card] ``` **Info, Warning, Hero** - Similar structure with different types **Button:** ```html

Button Text

``` ### Benefits: - ✅ **No manual typing** of [card] tags - ✅ **Consistent formatting** every time - ✅ **Visual feedback** with toast notifications - ✅ **Beginner-friendly** - just click and edit - ✅ **Professional templates** with pre-filled content ### Next: Email Appearance Settings 🎨 --- .../Settings/Notifications/EditTemplate.tsx | 96 ++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx b/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx index f086339..8320211 100644 --- a/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx +++ b/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx @@ -9,7 +9,7 @@ import { Input } from '@/components/ui/input'; import { RichTextEditor } from '@/components/ui/rich-text-editor'; import { Label } from '@/components/ui/label'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; -import { ArrowLeft, Eye, Edit, RotateCcw } from 'lucide-react'; +import { ArrowLeft, Eye, Edit, RotateCcw, Plus, CheckCircle, Info, AlertCircle, Image } from 'lucide-react'; import { toast } from 'sonner'; import { __ } from '@/lib/i18n'; @@ -125,6 +125,30 @@ export default function EditTemplate() { } }; + // Insert card helpers + const insertCard = (type?: string, content?: string) => { + let cardText = ''; + + if (type) { + cardText = `[card type="${type}"] +${content || '

Card Title

\n

Card content goes here...

'} +[/card]\n\n`; + } else { + cardText = `[card] +${content || '

Card Title

\n

Card content goes here...

'} +[/card]\n\n`; + } + + setBody(body + cardText); + toast.success(__('Card inserted')); + }; + + const insertButton = () => { + const buttonHtml = `

Button Text

`; + setBody(body + buttonHtml + '\n'); + toast.success(__('Button inserted')); + }; + // Get variable keys for the rich text editor const variableKeys = Object.keys(variables); @@ -343,6 +367,76 @@ export default function EditTemplate() { + {/* Card Insert Buttons */} + {!codeMode && ( +
+ + {__('Insert Card:')} + + + + + + +
+ +
+ )} + {codeMode ? (