From dd149f6d0479d20eef0bc9cede738784c9cdb4fd Mon Sep 17 00:00:00 2001 From: Arpan Kc Date: Sat, 22 Jan 2022 00:43:07 +1100 Subject: [PATCH] feat: use keyboard shortcuts to insert bullet points (#6134) Co-authored-by: Erez Rokah Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../src/MarkdownControl/plugins/List.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins/List.js b/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins/List.js index 58838100..20405950 100644 --- a/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins/List.js +++ b/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins/List.js @@ -209,6 +209,14 @@ function ListPlugin({ defaultType, unorderedListType, orderedListType }) { }, }, onKeyDown(event, editor, next) { + // Handle space ('*' + ) or ('-' + ) + 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