2018-11-01 02:51:56 +08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2020-05-26 04:00:13 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2021-04-01 19:14:24 +08:00
|
|
|
import browserInfo from '/imports/utils/browserInfo';
|
|
|
|
import deviceInfo from '/imports/utils/deviceInfo';
|
2022-02-15 23:54:55 +08:00
|
|
|
import Modal from '/imports/ui/components/common/modal/simple/component';
|
2018-05-01 03:18:29 +08:00
|
|
|
import _ from 'lodash';
|
2021-10-27 03:03:38 +08:00
|
|
|
import Styled from './styles';
|
2018-11-01 02:51:56 +08:00
|
|
|
import withShortcutHelper from './service';
|
2022-03-09 22:19:25 +08:00
|
|
|
import { isChatEnabled } from '/imports/ui/services/features';
|
2018-05-01 03:18:29 +08:00
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
title: {
|
|
|
|
id: 'app.shortcut-help.title',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'modal title label',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
|
|
|
closeLabel: {
|
|
|
|
id: 'app.shortcut-help.closeLabel',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'label for close button',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
|
|
|
closeDesc: {
|
|
|
|
id: 'app.shortcut-help.closeDesc',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'description for close button',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
2018-05-03 10:20:38 +08:00
|
|
|
accessKeyNotAvailable: {
|
|
|
|
id: 'app.shortcut-help.accessKeyNotAvailable',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'message shown in place of access key table if not supported',
|
2018-05-03 10:20:38 +08:00
|
|
|
},
|
|
|
|
comboLabel: {
|
|
|
|
id: 'app.shortcut-help.comboLabel',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'heading for key combo column',
|
2018-05-03 10:20:38 +08:00
|
|
|
},
|
|
|
|
functionLabel: {
|
|
|
|
id: 'app.shortcut-help.functionLabel',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'heading for shortcut function column',
|
2018-05-03 10:20:38 +08:00
|
|
|
},
|
2020-05-20 21:47:04 +08:00
|
|
|
openoptions: {
|
2018-05-01 03:18:29 +08:00
|
|
|
id: 'app.shortcut-help.openOptions',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the open options shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
2020-05-20 21:47:04 +08:00
|
|
|
toggleuserlist: {
|
2018-05-01 03:18:29 +08:00
|
|
|
id: 'app.shortcut-help.toggleUserList',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the toggle userlist shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
2020-05-20 21:47:04 +08:00
|
|
|
togglemute: {
|
2018-05-01 03:18:29 +08:00
|
|
|
id: 'app.shortcut-help.toggleMute',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the toggle mute shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
2020-05-20 21:47:04 +08:00
|
|
|
togglepublicchat: {
|
2018-05-01 03:18:29 +08:00
|
|
|
id: 'app.shortcut-help.togglePublicChat',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the toggle public chat shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
2020-05-20 21:47:04 +08:00
|
|
|
hideprivatechat: {
|
2018-05-01 03:18:29 +08:00
|
|
|
id: 'app.shortcut-help.hidePrivateChat',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the hide public chat shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
2020-05-20 21:47:04 +08:00
|
|
|
closeprivatechat: {
|
2018-05-01 03:18:29 +08:00
|
|
|
id: 'app.shortcut-help.closePrivateChat',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the close private chat shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
2020-05-20 21:47:04 +08:00
|
|
|
openactions: {
|
2018-05-01 03:18:29 +08:00
|
|
|
id: 'app.shortcut-help.openActions',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the open actions shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
2020-12-27 08:55:32 +08:00
|
|
|
opendebugwindow: {
|
|
|
|
id: 'app.shortcut-help.openDebugWindow',
|
|
|
|
description: 'describes the open debug window shortcut',
|
|
|
|
},
|
2020-05-20 21:47:04 +08:00
|
|
|
openstatus: {
|
2018-05-01 03:18:29 +08:00
|
|
|
id: 'app.shortcut-help.openStatus',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the open status shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
2020-05-20 21:47:04 +08:00
|
|
|
joinaudio: {
|
2018-05-01 03:18:29 +08:00
|
|
|
id: 'app.audio.joinAudio',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the join audio shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
2020-05-20 21:47:04 +08:00
|
|
|
leaveaudio: {
|
2018-05-01 03:18:29 +08:00
|
|
|
id: 'app.audio.leaveAudio',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the leave audio shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
2021-03-22 07:47:15 +08:00
|
|
|
raisehand: {
|
|
|
|
id: 'app.shortcut-help.raiseHand',
|
|
|
|
description: 'describes the toggle raise hand shortcut',
|
|
|
|
},
|
2019-04-12 08:08:14 +08:00
|
|
|
togglePan: {
|
|
|
|
id: 'app.shortcut-help.togglePan',
|
|
|
|
description: 'describes the toggle pan shortcut',
|
|
|
|
},
|
2020-10-08 07:06:42 +08:00
|
|
|
toggleFullscreen: {
|
|
|
|
id: 'app.shortcut-help.toggleFullscreen',
|
|
|
|
description: 'describes the toggle full-screen shortcut',
|
|
|
|
},
|
2019-04-13 11:48:21 +08:00
|
|
|
nextSlideDesc: {
|
|
|
|
id: 'app.shortcut-help.nextSlideDesc',
|
|
|
|
description: 'describes the next slide shortcut',
|
|
|
|
},
|
|
|
|
previousSlideDesc: {
|
|
|
|
id: 'app.shortcut-help.previousSlideDesc',
|
|
|
|
description: 'describes the previous slide shortcut',
|
|
|
|
},
|
2018-05-01 03:18:29 +08:00
|
|
|
});
|
|
|
|
|
2018-11-01 02:51:56 +08:00
|
|
|
const ShortcutHelpComponent = (props) => {
|
|
|
|
const { intl, shortcuts } = props;
|
2021-04-01 19:14:24 +08:00
|
|
|
const { browserName } = browserInfo;
|
|
|
|
const { isIos, isMacos } = deviceInfo;
|
2018-05-02 08:02:45 +08:00
|
|
|
|
2018-11-01 02:51:56 +08:00
|
|
|
let accessMod = null;
|
2018-05-01 03:18:29 +08:00
|
|
|
|
2020-04-14 23:20:48 +08:00
|
|
|
// different browsers use different access modifier keys
|
|
|
|
// on different systems when using accessKey property.
|
|
|
|
// Overview how different browsers behave: https://www.w3schools.com/jsref/prop_html_accesskey.asp
|
2021-04-01 19:14:24 +08:00
|
|
|
switch (browserName) {
|
|
|
|
case 'Chrome':
|
|
|
|
case 'Microsoft Edge':
|
2018-11-01 02:51:56 +08:00
|
|
|
accessMod = 'Alt';
|
|
|
|
break;
|
2021-04-01 19:14:24 +08:00
|
|
|
case 'Firefox':
|
2018-11-01 02:51:56 +08:00
|
|
|
accessMod = 'Alt + Shift';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2018-05-03 02:55:46 +08:00
|
|
|
|
2021-04-01 19:14:24 +08:00
|
|
|
// all Browsers on iOS are using Control + Alt as access modifier
|
|
|
|
if (isIos) {
|
|
|
|
accessMod = 'Control + Alt';
|
|
|
|
}
|
2020-04-14 23:20:48 +08:00
|
|
|
// all Browsers on MacOS are using Control + Option as access modifier
|
2021-04-01 19:14:24 +08:00
|
|
|
if (isMacos) {
|
2020-04-14 23:20:48 +08:00
|
|
|
accessMod = 'Control + Option';
|
|
|
|
}
|
|
|
|
|
2019-07-18 05:00:33 +08:00
|
|
|
const shortcutItems = shortcuts.map((shortcut) => {
|
2022-03-09 22:19:25 +08:00
|
|
|
if (!isChatEnabled() && shortcut.descId.indexOf('Chat') !== -1) return null;
|
2019-07-18 05:00:33 +08:00
|
|
|
return (
|
|
|
|
<tr key={_.uniqueId('hotkey-item-')}>
|
2021-10-27 03:03:38 +08:00
|
|
|
<Styled.KeyCell>{`${accessMod} + ${shortcut.accesskey}`}</Styled.KeyCell>
|
|
|
|
<Styled.DescCell>{`${intl.formatMessage(intlMessages[`${shortcut.descId.toLowerCase()}`])}`}</Styled.DescCell>
|
2019-07-18 05:00:33 +08:00
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
});
|
2019-04-12 08:08:14 +08:00
|
|
|
|
|
|
|
shortcutItems.push((
|
|
|
|
<tr key={_.uniqueId('hotkey-item-')}>
|
2021-10-27 03:03:38 +08:00
|
|
|
<Styled.KeyCell>Spacebar</Styled.KeyCell>
|
|
|
|
<Styled.DescCell>{intl.formatMessage(intlMessages.togglePan)}</Styled.DescCell>
|
2019-04-12 08:08:14 +08:00
|
|
|
</tr>
|
|
|
|
));
|
|
|
|
|
2020-10-08 07:06:42 +08:00
|
|
|
shortcutItems.push((
|
|
|
|
<tr key={_.uniqueId('hotkey-item-')}>
|
2021-10-27 03:03:38 +08:00
|
|
|
<Styled.KeyCell>Enter</Styled.KeyCell>
|
|
|
|
<Styled.DescCell>{intl.formatMessage(intlMessages.toggleFullscreen)}</Styled.DescCell>
|
2020-10-08 07:06:42 +08:00
|
|
|
</tr>
|
|
|
|
));
|
2021-03-22 07:47:15 +08:00
|
|
|
|
2019-04-13 11:48:21 +08:00
|
|
|
shortcutItems.push((
|
|
|
|
<tr key={_.uniqueId('hotkey-item-')}>
|
2021-10-27 03:03:38 +08:00
|
|
|
<Styled.KeyCell>Right Arrow</Styled.KeyCell>
|
|
|
|
<Styled.DescCell>{intl.formatMessage(intlMessages.nextSlideDesc)}</Styled.DescCell>
|
2019-04-13 11:48:21 +08:00
|
|
|
</tr>
|
|
|
|
));
|
|
|
|
|
|
|
|
shortcutItems.push((
|
|
|
|
<tr key={_.uniqueId('hotkey-item-')}>
|
2021-10-27 03:03:38 +08:00
|
|
|
<Styled.KeyCell>Left Arrow</Styled.KeyCell>
|
|
|
|
<Styled.DescCell>{intl.formatMessage(intlMessages.previousSlideDesc)}</Styled.DescCell>
|
2019-04-13 11:48:21 +08:00
|
|
|
</tr>
|
|
|
|
));
|
|
|
|
|
2018-11-01 02:51:56 +08:00
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
title={intl.formatMessage(intlMessages.title)}
|
|
|
|
dismiss={{
|
|
|
|
label: intl.formatMessage(intlMessages.closeLabel),
|
|
|
|
description: intl.formatMessage(intlMessages.closeDesc),
|
|
|
|
}}
|
|
|
|
>
|
2019-04-12 08:08:14 +08:00
|
|
|
{!accessMod ? <p>{intl.formatMessage(intlMessages.accessKeyNotAvailable)}</p>
|
|
|
|
: (
|
|
|
|
<span>
|
2021-10-27 03:03:38 +08:00
|
|
|
<Styled.ShortcutTable>
|
2019-04-12 08:08:14 +08:00
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<th>{intl.formatMessage(intlMessages.comboLabel)}</th>
|
|
|
|
<th>{intl.formatMessage(intlMessages.functionLabel)}</th>
|
|
|
|
</tr>
|
|
|
|
{shortcutItems}
|
|
|
|
</tbody>
|
2021-10-27 03:03:38 +08:00
|
|
|
</Styled.ShortcutTable>
|
2019-04-12 08:08:14 +08:00
|
|
|
</span>
|
|
|
|
)
|
2018-11-01 02:51:56 +08:00
|
|
|
}
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
ShortcutHelpComponent.defaultProps = {
|
2020-05-26 04:00:13 +08:00
|
|
|
intl: {},
|
2018-11-01 02:51:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
ShortcutHelpComponent.propTypes = {
|
2020-05-26 04:00:13 +08:00
|
|
|
intl: PropTypes.object.isRequired,
|
2018-11-01 02:51:56 +08:00
|
|
|
shortcuts: PropTypes.arrayOf(PropTypes.shape({
|
|
|
|
accesskey: PropTypes.string.isRequired,
|
|
|
|
descId: PropTypes.string.isRequired,
|
|
|
|
})).isRequired,
|
|
|
|
};
|
2018-05-01 03:18:29 +08:00
|
|
|
|
2018-11-01 02:51:56 +08:00
|
|
|
export default withShortcutHelper(injectIntl(ShortcutHelpComponent));
|