Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

33 rader
977 B

  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. *
  9. * @emails oncall+draft_js
  10. */
  11. 'use strict';
  12. var getDraftEditorSelectionWithNodes = require("./getDraftEditorSelectionWithNodes");
  13. /**
  14. * Convert the current selection range to an anchor/focus pair of offset keys
  15. * and values that can be interpreted by components.
  16. */
  17. function getDraftEditorSelection(editorState, root) {
  18. var selection = root.ownerDocument.defaultView.getSelection(); // No active selection.
  19. if (selection.rangeCount === 0) {
  20. return {
  21. selectionState: editorState.getSelection().set('hasFocus', false),
  22. needsRecovery: false
  23. };
  24. }
  25. return getDraftEditorSelectionWithNodes(editorState, root, selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset);
  26. }
  27. module.exports = getDraftEditorSelection;