@tamagui/react-native-use-responder-events 2.7.7 → 3.0.0-beta.643.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ResponderSystem.cjs +307 -344
- package/dist/cjs/ResponderSystem.native.cjs +357 -0
- package/dist/cjs/ResponderSystem.native.js +307 -343
- package/dist/cjs/ResponderSystem.native.js.map +1 -1
- package/dist/cjs/ResponderTouchHistoryStore.cjs +136 -149
- package/dist/cjs/ResponderTouchHistoryStore.native.cjs +217 -0
- package/dist/cjs/ResponderTouchHistoryStore.native.js +176 -189
- package/dist/cjs/ResponderTouchHistoryStore.native.js.map +1 -1
- package/dist/cjs/createResponderEvent.cjs +128 -132
- package/dist/cjs/createResponderEvent.native.cjs +147 -0
- package/dist/cjs/createResponderEvent.native.js +129 -132
- package/dist/cjs/createResponderEvent.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +40 -41
- package/dist/cjs/types.native.cjs +79 -0
- package/dist/cjs/types.native.js +40 -40
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/useResponderEvents.cjs +60 -85
- package/dist/cjs/useResponderEvents.native.cjs +87 -0
- package/dist/cjs/useResponderEvents.native.js +62 -86
- package/dist/cjs/useResponderEvents.native.js.map +1 -1
- package/dist/cjs/utils.cjs +123 -135
- package/dist/cjs/utils.native.cjs +160 -0
- package/dist/cjs/utils.native.js +124 -135
- package/dist/cjs/utils.native.js.map +1 -1
- package/dist/esm/ResponderSystem.mjs +291 -326
- package/dist/esm/ResponderSystem.mjs.map +1 -1
- package/dist/esm/ResponderSystem.native.js +291 -326
- package/dist/esm/ResponderSystem.native.js.map +1 -1
- package/dist/esm/ResponderTouchHistoryStore.mjs +123 -131
- package/dist/esm/ResponderTouchHistoryStore.mjs.map +1 -1
- package/dist/esm/ResponderTouchHistoryStore.native.js +163 -172
- package/dist/esm/ResponderTouchHistoryStore.native.js.map +1 -1
- package/dist/esm/createResponderEvent.mjs +115 -114
- package/dist/esm/createResponderEvent.mjs.map +1 -1
- package/dist/esm/createResponderEvent.native.js +116 -115
- package/dist/esm/createResponderEvent.native.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/index.native.js +1 -2
- package/dist/esm/types.mjs +7 -6
- package/dist/esm/types.mjs.map +1 -1
- package/dist/esm/types.native.js +7 -6
- package/dist/esm/types.native.js.map +1 -1
- package/dist/esm/useResponderEvents.mjs +45 -61
- package/dist/esm/useResponderEvents.mjs.map +1 -1
- package/dist/esm/useResponderEvents.native.js +47 -63
- package/dist/esm/useResponderEvents.native.js.map +1 -1
- package/dist/esm/utils.mjs +101 -111
- package/dist/esm/utils.mjs.map +1 -1
- package/dist/esm/utils.native.js +102 -112
- package/dist/esm/utils.native.js.map +1 -1
- package/package.json +2 -2
- package/types/ResponderTouchHistoryStore.d.ts.map +1 -1
- package/types/utils.d.ts.map +1 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
package/dist/cjs/utils.cjs
CHANGED
|
@@ -1,169 +1,157 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
10
11
|
};
|
|
11
12
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
19
20
|
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
22
|
var utils_exports = {};
|
|
24
23
|
__export(utils_exports, {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
canUseDOM: () => canUseDOM,
|
|
25
|
+
getBoundingClientRect: () => getBoundingClientRect,
|
|
26
|
+
getLowestCommonAncestor: () => getLowestCommonAncestor,
|
|
27
|
+
getResponderPaths: () => getResponderPaths,
|
|
28
|
+
hasTargetTouches: () => hasTargetTouches,
|
|
29
|
+
hasValidSelection: () => hasValidSelection,
|
|
30
|
+
isPrimaryPointerDown: () => isPrimaryPointerDown,
|
|
31
|
+
isSelectionValid: () => isSelectionValid,
|
|
32
|
+
setResponderId: () => setResponderId
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(utils_exports);
|
|
36
35
|
const keyName = "__reactResponderId";
|
|
37
36
|
const canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
38
|
-
const getBoundingClientRect = node => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
const getBoundingClientRect = (node) => {
|
|
38
|
+
if (!node) return;
|
|
39
|
+
if (node.nodeType !== 1) return;
|
|
40
|
+
if (node.getBoundingClientRect) {
|
|
41
|
+
return node.getBoundingClientRect();
|
|
42
|
+
}
|
|
44
43
|
};
|
|
45
44
|
function getEventPath(domEvent) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
if (domEvent.type === "selectionchange") {
|
|
46
|
+
const target = window.getSelection()?.anchorNode;
|
|
47
|
+
return composedPathFallback(target);
|
|
48
|
+
}
|
|
49
|
+
const path = domEvent.composedPath != null ? domEvent.composedPath() : composedPathFallback(domEvent.target);
|
|
50
|
+
return path;
|
|
52
51
|
}
|
|
53
52
|
function composedPathFallback(target) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
const path = [];
|
|
54
|
+
while (target != null && target !== document.body) {
|
|
55
|
+
path.push(target);
|
|
56
|
+
target = target.parentNode;
|
|
57
|
+
}
|
|
58
|
+
return path;
|
|
60
59
|
}
|
|
61
60
|
function getResponderId(node) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
if (node != null) {
|
|
62
|
+
return node[keyName];
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
66
65
|
}
|
|
67
66
|
function setResponderId(node, id) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
if (node != null) {
|
|
68
|
+
node[keyName] = id;
|
|
69
|
+
}
|
|
71
70
|
}
|
|
72
71
|
function getResponderPaths(domEvent) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
72
|
+
const idPath = [];
|
|
73
|
+
const nodePath = [];
|
|
74
|
+
const eventPath = getEventPath(domEvent);
|
|
75
|
+
for (let i = 0; i < eventPath.length; i++) {
|
|
76
|
+
const node = eventPath[i];
|
|
77
|
+
const id = getResponderId(node);
|
|
78
|
+
if (id != null) {
|
|
79
|
+
idPath.push(id);
|
|
80
|
+
nodePath.push(node);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
idPath,
|
|
85
|
+
nodePath
|
|
86
|
+
};
|
|
88
87
|
}
|
|
89
88
|
function getLowestCommonAncestor(pathA, pathB) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
itemA = pathA[indexA++];
|
|
120
|
-
itemB = pathB[indexB++];
|
|
121
|
-
}
|
|
122
|
-
return null;
|
|
89
|
+
let pathALength = pathA.length;
|
|
90
|
+
let pathBLength = pathB.length;
|
|
91
|
+
if (pathALength === 0 || pathBLength === 0 || pathA[pathALength - 1] !== pathB[pathBLength - 1]) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
let itemA = pathA[0];
|
|
95
|
+
let indexA = 0;
|
|
96
|
+
let itemB = pathB[0];
|
|
97
|
+
let indexB = 0;
|
|
98
|
+
if (pathALength - pathBLength > 0) {
|
|
99
|
+
indexA = pathALength - pathBLength;
|
|
100
|
+
itemA = pathA[indexA];
|
|
101
|
+
pathALength = pathBLength;
|
|
102
|
+
}
|
|
103
|
+
if (pathBLength - pathALength > 0) {
|
|
104
|
+
indexB = pathBLength - pathALength;
|
|
105
|
+
itemB = pathB[indexB];
|
|
106
|
+
pathBLength = pathALength;
|
|
107
|
+
}
|
|
108
|
+
let depth = pathALength;
|
|
109
|
+
while (depth--) {
|
|
110
|
+
if (itemA === itemB) {
|
|
111
|
+
return itemA;
|
|
112
|
+
}
|
|
113
|
+
itemA = pathA[indexA++];
|
|
114
|
+
itemB = pathB[indexB++];
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
123
117
|
}
|
|
124
118
|
function hasTargetTouches(target, touches) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
119
|
+
if (!touches || touches.length === 0) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
for (let i = 0; i < touches.length; i++) {
|
|
123
|
+
const node = touches[i].target;
|
|
124
|
+
if (node != null) {
|
|
125
|
+
if (target.contains(node)) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
137
131
|
}
|
|
138
132
|
function hasValidSelection(domEvent) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
133
|
+
if (domEvent.type === "selectionchange") {
|
|
134
|
+
return isSelectionValid();
|
|
135
|
+
}
|
|
136
|
+
return domEvent.type === "select";
|
|
143
137
|
}
|
|
144
138
|
function isPrimaryPointerDown(domEvent) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const isPrimaryMouseMove = type === "mousemove" && buttons === 1;
|
|
155
|
-
const noModifiers = altKey === false && ctrlKey === false;
|
|
156
|
-
if (isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers) {
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
return false;
|
|
139
|
+
const { altKey, button, buttons, ctrlKey, type } = domEvent;
|
|
140
|
+
const isTouch = type === "touchstart" || type === "touchmove";
|
|
141
|
+
const isPrimaryMouseDown = type === "mousedown" && (button === 0 || buttons === 1);
|
|
142
|
+
const isPrimaryMouseMove = type === "mousemove" && buttons === 1;
|
|
143
|
+
const noModifiers = altKey === false && ctrlKey === false;
|
|
144
|
+
if (isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
return false;
|
|
160
148
|
}
|
|
161
149
|
function isSelectionValid() {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
150
|
+
const selection = window.getSelection();
|
|
151
|
+
if (!selection) return false;
|
|
152
|
+
const string = selection.toString();
|
|
153
|
+
const anchorNode = selection.anchorNode;
|
|
154
|
+
const focusNode = selection.focusNode;
|
|
155
|
+
const isTextNode = anchorNode && anchorNode.nodeType === window.Node.TEXT_NODE || focusNode && focusNode.nodeType === window.Node.TEXT_NODE;
|
|
156
|
+
return string.length >= 1 && string !== "\n" && !!isTextNode;
|
|
157
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var utils_exports = {};
|
|
25
|
+
__export(utils_exports, {
|
|
26
|
+
canUseDOM: () => canUseDOM,
|
|
27
|
+
getBoundingClientRect: () => getBoundingClientRect,
|
|
28
|
+
getLowestCommonAncestor: () => getLowestCommonAncestor,
|
|
29
|
+
getResponderPaths: () => getResponderPaths,
|
|
30
|
+
hasTargetTouches: () => hasTargetTouches,
|
|
31
|
+
hasValidSelection: () => hasValidSelection,
|
|
32
|
+
isPrimaryPointerDown: () => isPrimaryPointerDown,
|
|
33
|
+
isSelectionValid: () => isSelectionValid,
|
|
34
|
+
setResponderId: () => setResponderId
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(utils_exports);
|
|
37
|
+
var keyName = "__reactResponderId";
|
|
38
|
+
var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
39
|
+
var getBoundingClientRect = function(node) {
|
|
40
|
+
if (!node) return;
|
|
41
|
+
if (node.nodeType !== 1) return;
|
|
42
|
+
if (node.getBoundingClientRect) {
|
|
43
|
+
return node.getBoundingClientRect();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
function getEventPath(domEvent) {
|
|
47
|
+
if (domEvent.type === "selectionchange") {
|
|
48
|
+
var _window_getSelection;
|
|
49
|
+
var target = (_window_getSelection = window.getSelection()) === null || _window_getSelection === void 0 ? void 0 : _window_getSelection.anchorNode;
|
|
50
|
+
return composedPathFallback(target);
|
|
51
|
+
}
|
|
52
|
+
var path = domEvent.composedPath != null ? domEvent.composedPath() : composedPathFallback(domEvent.target);
|
|
53
|
+
return path;
|
|
54
|
+
}
|
|
55
|
+
function composedPathFallback(target) {
|
|
56
|
+
var path = [];
|
|
57
|
+
while (target != null && target !== document.body) {
|
|
58
|
+
path.push(target);
|
|
59
|
+
target = target.parentNode;
|
|
60
|
+
}
|
|
61
|
+
return path;
|
|
62
|
+
}
|
|
63
|
+
function getResponderId(node) {
|
|
64
|
+
if (node != null) {
|
|
65
|
+
return node[keyName];
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
function setResponderId(node, id) {
|
|
70
|
+
if (node != null) {
|
|
71
|
+
node[keyName] = id;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function getResponderPaths(domEvent) {
|
|
75
|
+
var idPath = [];
|
|
76
|
+
var nodePath = [];
|
|
77
|
+
var eventPath = getEventPath(domEvent);
|
|
78
|
+
for (var i = 0; i < eventPath.length; i++) {
|
|
79
|
+
var node = eventPath[i];
|
|
80
|
+
var id = getResponderId(node);
|
|
81
|
+
if (id != null) {
|
|
82
|
+
idPath.push(id);
|
|
83
|
+
nodePath.push(node);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
idPath,
|
|
88
|
+
nodePath
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function getLowestCommonAncestor(pathA, pathB) {
|
|
92
|
+
var pathALength = pathA.length;
|
|
93
|
+
var pathBLength = pathB.length;
|
|
94
|
+
if (pathALength === 0 || pathBLength === 0 || pathA[pathALength - 1] !== pathB[pathBLength - 1]) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
var itemA = pathA[0];
|
|
98
|
+
var indexA = 0;
|
|
99
|
+
var itemB = pathB[0];
|
|
100
|
+
var indexB = 0;
|
|
101
|
+
if (pathALength - pathBLength > 0) {
|
|
102
|
+
indexA = pathALength - pathBLength;
|
|
103
|
+
itemA = pathA[indexA];
|
|
104
|
+
pathALength = pathBLength;
|
|
105
|
+
}
|
|
106
|
+
if (pathBLength - pathALength > 0) {
|
|
107
|
+
indexB = pathBLength - pathALength;
|
|
108
|
+
itemB = pathB[indexB];
|
|
109
|
+
pathBLength = pathALength;
|
|
110
|
+
}
|
|
111
|
+
var depth = pathALength;
|
|
112
|
+
while (depth--) {
|
|
113
|
+
if (itemA === itemB) {
|
|
114
|
+
return itemA;
|
|
115
|
+
}
|
|
116
|
+
itemA = pathA[indexA++];
|
|
117
|
+
itemB = pathB[indexB++];
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
function hasTargetTouches(target, touches) {
|
|
122
|
+
if (!touches || touches.length === 0) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
for (var i = 0; i < touches.length; i++) {
|
|
126
|
+
var node = touches[i].target;
|
|
127
|
+
if (node != null) {
|
|
128
|
+
if (target.contains(node)) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
function hasValidSelection(domEvent) {
|
|
136
|
+
if (domEvent.type === "selectionchange") {
|
|
137
|
+
return isSelectionValid();
|
|
138
|
+
}
|
|
139
|
+
return domEvent.type === "select";
|
|
140
|
+
}
|
|
141
|
+
function isPrimaryPointerDown(domEvent) {
|
|
142
|
+
var { altKey, button, buttons, ctrlKey, type } = domEvent;
|
|
143
|
+
var isTouch = type === "touchstart" || type === "touchmove";
|
|
144
|
+
var isPrimaryMouseDown = type === "mousedown" && (button === 0 || buttons === 1);
|
|
145
|
+
var isPrimaryMouseMove = type === "mousemove" && buttons === 1;
|
|
146
|
+
var noModifiers = altKey === false && ctrlKey === false;
|
|
147
|
+
if (isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
function isSelectionValid() {
|
|
153
|
+
var selection = window.getSelection();
|
|
154
|
+
if (!selection) return false;
|
|
155
|
+
var string = selection.toString();
|
|
156
|
+
var anchorNode = selection.anchorNode;
|
|
157
|
+
var focusNode = selection.focusNode;
|
|
158
|
+
var isTextNode = anchorNode && anchorNode.nodeType === window.Node.TEXT_NODE || focusNode && focusNode.nodeType === window.Node.TEXT_NODE;
|
|
159
|
+
return string.length >= 1 && string !== "\n" && !!isTextNode;
|
|
160
|
+
}
|