1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | 'use strict';
|
12 |
|
13 | var getDraftEditorSelectionWithNodes = require("./getDraftEditorSelectionWithNodes");
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | function getDraftEditorSelection(editorState, root) {
|
21 | var selection = root.ownerDocument.defaultView.getSelection();
|
22 | var anchorNode = selection.anchorNode,
|
23 | anchorOffset = selection.anchorOffset,
|
24 | focusNode = selection.focusNode,
|
25 | focusOffset = selection.focusOffset,
|
26 | rangeCount = selection.rangeCount;
|
27 |
|
28 | if (
|
29 | rangeCount === 0 ||
|
30 |
|
31 | anchorNode == null || focusNode == null) {
|
32 | return {
|
33 | selectionState: editorState.getSelection().set('hasFocus', false),
|
34 | needsRecovery: false
|
35 | };
|
36 | }
|
37 |
|
38 | return getDraftEditorSelectionWithNodes(editorState, root, anchorNode, anchorOffset, focusNode, focusOffset);
|
39 | }
|
40 |
|
41 | module.exports = getDraftEditorSelection; |
\ | No newline at end of file |