From 06c7e251ce5e97a4949aa308070c3a659b50c780 Mon Sep 17 00:00:00 2001 From: Kolja Markwardt Date: Thu, 28 Oct 2021 16:45:27 +0200 Subject: [PATCH] fix(richtext): improvement to the Rich Text Editor #5446 (#5897) --- cypress/integration/markdown_widget_backspace_spec.js | 11 +++++++++++ .../src/MarkdownControl/plugins/CloseBlock.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cypress/integration/markdown_widget_backspace_spec.js b/cypress/integration/markdown_widget_backspace_spec.js index 67c41d61..79389d4e 100644 --- a/cypress/integration/markdown_widget_backspace_spec.js +++ b/cypress/integration/markdown_widget_backspace_spec.js @@ -25,6 +25,17 @@ describe('Markdown widget', () => {

`); }); + it('moves to previous block when no character left to delete', () => { + cy.focused() + .type('foo') + .enter() + .clickHeadingOneButton() + .type('a') + .backspace({times: 2}) + .confirmMarkdownEditorContent(` +

foo

+ `); + }); it('does nothing at start of first block in document when non-empty and non-default', () => { cy.focused() .clickHeadingOneButton() diff --git a/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins/CloseBlock.js b/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins/CloseBlock.js index 9f44685a..4c2b05a7 100644 --- a/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins/CloseBlock.js +++ b/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins/CloseBlock.js @@ -15,7 +15,7 @@ function CloseBlock({ defaultType }) { return next(); } if (startBlock.type !== defaultType) { - return editor.setBlocks(defaultType); + editor.setBlocks(defaultType); } return next(); },