Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 如何创建自定义样式的键盘快捷键_Css_Ckeditor_Keyboard Shortcuts - Fatal编程技术网

Css 如何创建自定义样式的键盘快捷键

Css 如何创建自定义样式的键盘快捷键,css,ckeditor,keyboard-shortcuts,Css,Ckeditor,Keyboard Shortcuts,我创建了一些自定义样式: CKEDITOR.stylesSet.add( 'my_styles', [ { name: 'Advanced', element: 'div', attributes: { class: 'advanced' } }, { name: 'Future', element: 'div', attributes: { class: 'future' } }, ]); editor1 = CKEDITOR.replace("editor1", {st

我创建了一些自定义样式:

CKEDITOR.stylesSet.add( 'my_styles', [
    { name: 'Advanced',  element: 'div', attributes: { class: 'advanced' } },
    { name: 'Future',  element: 'div', attributes: { class: 'future' } },
]);

editor1 = CKEDITOR.replace("editor1", {stylesSet: 'my_styles'})

我可以在样式组合中查看和选择它们。如何为它们创建键盘快捷键?我可以使用“setKeystroke”,但我应该在“command”字符串中输入什么?

您需要从样式命令创建编辑器命令。然后为该命令指定一个击键:

const advancedStyle = new CKEDITOR.style({name: 'Advanced', element: 'div', attributes: { class: 'advanced'}});
editor1.addCommand('advancedCmd', new CKEDITOR.styleCommand(advancedStyle));
editor1.setKeystroke(CKEDITOR.CTRL + CKEDITOR.ALT + 65, 'advancedCmd'); // Ctrl+Alt+A