UNPKG

@liveblocks/react-ui

Version:

A set of React pre-built components for the Liveblocks products. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.

37 lines (33 loc) 1.01 kB
'use strict'; var slate = require('slate'); function selectionContainsInlines(editor, match) { const { selection } = editor; if (!selection) { return false; } const roots = Array.from( slate.Editor.nodes(editor, { at: selection, match: (node) => slate.Element.isElement(node) && slate.Editor.isBlock(editor, node), mode: "lowest" }) ); for (const [, rootPath] of roots) { const intersectingSelection = slate.Range.isRange(selection) ? slate.Range.intersection(selection, slate.Editor.range(editor, rootPath)) : selection; if (!intersectingSelection) { continue; } const matches = Array.from( slate.Editor.nodes(editor, { at: intersectingSelection, match: (node) => slate.Editor.isInline(editor, node) && match(node) }) ); if (matches.length > 0) { return true; } } return false; } exports.selectionContainsInlines = selectionContainsInlines; //# sourceMappingURL=selection-contains-inlines.cjs.map