@Override
  public void update(@NotNull AnActionEvent event) {
    final var fileAndEditor = getFileAndEditor(event);
    if (fileAndEditor == null) {
      return;
    }
    final var file = fileAndEditor.getFirst();
    final var caret = SelectionUtil.obtainPrimaryCaretSnapshot(this, event);
    if (caret == null) {
      event.getPresentation().setEnabled(false);
      return;
    }
    final var elements = MarkdownActionUtil.getElementsUnderCaretOrSelection(file, caret.getSelectionStart(), caret.getSelectionEnd());
    final var parentLink = MarkdownActionUtil.getCommonParentOfTypes(
      elements.getFirst(),
      elements.getSecond(),
      MarkdownTokenTypeSets.LINKS
    );
    if (parentLink == null) {
      event.getPresentation().setEnabled(false);
      return;
    }
    event.getPresentation().setEnabled(true);
  }
@Override
  public void update(@NotNull AnActionEvent event)