// Ref: https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js export const markApplies = (doc, ranges, type) => { for (const range of ranges) { const { $from, $to } = range; let canApply = $from.depth === 0 ? doc.type.allowsMarkType(type) : false; doc.nodesBetween($from.pos, $to.pos, (node) => { if (canApply) { return false; } canApply = node.inlineContent && node.type.allowsMarkType(type); return true; }); if (canApply) { return true; } } return false; }; export default markApplies; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFya0FwcGxpZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9uZ3gtZWRpdG9yL2hlbHBlcnMvbWFya0FwcGxpZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsdUZBQXVGO0FBQ3ZGLE1BQU0sQ0FBQyxNQUFNLFdBQVcsR0FBRyxDQUFDLEdBQW9CLEVBQUUsTUFBaUMsRUFBRSxJQUFjLEVBQVcsRUFBRTtJQUM5RyxLQUFLLE1BQU0sS0FBSyxJQUFJLE1BQU0sRUFBRTtRQUMxQixNQUFNLEVBQUUsS0FBSyxFQUFFLEdBQUcsRUFBRSxHQUFHLEtBQUssQ0FBQztRQUU3QixJQUFJLFFBQVEsR0FBRyxLQUFLLENBQUMsS0FBSyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLEtBQUssQ0FBQztRQUV6RSxHQUFHLENBQUMsWUFBWSxDQUFDLEtBQUssQ0FBQyxHQUFHLEVBQUUsR0FBRyxDQUFDLEdBQUcsRUFBRSxDQUFDLElBQXFCLEVBQVcsRUFBRTtZQUN0RSxJQUFJLFFBQVEsRUFBRTtnQkFDWixPQUFPLEtBQUssQ0FBQzthQUNkO1lBRUQsUUFBUSxHQUFHLElBQUksQ0FBQyxhQUFhLElBQUksSUFBSS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