// @ts-ignore // TODO: fix cjs build
import { hasParentNode } from 'prosemirror-utils';
import { textblockTypeInputRule } from "../../../utils/inputrules.js";
import { headingType } from "./HeadingSpecs/index.js";
import { headingLevelAttr } from "./const.js";
export const hasParentHeading = (level) => (state) => hasParentNode((node) => {
    return node.type === headingType(state.schema) && node.attrs[headingLevelAttr] === level;
})(state.selection);
// Given a node type and a maximum level, creates an input rule that
// turns up to that number of `#` characters followed by a space at
// the start of a textblock into a heading whose level corresponds to
// the number of `#` signs.
export function headingRule(nodeType, maxLevel) {
    return textblockTypeInputRule(new RegExp('^(#{1,' + maxLevel + '})\\s$'), nodeType, (match) => ({ [headingLevelAttr]: match[1].length }));
}
//# sourceMappingURL=utils.js.map
