Add keyboard shortcuts to all toolbar buttons
This commit is contained in:
@@ -239,6 +239,54 @@ describe('ToolbarManager', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('heading and list buttons', () => {
|
||||
it('registers h1-h6', () => {
|
||||
const editor = new r.Editor({ autoToolbar: false });
|
||||
editor.run();
|
||||
for (let i = 1; i <= 6; i++) {
|
||||
const btn = editor.toolbar.buttons.get(`h${i}`);
|
||||
expect(btn).toBeDefined();
|
||||
expect(btn!.label).toBe(`H${i}`);
|
||||
expect(btn!.shortcut).toBe(`Ctrl+${i}`);
|
||||
expect(btn!.action).toBe('prefix');
|
||||
}
|
||||
});
|
||||
|
||||
it('registers ul and ol', () => {
|
||||
const editor = new r.Editor({ autoToolbar: false });
|
||||
editor.run();
|
||||
expect(editor.toolbar.buttons.get('ul')!.shortcut).toBe('Ctrl+Shift+8');
|
||||
expect(editor.toolbar.buttons.get('ol')!.shortcut).toBe('Ctrl+Shift+7');
|
||||
});
|
||||
});
|
||||
|
||||
describe('keyboard shortcuts', () => {
|
||||
it('all formatting buttons have shortcuts', () => {
|
||||
const editor = new r.Editor({ autoToolbar: false });
|
||||
editor.run();
|
||||
const expected = ['bold', 'italic', 'code', 'link', 'save'];
|
||||
for (const id of expected) {
|
||||
expect(editor.toolbar.buttons.get(id)!.shortcut).toBeDefined();
|
||||
}
|
||||
});
|
||||
|
||||
it('block buttons have shortcuts', () => {
|
||||
const editor = new r.Editor({ autoToolbar: false });
|
||||
editor.run();
|
||||
expect(editor.toolbar.buttons.get('fencedCode')!.shortcut).toBe('Ctrl+Shift+E');
|
||||
expect(editor.toolbar.buttons.get('blockquote')!.shortcut).toBe('Ctrl+Shift+.');
|
||||
expect(editor.toolbar.buttons.get('table')!.shortcut).toBe('Ctrl+Shift+T');
|
||||
expect(editor.toolbar.buttons.get('hr')!.shortcut).toBe('Ctrl+Shift+-');
|
||||
});
|
||||
|
||||
it('editor actions have shortcuts', () => {
|
||||
const editor = new r.Editor({ autoToolbar: false });
|
||||
editor.run();
|
||||
expect(editor.toolbar.buttons.get('toggle')!.shortcut).toBe('Ctrl+Shift+V');
|
||||
expect(editor.toolbar.buttons.get('markdown')!.shortcut).toBe('Ctrl+/');
|
||||
});
|
||||
});
|
||||
|
||||
describe('save button', () => {
|
||||
it('triggers editor.save()', () => {
|
||||
resetDOM();
|
||||
|
||||
Reference in New Issue
Block a user