命名空间:核心/键盘快捷方式
.
返回包含给定快捷方式名称别名的快捷方式。
用法
从“@wordpress/keyboard-shortcuts”导入{store as keyboardShortcutsStore};从“@wordpress/data”导入{useSelect};从“@wordpress/element”导入{createInterpolateElement};从“@wordpress/i18n”导入{sprintf};常量示例组件=()=>{const allShortcutKeyCombinations=使用选择((选择)=>选择(keyboardShortcutsStore).getAllShortcutKeyCombinations('核心/编辑器/下一区域'),[]);返回(allShortcutKeyCombinations.length>0&&(<ul>{所有快捷键组合.map(({字符,修饰符},索引)=>(<li键={index}>{创建InterpolateElement(冲刺('字符:<code>%s</code>/Modifier:<code>%s</ccode>',字符,修改器),{代码:<code/>,}) }</li>)) }</ul>));};
参数
- 状态
对象
:全局状态。
- 名称
一串
:快捷方式名称。
退换商品
返回给定快捷方式名称的所有键盘组合的原始表示形式。
用法
从“@wordpress/keyboard-shortcuts”导入{store as keyboardShortcutsStore};从“@wordpress/data”导入{useSelect};从“@wordpress/element”导入{createInterpolateElement};从“@wordpress/i18n”导入{sprintf};常量示例组件=()=>{const allShortcutRawKeyCombinations=使用选择((选择)=>选择(keyboardShortcutsStore).getAllShortcutRawKeyCombinations('核心/编辑器/下一区域'),[]);返回(allShortcutRawKeyCombinations.length>0&&(<ul>{所有快捷键RawKeyCombinations.map((快捷键组合,索引)=>(<li键={index}>{创建InterpolateElement(冲刺(“<code>%s</code>”,快捷键原始键组合),{代码:<code/>,}) }</li>)) }</ul>));};
参数
- 状态
对象
:全局状态。
- 名称
一串
:快捷方式名称。
退换商品
返回给定类别名称的快捷方式名称列表。
用法
从“@wordpress/keyboard-shortcuts”导入{store as keyboardShortcutsStore};从“@wordpress/data”导入{useSelect};常量示例组件=()=>{const categoryShortcuts=使用选择((选择)=>select(keyboardShortcutsStore).getCategoryShortcuts(“块”),[]);返回(categoryShortcuts.length>0&&类别快捷方式长度(<ul>{categoryShortcuts.map((categoryShortcut)=>(<li key={categoryShortcut}>{categaryShortcut\}</li>) ) }</ul>));};
参数
退换商品
返回给定快捷方式名称的别名。
用法
从“@wordpress/keyboard-shortcuts”导入{store as keyboardShortcutsStore};从“@wordpress/data”导入{useSelect};从“@wordpress/element”导入{createInterpolateElement};从“@wordpress/i18n”导入{sprintf};常量示例组件=()=>{const快捷别名=使用选择((选择)=>选择(键盘快捷方式存储).getShortcutAliases('核心/编辑器/下一区域'),[]);返回(快捷方式Aliases.length>0&&(<ul>{shortcutAliases.map(({character,modifier},index)=>(<li键={index}>{创建InterpolateElement(冲刺('字符:<code>%s</code>/Modifier:<code>%s</ccode>',字符,修改器),{代码:<code/>,}) }</li>) ) }</ul>));};
参数
- 状态
对象
:全局状态。
- 名称
一串
:快捷方式名称。
退换商品
返回给定名称的快捷方式描述。
用法
从“@wordpress/keyboard-shortcuts”导入{store as keyboardShortcutsStore};从“@wordpress/data”导入{useSelect};从'@wordpress/i18n'导入{__};常量示例组件=()=>{const快捷方式描述=使用选择((选择)=>选择(键盘快捷方式存储).getShortcutDescription('核心/编辑器/下一区域'),[]);return快捷方式描述?(<div>{shortcutDescription}) : ({__('无描述')});};
参数
- 状态
对象
:全局状态。
- 名称
一串
:快捷方式名称。
退换商品
返回给定快捷方式名称的主键组合。
用法
从“@wordpress/keyboard-shortcuts”导入{store as keyboardShortcutsStore};从“@wordpress/data”导入{useSelect};从“@wordpress/element”导入{createInterpolateElement};从“@wordpress/i18n”导入{sprintf};常量示例组件=()=>{const{character,modifier}=useSelect((选择)=>选择(keyboardShortcutsStore).getShortcutKeyCombination('核心/编辑器/下一区域'),[]);返回(<div>{创建InterpolateElement(冲刺('字符:<code>%s</code>/Modifier:<code>%s</ccode>',字符,修改器),{代码:<code/>,}) }</div>);};
参数
- 状态
对象
:全局状态。
- 名称
一串
:快捷方式名称。
退换商品
WPShortcutKeyCombination?
:按键组合。
返回表示给定快捷方式名称的主键组合的字符串。
用法
从“@wordpress/keyboard-shortcuts”导入{store as keyboardShortcutsStore};从“@wordpress/data”导入{useSelect};从“@wordpress/i18n”导入{sprintf};常量示例组件=()=>{const{display,raw,ariaLabel}=useSelect((select)=>{返回{显示:选择(keyboardShortcutsStore).getShortcutRepresentation('核心/编辑器/下一区域'),raw:select(键盘快捷方式存储).getShortcutRepresentation('核心/编辑器/下一区域',“原始”),ariaLabel:选择(键盘快捷方式存储).get快捷方式表示('核心/编辑器/下一区域',“ariaLabel”),};}, [] );返回(<ul><li>{sprintf('显示字符串:%s',显示)}</li><li>{sprintf('原始字符串:%s',原始)}</li><li>{sprintf('ariaLabel-string:%s',ariaLabel)}</li></ul>);};
参数
- 状态
对象
:全局状态。
- 名称
一串
:快捷方式名称。
- 表示
FORMATING_METHODS键
:表示类型(显示、原始、ariaLabel)。
退换商品
返回用于注册新键盘快捷方式的操作对象。
用法
从'react'导入{useEffect};从“@wordpress/keyboard-shortcuts”导入{store as keyboardShortcutsStore};从“@wordpress/data”导入{useSelect,useDispatch};从'@wordpress/i18n'导入{__};常量示例组件=()=>{const{registerShortcut}=useDispatch(键盘快捷方式存储);使用效果(()=>{寄存器快捷方式({name:'自定义/my-custom-shortcut',category:'我的类别',description:__('我的自定义快捷方式'),组合键:{修饰符:“primary”,字符:'j',},} );}, [] );const shortcut=使用选择((选择)=>选择(键盘快捷方式存储).getShortcutKeyCombination('自定义/my-custom-shortcut'),[]);返回快捷方式?(<p>{__('快捷方式已注册。')}</p>) : (<p>{__('快捷方式未注册。')}</p>);};
参数
- 配置
WPShortcutConfig(WP快捷方式配置)
:快捷方式配置。
退换商品
返回用于注销键盘快捷方式的操作对象。
用法
从'react'导入{useEffect};从“@wordpress/keyboard-shortcuts”导入{store as keyboardShortcutsStore};从“@wordpress/data”导入{useSelect,useDispatch};从'@wordpress/i18n'导入{__};常量示例组件=()=>{const{unregisterShortcut}=useDispatch(keyboardShortcutsStore);使用效果(()=>{unregisterShortcut('core/editor/next-region');}, [] );const shortcut=使用选择((选择)=>选择(keyboardShortcutsStore).getShortcutKeyCombination('核心/编辑器/下一区域'),[]);返回快捷方式?(<p>{__('快捷方式未注销。')}</p>) : (<p>{__('快捷方式未注册。')}</p>);};
参数
退换商品