@Override
  public void actionPerformed(@NotNull AnActionEvent event) {
    var editor = MarkdownActionUtil.findMarkdownEditor(event);
    if (editor == null) return;
    var psiFile = event.getData(CommonDataKeys.PSI_FILE);
    if (psiFile == null) return;
    var commandName = getTemplatePresentation().getText();
    WriteCommandAction.runWriteCommandAction(psiFile.getProject(), commandName, null, () -> {
      if (!psiFile.isValid()) {
        return;
      }

      for (Caret caret : ContainerUtil.reverse(editor.getCaretModel().getAllCarets())) {
        PsiElement parent = Objects.requireNonNull(findParent(psiFile, caret.getSelectionStart(), caret.getSelectionEnd()));
        MarkdownHeader header = PsiTreeUtil.getParentOfType(parent, MarkdownHeader.class, false);

        if (header != null && header.isValid()) {
          header.replace(createNewLevelHeader(header));
        }
        else {
          parent.replace(createHeaderForText(parent));
        }
      }
    }, psiFile);
  }
@Override
  public void actionPerformed(@NotNull AnActionEvent event)