@portabletext/editor
Version:
Portable Text Editor made in React
24 lines (23 loc) • 1.02 kB
JavaScript
;
var selectionPoint = require("./selection-point.cjs"), util_childSelectionPointToBlockOffset = require("./util.child-selection-point-to-block-offset.cjs");
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: selectionPoint$1
}) {
const blockKey = selectionPoint.getBlockKeyFromSelectionPoint(selectionPoint$1);
return selectionPoint$1.path.length === 1 && blockKey !== void 0 ? {
path: [{
_key: blockKey
}],
offset: selectionPoint$1.offset
} : util_childSelectionPointToBlockOffset.childSelectionPointToBlockOffset({
context,
selectionPoint: selectionPoint$1
});
}
exports.isSelectionCollapsed = isSelectionCollapsed;
exports.selectionPointToBlockOffset = selectionPointToBlockOffset;
//# sourceMappingURL=util.selection-point-to-block-offset.cjs.map