"use client" import * as React from "react" import { createPortal } from "react-dom" import { EditorContent, useEditor, useEditorState } from "@tiptap/react" import { BubbleMenu } from "@tiptap/react/menus" import Placeholder from "@tiptap/extension-placeholder" import StarterKit from "@tiptap/starter-kit" import { cn } from "../../lib/utils" import { Button } from "./button" import { Input } from "./input" import { Kbd } from "./kbd" import { Popover, PopoverContent, PopoverTrigger, } from "./popover" import { Tip } from "./tip" type RichTextEditorProps = Omit< React.ComponentProps<"div">, "children" | "defaultValue" | "onChange" > & { value?: string defaultValue?: string onChange?: (html: string) => void name?: string placeholder?: string disabled?: boolean readOnly?: boolean } type EditorCommand = { label: string shortcut?: string icon: string active: boolean run: () => void } const EDITOR_TOGGLE_ACTIVE_CLASS = "border border-transparent aria-pressed:border-brand aria-pressed:bg-brand-tint aria-pressed:text-foreground hc:aria-pressed:border-foreground hc:aria-pressed:bg-accent hc:aria-pressed:text-accent-foreground forced-colors:aria-pressed:border-[CanvasText] forced-colors:aria-pressed:bg-[Highlight] forced-colors:aria-pressed:text-[HighlightText]" function ToolbarButton({ command }: { command: EditorCommand }) { const button = (