@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.
35 lines (32 loc) • 945 B
JavaScript
import { Editor, Element, Range } from 'slate';
function selectionContainsInlines(editor, match) {
const { selection } = editor;
if (!selection) {
return false;
}
const roots = Array.from(
Editor.nodes(editor, {
at: selection,
match: (node) => Element.isElement(node) && Editor.isBlock(editor, node),
mode: "lowest"
})
);
for (const [, rootPath] of roots) {
const intersectingSelection = Range.isRange(selection) ? Range.intersection(selection, Editor.range(editor, rootPath)) : selection;
if (!intersectingSelection) {
continue;
}
const matches = Array.from(
Editor.nodes(editor, {
at: intersectingSelection,
match: (node) => Editor.isInline(editor, node) && match(node)
})
);
if (matches.length > 0) {
return true;
}
}
return false;
}
export { selectionContainsInlines };
//# sourceMappingURL=selection-contains-inlines.js.map