UNPKG

@portabletext/editor

Version:

Portable Text Editor made in React

35 lines (34 loc) 869 B
import { getSelectionStartPoint, getBlockStartPoint } from "./selection-point.js"; import { getFocusBlock, getSelectionText } from "./selector.is-selection-expanded.js"; const getBlockTextBefore = (snapshot) => { if (!snapshot.context.selection) return ""; const startPoint = getSelectionStartPoint(snapshot.context.selection), block = getFocusBlock({ context: { ...snapshot.context, selection: { anchor: startPoint, focus: startPoint } } }); if (!block) return ""; const startOfBlock = getBlockStartPoint({ context: snapshot.context, block }); return getSelectionText({ context: { ...snapshot.context, selection: { anchor: startOfBlock, focus: startPoint } } }); }; export { getBlockTextBefore }; //# sourceMappingURL=selector.get-text-before.js.map