"use client"; import { type Editor, useEditorState } from "@tiptap/react"; import { Bold, BrushCleaning, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Italic, List, ListOrdered, Quote, Redo, SeparatorHorizontal, StrikethroughIcon, Text, Underline, Undo, } from "lucide-react"; import { Button } from "~/components/ui/button"; import { Toggle } from "~/components/ui/toggle"; function ToolBar({ editor }: { editor: Editor }) { const editorState = useEditorState({ editor, selector: (ctx) => { return { canBold: ctx.editor.can().chain().toggleBold().run() ?? false, canClearMarks: ctx.editor.can().chain().unsetAllMarks().run() ?? false, canItalic: ctx.editor.can().chain().toggleItalic().run() ?? false, canRedo: ctx.editor.can().chain().redo().run() ?? false, canStrike: ctx.editor.can().chain().toggleStrike().run() ?? false, canUnderline: ctx.editor.can().chain().toggleUnderline().run() ?? false, canUndo: ctx.editor.can().chain().undo().run() ?? false, isBlockquote: ctx.editor.isActive("blockquote") ?? false, isBold: ctx.editor.isActive("bold") ?? false, isBulletList: ctx.editor.isActive("bulletList") ?? false, isHeading1: ctx.editor.isActive("heading", { level: 1 }) ?? false, isHeading2: ctx.editor.isActive("heading", { level: 2 }) ?? false, isHeading3: ctx.editor.isActive("heading", { level: 3 }) ?? false, isHeading4: ctx.editor.isActive("heading", { level: 4 }) ?? false, isHeading5: ctx.editor.isActive("heading", { level: 5 }) ?? false, isHeading6: ctx.editor.isActive("heading", { level: 6 }) ?? false, isItalic: ctx.editor.isActive("italic") ?? false, isOrderedList: ctx.editor.isActive("orderedList") ?? false, isParagraph: ctx.editor.isActive("paragraph") ?? false, isStrike: ctx.editor.isActive("strike") ?? false, isUnderline: ctx.editor.isActive("underline") ?? false, }; }, }); return (