Skip to content

Commit

Permalink
Move BrowserUtils into an object
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Jun 26, 2024
1 parent db68b78 commit 31711ab
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/MarkdownTextInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import React, {useEffect, useRef, useCallback, useMemo, useLayoutEffect} from 'r
import type {CSSProperties, MutableRefObject, ReactEventHandler, FocusEventHandler, MouseEvent, KeyboardEvent, SyntheticEvent} from 'react';
import {StyleSheet} from 'react-native';
import {updateInputStructure} from './web/parserUtils';
import * as BrowserUtils from './web/browserUtils';
import BrowserUtils from './web/browserUtils';
import InputHistory from './web/InputHistory';
import {buildTree} from './web/treeUtils';
import type {TreeNode} from './web/treeUtils';
Expand Down
20 changes: 11 additions & 9 deletions src/web/browserUtils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
const isChromium = 'chrome' in window;
const BrowserUtils = {
isFirefox: navigator.userAgent.toLowerCase().includes('firefox'),
isChromium: 'chrome' in window,

/**
* Whether the platform is a mobile browser.
* Copied from Expensify App https://github.com/Expensify/App/blob/90dee7accae79c49debf30354c160cab6c52c423/src/libs/Browser/index.website.ts#L41
*
*/
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Silk|Opera Mini/i.test(navigator.userAgent);
/**
* Whether the platform is a mobile browser.
* Copied from Expensify App https://github.com/Expensify/App/blob/90dee7accae79c49debf30354c160cab6c52c423/src/libs/Browser/index.website.ts#L41
*
*/
isMobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Silk|Opera Mini/i.test(navigator.userAgent),
};

export {isFirefox, isChromium, isMobile};
export default BrowserUtils;
2 changes: 1 addition & 1 deletion src/web/cursorUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {MarkdownTextInputElement} from '../MarkdownTextInput.web';
import * as BrowserUtils from './browserUtils';
import BrowserUtils from './browserUtils';
import {findHTMLElementInTree, getTreeNodeByIndex} from './treeUtils';

function setCursorPosition(target: MarkdownTextInputElement, start: number, end: number | null = null) {
Expand Down
2 changes: 1 addition & 1 deletion src/web/parserUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as BrowserUtils from './browserUtils';
import BrowserUtils from './browserUtils';
import type {MarkdownTextInputElement} from '../MarkdownTextInput.web';
import {addNodeToTree, buildTree} from './treeUtils';
import type {NodeType, TreeNode} from './treeUtils';
Expand Down

0 comments on commit 31711ab

Please sign in to comment.