/**
* External dependencies
*/
import classnames from 'classnames'
import { isString } from 'lodash'
/**
* WordPress dependencies
*/
import { Modal } from '@wordpress/components'
import { __ } from 'ct-i18n'
import {
useShortcut,
store as keyboardShortcutsStore,
} from '@wordpress/keyboard-shortcuts'
import { useDispatch, useSelect } from '@wordpress/data'
import { createElement } from '@wordpress/element'
/**
* Internal dependencies
*/
import { textFormattingShortcuts } from './config'
import Shortcut from './shortcut'
import DynamicShortcut from './dynamic-shortcut'
const ShortcutList = ({ shortcuts }) => (
/*
* Disable reason: The `list` ARIA role is redundant but
* Safari+VoiceOver won't announce the list otherwise.
*/
/* eslint-disable jsx-a11y/no-redundant-roles */
{shortcuts.map((shortcut, index) => (
-
{isString(shortcut) ? (
) : (
)}
))}
/* eslint-enable jsx-a11y/no-redundant-roles */
)
const ShortcutSection = ({ title, shortcuts, className }) => (
)
const ShortcutCategorySection = ({
title,
categoryName,
additionalShortcuts = [],
}) => {
const categoryShortcuts = useSelect(
(select) => {
return select(keyboardShortcutsStore).getCategoryShortcuts(
categoryName
)
},
[categoryName]
)
return (
)
}
export default function KeyboardShortcutHelpModal({
isModalActive,
toggleModal,
}) {
const { registerShortcut } = useDispatch(keyboardShortcutsStore)
registerShortcut({
name: 'core/customize-widgets/keyboard-shortcuts',
category: 'main',
description: __('Display these keyboard shortcuts.'),
keyCombination: {
modifier: 'access',
character: 'h',
},
})
useShortcut('core/customize-widgets/keyboard-shortcuts', toggleModal)
if (!isModalActive) {
return null
}
return (
)
}