bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/shortcut-help/component.jsx

458 lines
16 KiB
React
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl } from 'react-intl';
import browserInfo from '/imports/utils/browserInfo';
import deviceInfo from '/imports/utils/deviceInfo';
import ModalSimple from '/imports/ui/components/common/modal/simple/component';
2021-10-27 03:03:38 +08:00
import Styled from './styles';
import StyledSettings from '../settings/styles';
import withShortcutHelper from './service';
2024-06-14 21:30:48 +08:00
import { useIsChatEnabled } from '/imports/ui/services/features';
2023-02-23 22:23:51 +08:00
import { uniqueId } from '/imports/utils/string-utils';
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
},
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',
},
comboLabel: {
id: 'app.shortcut-help.comboLabel',
2018-05-03 11:33:28 +08:00
description: 'heading for key combo column',
},
alternativeLabel: {
id: 'app.shortcut-help.alternativeLabel',
description: 'heading for key alternatives column',
},
functionLabel: {
id: 'app.shortcut-help.functionLabel',
2018-05-03 11:33:28 +08:00
description: 'heading for shortcut function column',
},
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
},
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
},
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
},
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
},
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
},
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
},
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',
},
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
},
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
},
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',
},
nextSlideDesc: {
id: 'app.shortcut-help.nextSlideDesc',
description: 'describes the next slide shortcut',
},
previousSlideDesc: {
id: 'app.shortcut-help.previousSlideDesc',
description: 'describes the previous slide shortcut',
},
2022-04-13 00:49:10 +08:00
togglePanKey: {
id: 'app.shortcut-help.togglePanKey',
description: 'describes the toggle pan shortcut key',
},
toggleFullscreenKey: {
id: 'app.shortcut-help.toggleFullscreenKey',
description: 'describes the toggle full-screen shortcut key',
},
nextSlideKey: {
id: 'app.shortcut-help.nextSlideKey',
description: 'describes the next slide shortcut key',
},
previousSlideKey: {
id: 'app.shortcut-help.previousSlideKey',
description: 'describes the previous slide shortcut key',
},
select: {
id: 'app.shortcut-help.select',
description: 'describes the selection tool shortcut key',
},
pencil: {
id: 'app.shortcut-help.pencil',
description: 'describes the pencil tool shortcut key',
},
eraser: {
id: 'app.shortcut-help.eraser',
description: 'describes the eraser tool shortcut key',
},
rectangle: {
id: 'app.shortcut-help.rectangle',
description: 'describes the rectangle shape tool shortcut key',
},
elipse: {
id: 'app.shortcut-help.elipse',
description: 'describes the elipse shape tool shortcut key',
},
triangle: {
id: 'app.shortcut-help.triangle',
description: 'describes the triangle shape tool shortcut key',
},
line: {
id: 'app.shortcut-help.line',
description: 'describes the line shape tool shortcut key',
},
arrow: {
id: 'app.shortcut-help.arrow',
description: 'describes the arrow shape tool shortcut key',
},
text: {
id: 'app.shortcut-help.text',
description: 'describes the text tool shortcut key',
},
note: {
id: 'app.shortcut-help.note',
description: 'describes the sticky note shortcut key',
},
2022-08-02 19:43:29 +08:00
general: {
id: 'app.shortcut-help.general',
description: 'general tab heading',
},
presentation: {
id: 'app.shortcut-help.presentation',
description: 'presentation tab heading',
},
whiteboard: {
id: 'app.shortcut-help.whiteboard',
description: 'whiteboard tab heading',
2022-08-09 19:45:46 +08:00
},
zoomIn: {
id: 'app.shortcut-help.zoomIn',
description: 'describes the zoom in shortcut key',
},
zoomOut: {
id: 'app.shortcut-help.zoomOut',
description: 'describes the zoom out shortcut key',
},
zoomFit: {
id: 'app.shortcut-help.zoomFit',
description: 'describes the zoom to fit shortcut key',
},
zoomSelect: {
id: 'app.shortcut-help.zoomSelect',
description: 'describes the zoom to selection shortcut key',
},
flipH: {
id: 'app.shortcut-help.flipH',
description: 'describes the flip horozontally shortcut key',
},
flipV: {
id: 'app.shortcut-help.flipV',
description: 'describes the flip vertically shortcut key',
},
lock: {
id: 'app.shortcut-help.lock',
description: 'describes the lock / unlock shape shortcut key',
},
moveToFront: {
id: 'app.shortcut-help.moveToFront',
description: 'describes the move to front shortcut key',
},
moveToBack: {
id: 'app.shortcut-help.moveToBack',
description: 'describes the move to back shortcut key',
},
moveForward: {
id: 'app.shortcut-help.moveForward',
description: 'describes the move forward shortcut key',
},
moveBackward: {
id: 'app.shortcut-help.moveBackward',
description: 'describes the move backward shortcut key',
},
undo: {
id: 'app.shortcut-help.undo',
description: 'describes the undo shortcut key',
},
redo: {
id: 'app.shortcut-help.redo',
description: 'describes the redo shortcut key',
},
cut: {
id: 'app.shortcut-help.cut',
description: 'describes the cut shortcut key',
},
copy: {
id: 'app.shortcut-help.copy',
description: 'describes the cut shortcut key',
},
paste: {
id: 'app.shortcut-help.paste',
description: 'describes the paste shortcut key',
},
selectAll: {
id: 'app.shortcut-help.selectAll',
description: 'describes the select all shortcut key',
},
delete: {
id: 'app.shortcut-help.delete',
description: 'describes the delete shortcut key',
},
duplicate: {
id: 'app.shortcut-help.duplicate',
description: 'describes the duplicate shortcut key',
2022-08-02 19:43:29 +08:00
}
2018-05-01 03:18:29 +08:00
});
2022-08-09 19:45:46 +08:00
const renderItem = (func, key) => {
return (
2023-02-23 22:23:51 +08:00
<tr key={uniqueId('hotkey-item-')}>
<Styled.DescCell>{func}</Styled.DescCell>
<Styled.KeyCell>{key}</Styled.KeyCell>
</tr>
);
}
const renderItemWhiteBoard = (func, key, alt) => {
return (
2023-02-23 22:23:51 +08:00
<tr key={uniqueId('hotkey-item-')}>
<Styled.DescCell>{func}</Styled.DescCell>
<Styled.KeyCell>{key}</Styled.KeyCell>
<Styled.KeyCell>{alt}</Styled.KeyCell>
</tr>
);
}
2024-06-11 21:05:08 +08:00
const ShortcutHelpComponent = ({
intl = {},
shortcuts,
isOpen,
onRequestClose,
priority,
}) => {
const { browserName } = browserInfo;
const { isIos, isMacos } = deviceInfo;
const [ selectedTab, setSelectedTab] = React.useState(0);
2024-06-14 21:30:48 +08:00
const isChatEnabled = useIsChatEnabled();
2018-05-02 08:02:45 +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
switch (browserName) {
case 'Chrome':
case 'Microsoft Edge':
accessMod = 'Alt';
break;
case 'Firefox':
accessMod = 'Alt + Shift';
break;
default:
break;
}
// 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
if (isMacos) {
2020-04-14 23:20:48 +08:00
accessMod = 'Control + Option';
}
const generalShortcutItems = shortcuts.map((shortcut) => {
2024-06-14 21:30:48 +08:00
if (!isChatEnabled && shortcut.descId.indexOf('Chat') !== -1) return null;
return renderItem(
`${intl.formatMessage(intlMessages[`${shortcut.descId.toLowerCase()}`])}`,
`${accessMod} + ${shortcut.accesskey}`
);
});
2019-04-12 08:08:14 +08:00
const shortcutItems = [];
shortcutItems.push(renderItem(intl.formatMessage(intlMessages.togglePan),
intl.formatMessage(intlMessages.togglePanKey)));
shortcutItems.push(renderItem(intl.formatMessage(intlMessages.toggleFullscreen),
intl.formatMessage(intlMessages.toggleFullscreenKey)));
shortcutItems.push(renderItem(intl.formatMessage(intlMessages.nextSlideDesc),
intl.formatMessage(intlMessages.nextSlideKey)));
shortcutItems.push(renderItem(intl.formatMessage(intlMessages.previousSlideDesc),
intl.formatMessage(intlMessages.previousSlideKey)));
const whiteboardShortcutItems = [];
2022-08-09 19:45:46 +08:00
//tools
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.select), '1', 'V'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.pencil), '2', 'D, P'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.eraser), '3', 'E'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.rectangle), '4', 'R'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.elipse), '5', 'O'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.triangle), '6', 'G'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.line), '7', 'L'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.arrow), '8', 'A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.text), '9', 'T'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.note), '0', 'S'));
2022-08-09 19:45:46 +08:00
//views
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.zoomIn), 'Ctrl +', 'Ctrl M. Wheel up'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.zoomOut), 'Ctrl -', 'Ctrl M. Wheel down'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.zoomFit), 'Shift 1', 'N/A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.zoomSelect), 'Shift 2', 'N/A'));
2022-08-09 19:45:46 +08:00
//transform
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.flipH), 'Shift H', 'N/A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.flipV), 'Shift V', 'N/A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.lock), 'Ctrl Shift L', 'N/A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.moveToFront), 'Shift ]', 'N/A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.moveForward), ']', 'N/A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.moveBackward), '[', 'N/A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.moveToBack), 'Shift [', 'N/A'));
2022-08-09 19:45:46 +08:00
//edit
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.undo), 'Ctrl Z', 'N/A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.redo), 'Ctrl Shift Z', 'N/A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.cut), 'Ctrl X', 'N/A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.copy), 'Ctrl C', 'N/A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.paste), 'Ctrl V', 'N/A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.selectAll), 'Ctrl A', 'N/A'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.delete), 'Del', 'Backspace'));
whiteboardShortcutItems.push(renderItemWhiteBoard(intl.formatMessage(intlMessages.duplicate), 'Ctrl D', 'N/A'));
return (
<ModalSimple
contentLabel={intl.formatMessage(intlMessages.title)}
dismiss={{
label: intl.formatMessage(intlMessages.closeLabel),
description: intl.formatMessage(intlMessages.closeDesc),
}}
title={intl.formatMessage(intlMessages.title)}
{...{
isOpen,
onRequestClose,
priority,
}}
>
<Styled.SettingsTabs
onSelect={(tab) => setSelectedTab(tab)}
selectedIndex={selectedTab}
role="presentation"
>
<StyledSettings.SettingsTabList>
<StyledSettings.SettingsTabSelector selectedClassName="is-selected">
<StyledSettings.SettingsIcon iconName="application" />
2022-08-02 19:43:29 +08:00
<span id="appicationTab">{intl.formatMessage(intlMessages.general)}</span>
</StyledSettings.SettingsTabSelector>
<StyledSettings.SettingsTabSelector selectedClassName="is-selected">
2022-08-02 23:33:33 +08:00
<StyledSettings.SettingsIcon iconName="presentation" />
2022-08-02 19:43:29 +08:00
<span id="presentationTab">{intl.formatMessage(intlMessages.presentation)}</span>
</StyledSettings.SettingsTabSelector>
<StyledSettings.SettingsTabSelector selectedClassName="is-selected">
2022-08-02 23:33:33 +08:00
<StyledSettings.SettingsIcon iconName="whiteboard" />
2022-08-02 19:43:29 +08:00
<span id="whiteboardTab">{intl.formatMessage(intlMessages.whiteboard)}</span>
</StyledSettings.SettingsTabSelector>
</StyledSettings.SettingsTabList>
2022-10-19 03:25:23 +08:00
<Styled.TabPanel selectedClassName="is-selected">
{!accessMod ? <p>{intl.formatMessage(intlMessages.accessKeyNotAvailable)}</p>
: (
2022-10-19 02:39:28 +08:00
<Styled.TableWrapper>
<Styled.ShortcutTable>
<tbody>
<tr>
<th>{intl.formatMessage(intlMessages.functionLabel)}</th>
<th>{intl.formatMessage(intlMessages.comboLabel)}</th>
</tr>
{generalShortcutItems}
</tbody>
</Styled.ShortcutTable>
2022-10-19 02:39:28 +08:00
</Styled.TableWrapper>
)
}
2022-10-19 03:25:23 +08:00
</Styled.TabPanel>
<Styled.TabPanel selectedClassName="is-selected">
2022-10-19 02:39:28 +08:00
<Styled.TableWrapper>
<Styled.ShortcutTable>
2019-04-12 08:08:14 +08:00
<tbody>
<tr>
<th>{intl.formatMessage(intlMessages.functionLabel)}</th>
<th>{intl.formatMessage(intlMessages.comboLabel)}</th>
2019-04-12 08:08:14 +08:00
</tr>
{shortcutItems}
</tbody>
2021-10-27 03:03:38 +08:00
</Styled.ShortcutTable>
2022-10-19 02:39:28 +08:00
</Styled.TableWrapper>
2022-10-19 03:25:23 +08:00
</Styled.TabPanel>
<Styled.TabPanel selectedClassName="is-selected">
2022-10-19 02:39:28 +08:00
<Styled.TableWrapper>
<Styled.ShortcutTable>
<tbody>
<tr>
<th>{intl.formatMessage(intlMessages.functionLabel)}</th>
<th>{intl.formatMessage(intlMessages.comboLabel)}</th>
<th>{intl.formatMessage(intlMessages.alternativeLabel)}</th>
</tr>
{whiteboardShortcutItems}
</tbody>
</Styled.ShortcutTable>
2022-10-19 02:39:28 +08:00
</Styled.TableWrapper>
2022-10-19 03:25:23 +08:00
</Styled.TabPanel>
</Styled.SettingsTabs>
</ModalSimple>
);
};
ShortcutHelpComponent.propTypes = {
intl: PropTypes.object.isRequired,
shortcuts: PropTypes.arrayOf(PropTypes.shape({
accesskey: PropTypes.string.isRequired,
descId: PropTypes.string.isRequired,
})).isRequired,
};
2018-05-01 03:18:29 +08:00
export default withShortcutHelper(injectIntl(ShortcutHelpComponent));