2020-12-10 06:13:59 -05:00
|
|
|
import PropTypes from 'prop-types'
|
2021-03-05 08:00:28 -05:00
|
|
|
import { Trans, useTranslation } from 'react-i18next'
|
2022-11-24 09:26:38 -05:00
|
|
|
import HotkeysModalBottomText from './hotkeys-modal-bottom-text'
|
2024-10-11 05:22:38 -04:00
|
|
|
import OLModal, {
|
|
|
|
OLModalBody,
|
|
|
|
OLModalFooter,
|
|
|
|
OLModalHeader,
|
|
|
|
OLModalTitle,
|
|
|
|
} from '@/features/ui/components/ol/ol-modal'
|
|
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
|
|
|
import OLRow from '@/features/ui/components/ol/ol-row'
|
|
|
|
import OLCol from '@/features/ui/components/ol/ol-col'
|
2020-12-10 06:13:59 -05:00
|
|
|
|
2021-03-05 08:00:28 -05:00
|
|
|
export default function HotkeysModal({
|
|
|
|
animation = true,
|
|
|
|
handleHide,
|
|
|
|
show,
|
|
|
|
isMac = false,
|
2021-04-27 03:52:58 -04:00
|
|
|
trackChangesVisible = false,
|
2021-03-05 08:00:28 -05:00
|
|
|
}) {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
const ctrl = isMac ? 'Cmd' : 'Ctrl'
|
2020-12-10 06:13:59 -05:00
|
|
|
|
|
|
|
return (
|
2024-10-11 05:22:38 -04:00
|
|
|
<OLModal size="lg" onHide={handleHide} show={show} animation={animation}>
|
|
|
|
<OLModalHeader closeButton>
|
|
|
|
<OLModalTitle>{t('hotkeys')}</OLModalTitle>
|
|
|
|
</OLModalHeader>
|
|
|
|
|
|
|
|
<OLModalBody className="hotkeys-modal">
|
2021-03-05 08:00:28 -05:00
|
|
|
<h3>{t('common')}</h3>
|
|
|
|
|
2024-10-11 05:22:38 -04:00
|
|
|
<OLRow>
|
|
|
|
<OLCol xs={4}>
|
2021-03-05 08:00:28 -05:00
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + F`}
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_find_and_replace')}
|
|
|
|
/>
|
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + Enter`}
|
|
|
|
description={t('hotkey_compile')}
|
2021-03-05 08:00:28 -05:00
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
<OLCol xs={4}>
|
2021-05-07 09:20:55 -04:00
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + Z`}
|
|
|
|
description={t('hotkey_undo')}
|
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
<OLCol xs={4}>
|
2021-05-07 09:20:55 -04:00
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + Y`}
|
|
|
|
description={t('hotkey_redo')}
|
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
</OLRow>
|
2021-03-05 08:00:28 -05:00
|
|
|
|
|
|
|
<h3>{t('navigation')}</h3>
|
|
|
|
|
2024-10-11 05:22:38 -04:00
|
|
|
<OLRow>
|
|
|
|
<OLCol xs={4}>
|
2021-03-05 08:00:28 -05:00
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + Home`}
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_beginning_of_document')}
|
2021-03-05 08:00:28 -05:00
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
<OLCol xs={4}>
|
2021-03-05 08:00:28 -05:00
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + End`}
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_end_of_document')}
|
2021-03-05 08:00:28 -05:00
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
<OLCol xs={4}>
|
2021-05-07 09:20:55 -04:00
|
|
|
<Hotkey
|
2023-11-28 06:20:24 -05:00
|
|
|
combination={`${ctrl} + Shift + L`}
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_go_to_line')}
|
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
</OLRow>
|
2021-03-05 08:00:28 -05:00
|
|
|
|
|
|
|
<h3>{t('editing')}</h3>
|
|
|
|
|
2024-10-11 05:22:38 -04:00
|
|
|
<OLRow>
|
|
|
|
<OLCol xs={4}>
|
2021-05-07 09:20:55 -04:00
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + /`}
|
|
|
|
description={t('hotkey_toggle_comment')}
|
|
|
|
/>
|
2021-03-05 08:00:28 -05:00
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + D`}
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_delete_current_line')}
|
|
|
|
/>
|
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + A`}
|
|
|
|
description={t('hotkey_select_all')}
|
2021-03-05 08:00:28 -05:00
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
2021-03-05 08:00:28 -05:00
|
|
|
|
2024-10-11 05:22:38 -04:00
|
|
|
<OLCol xs={4}>
|
2021-05-07 09:20:55 -04:00
|
|
|
<Hotkey
|
2021-12-10 05:03:52 -05:00
|
|
|
combination="Ctrl + U"
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_to_uppercase')}
|
|
|
|
/>
|
2021-03-05 08:00:28 -05:00
|
|
|
<Hotkey
|
2021-12-10 05:03:52 -05:00
|
|
|
combination="Ctrl + Shift + U"
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_to_lowercase')}
|
|
|
|
/>
|
|
|
|
<Hotkey
|
|
|
|
combination="Tab"
|
|
|
|
description={t('hotkey_indent_selection')}
|
2021-03-05 08:00:28 -05:00
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
2021-03-05 08:00:28 -05:00
|
|
|
|
2024-10-11 05:22:38 -04:00
|
|
|
<OLCol xs={4}>
|
2021-05-07 09:20:55 -04:00
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + B`}
|
|
|
|
description={t('hotkey_bold_text')}
|
|
|
|
/>
|
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + I`}
|
|
|
|
description={t('hotkey_italic_text')}
|
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
</OLRow>
|
2021-03-05 08:00:28 -05:00
|
|
|
|
|
|
|
<h3>{t('autocomplete')}</h3>
|
|
|
|
|
2024-10-11 05:22:38 -04:00
|
|
|
<OLRow>
|
|
|
|
<OLCol xs={4}>
|
2021-03-05 08:00:28 -05:00
|
|
|
<Hotkey
|
2021-12-10 05:03:52 -05:00
|
|
|
combination="Ctrl + Space"
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_autocomplete_menu')}
|
2021-03-05 08:00:28 -05:00
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
<OLCol xs={4}>
|
2021-03-05 08:00:28 -05:00
|
|
|
<Hotkey
|
2023-04-14 04:57:39 -04:00
|
|
|
combination="Up / Down"
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_select_candidate')}
|
2021-03-05 08:00:28 -05:00
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
<OLCol xs={4}>
|
2021-05-07 09:20:55 -04:00
|
|
|
<Hotkey
|
2023-04-14 04:57:39 -04:00
|
|
|
combination="Enter / Tab"
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_insert_candidate')}
|
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
</OLRow>
|
2021-03-05 08:00:28 -05:00
|
|
|
|
|
|
|
<h3>
|
|
|
|
<Trans
|
|
|
|
i18nKey="autocomplete_references"
|
|
|
|
components={{ code: <code /> }}
|
|
|
|
/>
|
|
|
|
</h3>
|
|
|
|
|
2024-10-11 05:22:38 -04:00
|
|
|
<OLRow>
|
|
|
|
<OLCol xs={4}>
|
2021-03-05 08:00:28 -05:00
|
|
|
<Hotkey
|
2021-12-10 05:03:52 -05:00
|
|
|
combination={`Ctrl + Space `}
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_search_references')}
|
2021-03-05 08:00:28 -05:00
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
</OLRow>
|
2021-03-05 08:00:28 -05:00
|
|
|
|
|
|
|
{trackChangesVisible && (
|
|
|
|
<>
|
|
|
|
<h3>{t('review')}</h3>
|
|
|
|
|
2024-10-11 05:22:38 -04:00
|
|
|
<OLRow>
|
|
|
|
<OLCol xs={4}>
|
2021-03-05 08:00:28 -05:00
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + J`}
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_toggle_review_panel')}
|
2021-03-05 08:00:28 -05:00
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
<OLCol xs={4}>
|
2021-03-05 08:00:28 -05:00
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + Shift + A`}
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_toggle_track_changes')}
|
2021-03-05 08:00:28 -05:00
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
<OLCol xs={4}>
|
2021-03-05 08:00:28 -05:00
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + Shift + C`}
|
2021-05-07 09:20:55 -04:00
|
|
|
description={t('hotkey_add_a_comment')}
|
2021-03-05 08:00:28 -05:00
|
|
|
/>
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLCol>
|
|
|
|
</OLRow>
|
2021-03-05 08:00:28 -05:00
|
|
|
</>
|
|
|
|
)}
|
2022-11-24 09:26:38 -05:00
|
|
|
<HotkeysModalBottomText />
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLModalBody>
|
2021-03-05 08:00:28 -05:00
|
|
|
|
2024-10-11 05:22:38 -04:00
|
|
|
<OLModalFooter>
|
|
|
|
<OLButton variant="secondary" onClick={handleHide}>
|
2024-04-04 10:14:09 -04:00
|
|
|
{t('close')}
|
2024-10-11 05:22:38 -04:00
|
|
|
</OLButton>
|
|
|
|
</OLModalFooter>
|
|
|
|
</OLModal>
|
2020-12-10 06:13:59 -05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
HotkeysModal.propTypes = {
|
2021-03-05 08:00:28 -05:00
|
|
|
animation: PropTypes.bool,
|
|
|
|
isMac: PropTypes.bool,
|
2020-12-10 06:13:59 -05:00
|
|
|
show: PropTypes.bool.isRequired,
|
2021-03-05 08:00:28 -05:00
|
|
|
handleHide: PropTypes.func.isRequired,
|
2021-04-27 03:52:58 -04:00
|
|
|
trackChangesVisible: PropTypes.bool,
|
2020-12-10 06:13:59 -05:00
|
|
|
}
|
|
|
|
|
2021-03-05 08:00:28 -05:00
|
|
|
function Hotkey({ combination, description }) {
|
|
|
|
return (
|
|
|
|
<div className="hotkey" data-test-selector="hotkey">
|
|
|
|
<span className="combination">{combination}</span>
|
|
|
|
<span className="description">{description}</span>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
Hotkey.propTypes = {
|
|
|
|
combination: PropTypes.string.isRequired,
|
2021-04-27 03:52:58 -04:00
|
|
|
description: PropTypes.string.isRequired,
|
2021-03-05 08:00:28 -05:00
|
|
|
}
|