forked from phoenix/litellm-mirror
(fix) create key flow
This commit is contained in:
parent
fae935cdb2
commit
d3e72e1c3b
144 changed files with 53398 additions and 50 deletions
39
node_modules/toggle-selection/index.js
generated
vendored
Normal file
39
node_modules/toggle-selection/index.js
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
module.exports = function () {
|
||||
var selection = document.getSelection();
|
||||
if (!selection.rangeCount) {
|
||||
return function () {};
|
||||
}
|
||||
var active = document.activeElement;
|
||||
|
||||
var ranges = [];
|
||||
for (var i = 0; i < selection.rangeCount; i++) {
|
||||
ranges.push(selection.getRangeAt(i));
|
||||
}
|
||||
|
||||
switch (active.tagName.toUpperCase()) { // .toUpperCase handles XHTML
|
||||
case 'INPUT':
|
||||
case 'TEXTAREA':
|
||||
active.blur();
|
||||
break;
|
||||
|
||||
default:
|
||||
active = null;
|
||||
break;
|
||||
}
|
||||
|
||||
selection.removeAllRanges();
|
||||
return function () {
|
||||
selection.type === 'Caret' &&
|
||||
selection.removeAllRanges();
|
||||
|
||||
if (!selection.rangeCount) {
|
||||
ranges.forEach(function(range) {
|
||||
selection.addRange(range);
|
||||
});
|
||||
}
|
||||
|
||||
active &&
|
||||
active.focus();
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue