@portabletext/editor
Version:
Portable Text Editor made in React
26 lines (25 loc) • 870 B
JavaScript
import { getBlockKeyFromSelectionPoint } from "./selection-point.js";
import { childSelectionPointToBlockOffset } from "./util.child-selection-point-to-block-offset.js";
function isSelectionCollapsed(selection) {
return selection ? JSON.stringify(selection.anchor.path) === JSON.stringify(selection.focus.path) && selection.anchor.offset === selection.focus.offset : !1;
}
function selectionPointToBlockOffset({
context,
selectionPoint
}) {
const blockKey = getBlockKeyFromSelectionPoint(selectionPoint);
return selectionPoint.path.length === 1 && blockKey !== void 0 ? {
path: [{
_key: blockKey
}],
offset: selectionPoint.offset
} : childSelectionPointToBlockOffset({
context,
selectionPoint
});
}
export {
isSelectionCollapsed,
selectionPointToBlockOffset
};
//# sourceMappingURL=util.selection-point-to-block-offset.js.map