import { Fragment, useState } from 'react'; import { CodeEditor, Language } from '@patternfly/react-code-editor'; import { Grid, GridItem, Label, Radio } from '@patternfly/react-core'; export const CodeEditorShortcutMainHeader: React.FunctionComponent = () => { type ShortcutMode = 'PC' | 'Mac'; const [currentShortcutMode, setCurrentShortcutMode] = useState('PC'); const onEditorDidMount = (editor, monaco) => { editor.layout(); editor.focus(); monaco.editor.getModels()[0].updateOptions({ tabSize: 5 }); }; const onChange = (value: string) => { // eslint-disable-next-line no-console console.log(value); }; const onShortcutModeChange = (event: React.FormEvent, checked: boolean) => { if (checked) { const newMode = event.currentTarget.value as ShortcutMode; setCurrentShortcutMode(newMode); } }; const shortcuts = [ { PC: ['Alt', 'F1'], Mac: ['Opt', 'F1'], description: 'Accessibility helps' }, { PC: ['F1'], Mac: ['F1'], description: 'View all editor shortcuts' }, { PC: ['Ctrl', 'Space'], Mac: ['Opt', 'Esc'], description: 'Activate auto complete' }, { PC: ['Ctrl', 'S'], Mac: ['Cmd', 'S'], description: 'Save' } ]; const shortcutsPopoverProps = { bodyContent: ( {shortcuts.map((shortcut, index) => ( {shortcut[currentShortcutMode] .map((key) => ( )) .reduce((prev, curr) => ( <>{[prev, ' + ', curr]} ))} {shortcut.description} ))} ), 'aria-label': 'Shortcuts' }; return ( <> ); };