diff --git a/admin-spa/src/components/RichTextEditor.tsx b/admin-spa/src/components/RichTextEditor.tsx new file mode 100644 index 0000000..08fdf0b --- /dev/null +++ b/admin-spa/src/components/RichTextEditor.tsx @@ -0,0 +1,118 @@ +import React from 'react'; +import { useEditor, EditorContent } from '@tiptap/react'; +import StarterKit from '@tiptap/starter-kit'; +import { Bold, Italic, List, ListOrdered, Heading2, Quote, Undo, Redo } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { cn } from '@/lib/utils'; + +type RichTextEditorProps = { + value: string; + onChange: (value: string) => void; + placeholder?: string; + className?: string; +}; + +export function RichTextEditor({ value, onChange, placeholder, className }: RichTextEditorProps) { + const editor = useEditor({ + extensions: [StarterKit], + content: value, + onUpdate: ({ editor }) => { + onChange(editor.getHTML()); + }, + editorProps: { + attributes: { + class: 'prose prose-sm max-w-none focus:outline-none min-h-[150px] px-3 py-2', + }, + }, + }); + + if (!editor) { + return null; + } + + return ( +
+ {/* Toolbar */} +
+ + + + + + +
+ + +
+ + {/* Editor */} + +
+ ); +} diff --git a/admin-spa/src/routes/Products/index.tsx b/admin-spa/src/routes/Products/index.tsx index 21d3ffb..994b3ef 100644 --- a/admin-spa/src/routes/Products/index.tsx +++ b/admin-spa/src/routes/Products/index.tsx @@ -381,18 +381,31 @@ export default function Products() { {product.sku || '—'} - + {product.manage_stock ? ( + + ) : ( + + )} {product.price_html ? ( + ) : product.sale_price ? ( + + {formatMoney(product.regular_price)} + {formatMoney(product.sale_price)} + ) : product.regular_price ? ( {formatMoney(product.regular_price)} ) : ( )} - {product.type || '—'} + + + {product.type || 'simple'} + + {__('Edit')} diff --git a/admin-spa/src/routes/Products/partials/tabs/GeneralTab.tsx b/admin-spa/src/routes/Products/partials/tabs/GeneralTab.tsx index f8ad9ae..48b67df 100644 --- a/admin-spa/src/routes/Products/partials/tabs/GeneralTab.tsx +++ b/admin-spa/src/routes/Products/partials/tabs/GeneralTab.tsx @@ -9,6 +9,7 @@ import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectVa import { Separator } from '@/components/ui/separator'; import { DollarSign } from 'lucide-react'; import { getStoreCurrency } from '@/lib/currency'; +import { RichTextEditor } from '@/components/RichTextEditor'; type GeneralTabProps = { name: string; @@ -138,14 +139,13 @@ export function GeneralTab({ {/* Description */}
-