import type { Editor } from '@tiptap/core'
import { Button } from '@admin/components/ui/button'
import { Minus } from 'lucide-react'

export function HorizontalRuleButton({ editor }: { editor: Editor | null }) {
  const canInsert = editor?.can().setHorizontalRule() ?? false

  return (
    <Button
      type="button"
      variant="ghost"
      size="icon-sm"
      disabled={!canInsert}
      data-disabled={!canInsert}
      aria-label="Insert divider"
      title="Divider"
      onClick={() => editor?.chain().focus().setHorizontalRule().run()}
    >
      <Minus />
    </Button>
  )
}
