feat: use keyboard shortcuts to insert bullet points (#6134)

Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Arpan Kc 2022-01-22 00:43:07 +11:00 committed by GitHub
parent 6c924db10b
commit dd149f6d04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -209,6 +209,14 @@ function ListPlugin({ defaultType, unorderedListType, orderedListType }) {
},
},
onKeyDown(event, editor, next) {
// Handle space ('*' + <space>) or ('-' + <space>)
if (isHotkey('space', event)) {
if (editor.value.startBlock.text === '*' || editor.value.startBlock.text === '-') {
event.preventDefault();
return editor.wrapInList('bulleted-list').deleteBackward(1);
}
}
// Handle Backspace
if (isHotkey('backspace', event) && editor.value.selection.isCollapsed) {
// If beginning block is not of default type, do nothing