如何创建自定义样式的键盘快捷键
How to create a keyboard shortcut to a custom style
我创建了一些自定义样式:
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'})
我可以在样式组合中看到和 select 它们。我如何为他们创建键盘快捷键?我可以使用 "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
我创建了一些自定义样式:
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'})
我可以在样式组合中看到和 select 它们。我如何为他们创建键盘快捷键?我可以使用 "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