| // src/components/authoring/EditorToolbar.tsx | |
| import { | |
| Bold, Italic, Strikethrough, Code, Quote, List, ListOrdered, | |
| Heading1, Heading2, Heading3, Undo2, Redo2, Link as LinkIcon, | |
| Image as ImageIcon, Table as TableIcon, Pilcrow, Sigma, | |
| } from "lucide-react"; | |
| interface EditorToolbarProps { | |
| editor: any; | |
| onUndo: () => void; | |
| onRedo: () => void; | |
| reviewMode: string; | |
| } | |
| export function EditorToolbar({ editor, onUndo, onRedo, reviewMode }: EditorToolbarProps) { | |
| if (!editor) return null; | |
| return ( | |
| <div className="flex flex-wrap gap-0.5 px-4 py-2 border-b border-white/10 bg-white/5"> | |
| <ToolBtn onClick={onUndo} title="Undo (Ctrl+Z)"><Undo2 className="w-3.5 h-3.5"/></ToolBtn> | |
| <ToolBtn onClick={onRedo} title="Redo (Ctrl+Y)"><Redo2 className="w-3.5 h-3.5"/></ToolBtn> | |
| <div className="w-px h-6 bg-white/20 mx-1 self-center"/> | |
| <ToolBtn onClick={() => editor.chain().focus().toggleBold().run()} active={editor.isActive("bold")}><Bold className="w-3.5 h-3.5"/></ToolBtn> | |
| <ToolBtn onClick={() => editor.chain().focus().toggleItalic().run()} active={editor.isActive("italic")}><Italic className="w-3.5 h-3.5"/></ToolBtn> | |
| <ToolBtn onClick={() => editor.chain().focus().toggleStrike().run()} active={editor.isActive("strike")}><Strikethrough className="w-3.5 h-3.5"/></ToolBtn> | |
| <ToolBtn onClick={() => editor.chain().focus().toggleCode().run()} active={editor.isActive("code")}><Code className="w-3.5 h-3.5"/></ToolBtn> | |
| <div className="w-px h-6 bg-white/20 mx-1 self-center"/> | |
| <ToolBtn onClick={() => editor.chain().focus().toggleHeading({ level: 1 }).run()} active={editor.isActive("heading", { level: 1 })}><Heading1 className="w-3.5 h-3.5"/></ToolBtn> | |
| <ToolBtn onClick={() => editor.chain().focus().toggleHeading({ level: 2 }).run()} active={editor.isActive("heading", { level: 2 })}><Heading2 className="w-3.5 h-3.5"/></ToolBtn> | |
| <ToolBtn onClick={() => editor.chain().focus().toggleHeading({ level: 3 }).run()} active={editor.isActive("heading", { level: 3 })}><Heading3 className="w-3.5 h-3.5"/></ToolBtn> | |
| <div className="w-px h-6 bg-white/20 mx-1 self-center"/> | |
| <ToolBtn onClick={() => editor.chain().focus().toggleBulletList().run()} active={editor.isActive("bulletList")}><List className="w-3.5 h-3.5"/></ToolBtn> | |
| <ToolBtn onClick={() => editor.chain().focus().toggleOrderedList().run()} active={editor.isActive("orderedList")}><ListOrdered className="w-3.5 h-3.5"/></ToolBtn> | |
| <ToolBtn onClick={() => editor.chain().focus().toggleBlockquote().run()} active={editor.isActive("blockquote")}><Quote className="w-3.5 h-3.5"/></ToolBtn> | |
| <ToolBtn onClick={() => editor.chain().focus().toggleCodeBlock().run()} active={editor.isActive("codeBlock")}><Code className="w-3.5 h-3.5"/></ToolBtn> | |
| <div className="w-px h-6 bg-white/20 mx-1 self-center"/> | |
| <ToolBtn onClick={() => editor.chain().focus().setHorizontalRule().run()} title="Horizontal rule"><Pilcrow className="w-3.5 h-3.5"/></ToolBtn> | |
| <ToolBtn onClick={() => editor.chain().focus().insertContent("$$").run()} title="Insert math"><Sigma className="w-3.5 h-3.5"/></ToolBtn> | |
| <ToolBtn onClick={() => { const url = window.prompt("Link URL:"); if (url) editor.chain().focus().setLink({ href: url }).run(); }} active={editor.isActive("link")}><LinkIcon className="w-3.5 h-3.5"/></ToolBtn> | |
| <ToolBtn onClick={() => { const url = window.prompt("Image URL:"); if (url) editor.chain().focus().setImage({ src: url }).run(); }}><ImageIcon className="w-3.5 h-3.5"/></ToolBtn> | |
| <ToolBtn onClick={() => editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run()}><TableIcon className="w-3.5 h-3.5"/></ToolBtn> | |
| {reviewMode === "suggesting" && ( | |
| <span className="ml-2 text-[10px] bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 px-2 py-0.5 rounded-full">Suggesting Mode</span> | |
| )} | |
| </div> | |
| ); | |
| } | |
| function ToolBtn({ onClick, active, children, title }: { onClick: () => void; active?: boolean; children: React.ReactNode; title?: string }) { | |
| return ( | |
| <button type="button" onClick={onClick} title={title} | |
| className={`p-1.5 rounded-md transition ${active ? "bg-primary/10 text-primary" : "text-gray-600 dark:text-gray-400 hover:bg-white/10"}`}> | |
| {children} | |
| </button> | |
| ); | |
| } | |
Xet Storage Details
- Size:
- 4.34 kB
- Xet hash:
- f78f8ffe44debaa2cc7053dcec9d907b5b2ee9f7f27f45c510165b6e7c5e64b6
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.