import { Editor, Path } from "slate";
import { isUnorderedListElement } from "./UnorderedListElement.js";
import { isOrderedListElement } from "./OrderedListElement.js";
import { ContemberEditor } from "../../../ContemberEditor/index.js";
import { isListItemElement } from "./ListItemElement.js";
const isListElement = (element, suchThat) => isOrderedListElement(element, suchThat) || isUnorderedListElement(element, suchThat);
const getParentListElement = (editor) => {
  const closestNonDefaultEntry = ContemberEditor.closest(editor, {
    match: (node) => Editor.isBlock(editor, node) && !editor.isDefaultElement(node)
  });
  if (!closestNonDefaultEntry) {
    return void 0;
  }
  const [closestNonDefaultElement, closestNonDefaultPath] = closestNonDefaultEntry;
  if (isListItemElement(closestNonDefaultElement)) {
    return Editor.node(editor, Path.parent(closestNonDefaultPath))[0];
  } else if (isListElement(closestNonDefaultElement)) {
    return closestNonDefaultElement;
  }
  return void 0;
};
export {
  getParentListElement,
  isListElement
};
//# sourceMappingURL=ListElement.js.map
