import { useElement } from '@udecode/plate-common';
import { useFocused, useReadOnly, useSelected } from 'slate-react';

import { TAttachmentElement } from './types';
import { useAttachmentList } from './useAttachmentList';

export const useAttachmentState = () => {
  const element = useElement<TAttachmentElement>();
  const focused = useFocused();
  const selected = useSelected();
  const readOnly = useReadOnly();

  const attachmentList = useAttachmentList();

  return {
    focused,
    selected,
    readOnly,
    align: element.align,
    element,
    attachmentList,
  };
};
