getInputRange.js 740 B

12345678910111213141516
  1. import { getTargetTypeAndSelection } from './getTargetTypeAndSelection.js';
  2. /**
  3. * Get the range that would be overwritten by input.
  4. */ function getInputRange(focusNode) {
  5. const typeAndSelection = getTargetTypeAndSelection(focusNode);
  6. if (typeAndSelection.type === 'input') {
  7. return typeAndSelection.selection;
  8. } else if (typeAndSelection.type === 'contenteditable') {
  9. var _typeAndSelection_selection;
  10. // Multi-range on contenteditable edits the first selection instead of the last
  11. return (_typeAndSelection_selection = typeAndSelection.selection) === null || _typeAndSelection_selection === undefined ? undefined : _typeAndSelection_selection.getRangeAt(0);
  12. }
  13. }
  14. export { getInputRange };