2021-03-05 08:00:28 -05:00
|
|
|
import { Button, Modal, Row, Col } from 'react-bootstrap'
|
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'
|
|
|
|
import AccessibleModal from '../../../shared/components/accessible-modal'
|
2022-11-24 09:26:38 -05:00
|
|
|
import HotkeysModalBottomText from './hotkeys-modal-bottom-text'
|
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 (
|
2021-03-05 08:00:28 -05:00
|
|
|
<AccessibleModal
|
|
|
|
bsSize="large"
|
|
|
|
onHide={handleHide}
|
|
|
|
show={show}
|
|
|
|
animation={animation}
|
|
|
|
>
|
|
|
|
<Modal.Header closeButton>
|
2024-04-04 10:14:09 -04:00
|
|
|
<Modal.Title>{t('hotkeys')}</Modal.Title>
|
2021-03-05 08:00:28 -05:00
|
|
|
</Modal.Header>
|
|
|
|
|
2022-11-24 09:26:38 -05:00
|
|
|
<Modal.Body className="hotkeys-modal">
|
2021-03-05 08:00:28 -05:00
|
|
|
<h3>{t('common')}</h3>
|
|
|
|
|
|
|
|
<Row>
|
|
|
|
<Col xs={4}>
|
|
|
|
<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
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
<Col xs={4}>
|
2021-05-07 09:20:55 -04:00
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + Z`}
|
|
|
|
description={t('hotkey_undo')}
|
|
|
|
/>
|
2021-03-05 08:00:28 -05:00
|
|
|
</Col>
|
|
|
|
<Col xs={4}>
|
2021-05-07 09:20:55 -04:00
|
|
|
<Hotkey
|
|
|
|
combination={`${ctrl} + Y`}
|
|
|
|
description={t('hotkey_redo')}
|
|
|
|
/>
|
2021-03-05 08:00:28 -05:00
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
<h3>{t('navigation')}</h3>
|
|
|
|
|
|
|
|
<Row>
|
|
|
|
<Col xs={4}>
|
|
|
|
<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
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
<Col xs={4}>
|
|
|
|
<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
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
<Col 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')}
|
|
|
|
/>
|
2021-03-05 08:00:28 -05:00
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
<h3>{t('editing')}</h3>
|
|
|
|
|
|
|
|
<Row>
|
|
|
|
<Col 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
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
<Col 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
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
<Col 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')}
|
|
|
|
/>
|
2021-03-05 08:00:28 -05:00
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
<h3>{t('autocomplete')}</h3>
|
|
|
|
|
|
|
|
<Row>
|
|
|
|
<Col xs={4}>
|
|
|
|
<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
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
<Col xs={4}>
|
|
|
|
<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
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
<Col 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')}
|
|
|
|
/>
|
2021-03-05 08:00:28 -05:00
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
<h3>
|
|
|
|
<Trans
|
|
|
|
i18nKey="autocomplete_references"
|
|
|
|
components={{ code: <code /> }}
|
|
|
|
/>
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
<Row>
|
|
|
|
<Col xs={4}>
|
|
|
|
<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
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
{trackChangesVisible && (
|
|
|
|
<>
|
|
|
|
<h3>{t('review')}</h3>
|
|
|
|
|
|
|
|
<Row>
|
|
|
|
<Col xs={4}>
|
|
|
|
<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
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
<Col xs={4}>
|
|
|
|
<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
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
<Col xs={4}>
|
|
|
|
<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
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</>
|
|
|
|
)}
|
2022-11-24 09:26:38 -05:00
|
|
|
<HotkeysModalBottomText />
|
2021-03-05 08:00:28 -05:00
|
|
|
</Modal.Body>
|
|
|
|
|
|
|
|
<Modal.Footer>
|
2022-12-07 05:51:44 -05:00
|
|
|
<Button bsStyle={null} className="btn-secondary" onClick={handleHide}>
|
2024-04-04 10:14:09 -04:00
|
|
|
{t('close')}
|
2022-12-07 05:51:44 -05:00
|
|
|
</Button>
|
2021-03-05 08:00:28 -05:00
|
|
|
</Modal.Footer>
|
|
|
|
</AccessibleModal>
|
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
|
|
|
}
|