import { IconBold } from '@tabler/icons-react';

import ActionButton from '../components/ActionButton';
import { useTextArea } from '../context';

const Bold = ({ title }: { title: string }) => {
  const { editor } = useTextArea();

  if (!editor) {
    return null;
  }

  return (
    <ActionButton
      title={title}
      icon={<IconBold />}
      onClick={() => editor.chain().focus().toggleBold().run()}
      isActive={editor.isActive('bold')}
      disabled={!editor.can().chain().focus().toggleBold().run()}
    />
  );
};

export default Bold;
