mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-27 02:51:57 +02:00
Refactor isMac to a utility module (#22829)
GitOrigin-RevId: c6ab1dbeb1c56c35af121e7f657325a89fc847ea
This commit is contained in:
@@ -5,12 +5,12 @@ import { useProjectContext } from '../../../shared/context/project-context'
|
||||
import HotkeysModal from '../../hotkeys-modal/components/hotkeys-modal'
|
||||
import LeftMenuButton from './left-menu-button'
|
||||
import { bsVersionIcon } from '@/features/utils/bootstrap-5'
|
||||
import { isMac } from '@/shared/utils/os'
|
||||
|
||||
export default function HelpShowHotkeys() {
|
||||
const [showModal, setShowModal] = useState(false)
|
||||
const { t } = useTranslation()
|
||||
const { features } = useProjectContext()
|
||||
const isMac = /Mac/.test(window.navigator?.platform)
|
||||
|
||||
const showModalWithAnalytics = useCallback(() => {
|
||||
eventTracking.sendMB('left-menu-hotkeys')
|
||||
|
||||
@@ -21,6 +21,7 @@ import { FindResult } from '@/features/file-tree/util/path'
|
||||
import { fileCollator } from '@/features/file-tree/util/file-collator'
|
||||
import { Folder } from '../../../../../types/folder'
|
||||
import { FileTreeEntity } from '../../../../../types/file-tree-entity'
|
||||
import { isMac } from '@/shared/utils/os'
|
||||
|
||||
const FileTreeSelectableContext = createContext<
|
||||
| {
|
||||
@@ -234,8 +235,6 @@ export const FileTreeSelectableProvider: FC<{
|
||||
)
|
||||
}
|
||||
|
||||
const isMac = /Mac/.test(window.navigator?.platform)
|
||||
|
||||
export function useSelectableEntity(id: string, type: string) {
|
||||
const { view, setView } = useLayoutContext()
|
||||
const { setContextMenuCoords } = useFileTreeMainContext()
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import PDFToolbarButton from './pdf-toolbar-button'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import OLButtonGroup from '@/features/ui/components/ol/ol-button-group'
|
||||
|
||||
const isMac = /Mac/.test(window.navigator?.platform)
|
||||
import { isMac } from '@/shared/utils/os'
|
||||
|
||||
type PdfZoomButtonsProps = {
|
||||
setZoom: (zoom: string) => void
|
||||
|
||||
@@ -14,8 +14,7 @@ import {
|
||||
DropdownToggle,
|
||||
} from '@/features/ui/components/bootstrap-5/dropdown-menu'
|
||||
import FormControl from '@/features/ui/components/bootstrap-5/form/form-control'
|
||||
|
||||
const isMac = /Mac/.test(window.navigator?.platform)
|
||||
import { isMac } from '@/shared/utils/os'
|
||||
|
||||
const shortcuts = isMac
|
||||
? {
|
||||
|
||||
@@ -18,8 +18,7 @@ import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/boots
|
||||
import MaterialIcon from '@/shared/components/material-icon'
|
||||
import OLOverlay from '@/features/ui/components/ol/ol-overlay'
|
||||
import OLPopover from '@/features/ui/components/ol/ol-popover'
|
||||
|
||||
const isMac = /Mac/.test(window.navigator?.platform)
|
||||
import { isMac } from '@/shared/utils/os'
|
||||
|
||||
export const PastedContentMenu: FC<{
|
||||
insertPastedContent: (
|
||||
|
||||
@@ -21,6 +21,7 @@ import { ChangeSpec } from '@codemirror/state'
|
||||
import { startCompileKeypress } from '@/features/pdf-preview/hooks/use-compile-triggers'
|
||||
import { useTabularContext } from './contexts/tabular-context'
|
||||
import { ColumnSizeIndicator } from './column-size-indicator'
|
||||
import { isMac } from '@/shared/utils/os'
|
||||
|
||||
type NavigationKey =
|
||||
| 'ArrowRight'
|
||||
@@ -38,7 +39,6 @@ type NavigationMap = {
|
||||
}
|
||||
}
|
||||
|
||||
const isMac = /Mac/.test(window.navigator?.platform)
|
||||
const MINIMUM_CELL_WIDTH_CHARACTERS = 15
|
||||
const MINIMUM_EDITING_CELL_WIDTH_CHARACTERS = 20
|
||||
const CELL_WIDTH_BUFFER = 3 // characters
|
||||
|
||||
@@ -13,8 +13,7 @@ import { TableInserterDropdown } from './table-inserter-dropdown'
|
||||
import { withinFormattingCommand } from '@/features/source-editor/utils/tree-operations/formatting'
|
||||
import { bsVersion } from '@/features/utils/bootstrap-5'
|
||||
import { isSplitTestEnabled } from '@/utils/splitTestUtils'
|
||||
|
||||
const isMac = /Mac/.test(window.navigator?.platform)
|
||||
import { isMac } from '@/shared/utils/os'
|
||||
|
||||
export const ToolbarItems: FC<{
|
||||
state: EditorState
|
||||
|
||||
1
services/web/frontend/js/shared/utils/os.ts
Normal file
1
services/web/frontend/js/shared/utils/os.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const isMac = /Mac/.test(window.navigator?.platform)
|
||||
@@ -3,7 +3,7 @@ import { EditorProviders } from '../../../helpers/editor-providers'
|
||||
import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor'
|
||||
import { mockScope } from '../helpers/mock-scope'
|
||||
import { TestContainer } from '../helpers/test-container'
|
||||
const isMac = /Mac/.test(window.navigator?.platform)
|
||||
import { isMac } from '@/shared/utils/os'
|
||||
|
||||
describe('Cursor and active line highlight', function () {
|
||||
const content = `line 1
|
||||
|
||||
@@ -3,8 +3,7 @@ import { EditorProviders } from '../../../helpers/editor-providers'
|
||||
import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor'
|
||||
import { mockScope } from '../helpers/mock-scope'
|
||||
import { TestContainer } from '../helpers/test-container'
|
||||
|
||||
const isMac = /Mac/.test(window.navigator?.platform)
|
||||
import { isMac } from '@/shared/utils/os'
|
||||
|
||||
const mountEditor = (content: string) => {
|
||||
const scope = mockScope(content)
|
||||
|
||||
@@ -3,8 +3,7 @@ import { EditorProviders } from '../../../helpers/editor-providers'
|
||||
import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor'
|
||||
import { mockScope } from '../helpers/mock-scope'
|
||||
import { TestContainer } from '../helpers/test-container'
|
||||
|
||||
const isMac = /Mac/.test(window.navigator?.platform)
|
||||
import { isMac } from '@/shared/utils/os'
|
||||
|
||||
const selectAll = () => {
|
||||
cy.get('.cm-content').trigger(
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
const isMac = /Mac/.test(window.navigator?.platform)
|
||||
import { isMac } from '@/shared/utils/os'
|
||||
|
||||
export const metaKey = isMac ? 'meta' : 'ctrl'
|
||||
|
||||
Reference in New Issue
Block a user