UNPKG

@atlaskit/editor-common

Version:

A package that contains common classes and components for editor and renderer

18 lines 570 B
import { numberNestedLists } from './selection'; 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; };