@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
17 lines • 638 B
JavaScript
import { numberNestedLists } from './selection';
export var hasValidListIndentationLevel = function hasValidListIndentationLevel(_ref) {
var tr = _ref.tr,
maxIndentation = _ref.maxIndentation;
var initialIndentationLevel = numberNestedLists(tr.selection.$from);
var currentIndentationLevel;
var currentPos = tr.selection.$to.pos;
do {
var resolvedPos = tr.doc.resolve(currentPos);
currentIndentationLevel = numberNestedLists(resolvedPos);
if (currentIndentationLevel > maxIndentation) {
return false;
}
currentPos++;
} while (currentIndentationLevel >= initialIndentationLevel);
return true;
};