UNPKG

@gechiui/dom

Version:
31 lines (24 loc) 1.01 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = documentHasSelection; var _isTextField = _interopRequireDefault(require("./is-text-field")); var _isNumberInput = _interopRequireDefault(require("./is-number-input")); var _documentHasTextSelection = _interopRequireDefault(require("./document-has-text-selection")); /** * Internal dependencies */ /** * Check whether the current document has a selection. This checks for both * focus in an input field and general text selection. * * @param {Document} doc The document to check. * * @return {boolean} True if there is selection, false if not. */ function documentHasSelection(doc) { return !!doc.activeElement && ((0, _isTextField.default)(doc.activeElement) || (0, _isNumberInput.default)(doc.activeElement) || (0, _documentHasTextSelection.default)(doc)); } //# sourceMappingURL=document-has-selection.js.map