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

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

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

  if (!editor) {
    return null;
  }

  return (
    <ActionButton
      title={title}
      icon={<IconAlignJustified />}
      onClick={() => editor.chain().focus().toggleTextAlign('justify').run()}
      isActive={editor.isActive({ textAlign: 'justify' })}
    />
  );
};

export default AlignJustify;
