getInputRange.js 793 B

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