import { numberNestedLists } from './numberNestedLists';
export const hasValidListIndentationLevel = ({
  tr,
  maxIndentation
}) => {
  const initialIndentationLevel = numberNestedLists(tr.selection.$from);
  let currentIndentationLevel;
  let currentPos = tr.selection.$to.pos;
  do {
    const resolvedPos = tr.doc.resolve(currentPos);
    currentIndentationLevel = numberNestedLists(resolvedPos);
    if (currentIndentationLevel > maxIndentation) {
      return false;
    }
    currentPos++;
  } while (currentIndentationLevel >= initialIndentationLevel);
  return true;
};