@portabletext/editor
Version:
Portable Text Editor made in React
33 lines (32 loc) • 953 B
JavaScript
;
var selectionPoint = require("./selection-point.cjs"), selector_isSelectionExpanded = require("./selector.is-selection-expanded.cjs");
const getBlockTextBefore = (snapshot) => {
if (!snapshot.context.selection)
return "";
const startPoint = selectionPoint.getSelectionStartPoint(snapshot.context.selection), block = selector_isSelectionExpanded.getFocusBlock({
context: {
...snapshot.context,
selection: {
anchor: startPoint,
focus: startPoint
}
}
});
if (!block)
return "";
const startOfBlock = selectionPoint.getBlockStartPoint({
context: snapshot.context,
block
});
return selector_isSelectionExpanded.getSelectionText({
context: {
...snapshot.context,
selection: {
anchor: startOfBlock,
focus: startPoint
}
}
});
};
exports.getBlockTextBefore = getBlockTextBefore;
//# sourceMappingURL=selector.get-text-before.cjs.map