import React, { useContext } from 'react';
import classNames from 'classnames';
import { BLOCK_TYPES } from '../../text-editor-constants';
import TextEditorService from '../../text-editor-service';
import TextEditorContext from '../../text-editor-context';
import EditorButton from './editor-button';
import { jsx as _jsx } from "react/jsx-runtime";
function RemoveLinkButton({
  icon,
  tooltip = ''
}) {
  const {
    slate,
    slateReact
  } = useContext(TextEditorContext);
  const textEditorService = new TextEditorService(slate, slateReact);
  const editor = slateReact.useSlate();
  const isLinkActive = textEditorService.isBlockActive(editor, BLOCK_TYPES.LINK);
  return /*#__PURE__*/_jsx(EditorButton, {
    className: classNames({
      active: isLinkActive
    }),
    tooltipText: tooltip,
    icon: icon,
    onClick: () => {
      if (isLinkActive) {
        textEditorService.removeLink(editor);
      }
      textEditorService.focus(editor);
    },
    testId: "remove-link-button"
  });
}
export default RemoveLinkButton;