UNPKG

@tarojs/taro-h5

Version:
21 lines (18 loc) • 1.13 kB
import { temporarilyNotSupport } from '../../utils/index.js'; import { MethodHandler } from '../../utils/handler.js'; // 键盘 const onKeyboardHeightChange = /* @__PURE__ */ temporarilyNotSupport('onKeyboardHeightChange'); const offKeyboardHeightChange = /* @__PURE__ */ temporarilyNotSupport('offKeyboardHeightChange'); const hideKeyboard = /* @__PURE__ */ temporarilyNotSupport('hideKeyboard'); const getSelectedTextRange = ({ success, fail, complete } = {}) => { const handle = new MethodHandler({ name: 'getSelectedTextRange', success, fail, complete }); const input = typeof document === 'undefined' ? null : document.activeElement; if (input && (input instanceof HTMLInputElement || input instanceof HTMLTextAreaElement)) { const { selectionStart: start, selectionEnd: end } = input; if (start !== null && end !== null) return handle.success({ start, end }); } return handle.fail({ errMsg: 'no focused input with a text selection' }); }; export { getSelectedTextRange, hideKeyboard, offKeyboardHeightChange, onKeyboardHeightChange }; //# sourceMappingURL=keyboard.js.map