decaporg / decaporg/decap-cms

Soft line breaks in new richtext widget

Open
#7,816 1 comment 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Describe the bug**

In the new `richtext` widget, soft line breaks (shift + enter) do not emit a line break in the final Markdown. In the old `markdown` widget these would emit `\` at the end of the line to force a hard line break, but the new widget doesn’t include this, causing many Markdown renderers (including Decap’s built-in preview) to ignore the newline.

**To Reproduce**

1. Open an item in the CMS that uses the `richtext` widget.
2. Add some text that includes soft line breaks (e.g. type while using shift + enter to break up your text)
3. Observe that no line breaks are shown in the preview pane
4. Observe that when saving the item, the Markdown output includes newlines but no trailing `\`.

**Expected behavior**

The editor should output `\` at the end of soft line breaks like the `markdown` widget does. (Or an alternative like a `
` element.)

**Screenshots**

Here’s an example of soft line breaks in the editor and rendering without breaks in the preview pane:

Decap CMS showing richtext widget on the left and preview pane on the right

**Applicable Versions:**

- Decap CMS version: 3.12.2
- Git provider: not relevant
- OS: macOS
- Browser version: Firefox 150
- Node.JS version: 24.15.0

**CMS configuration**
It’s a lot in my case, but here’s a relevant `fields` config:

```js
{
name: 'body',
label: 'Page contents',
widget: 'richtext',
buttons: ['bold', 'italic', 'link', 'heading-two', 'quote'],
editor_components: ['image'],
modes: ['rich_text'],
},
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.