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

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

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

  if (!editor) {
    return null;
  }

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

export default Strike;
