<p>I'm trying to configure redactor in Craft 3 to only allow a single line. Setting &quot;enterKey&quot; to false seems great for typing, but pasting content still makes it add breaks.</p>
<p>Here's my configuration:</p>
<pre><code>{
  &quot;removeNewLines&quot;: true,
  &quot;markup&quot;: &quot;div&quot;,
  &quot;enterKey&quot;: false,
  &quot;structure&quot;: false,
  &quot;pastePlainText&quot;: true,
  &quot;pasteLinks&quot;: false,
  &quot;pasteImages&quot;: false,
  &quot;linebreaks&quot;: false,
  &quot;pasteKeepStyle&quot;: false,
  &quot;pasteKeepClass&quot;: false,
  &quot;pasteKeepAttrs&quot;: false,
  &quot;pasteBlockTags&quot;: false,
  &quot;pasteInlineTags&quot;: false
}
</code></pre>
<p>Sample content that I paste in:</p>
<pre><code>Line 1
Line 2
Line 3
</code></pre>
<p>Which becomes:</p>
<pre><code>&lt;div&gt;Line 1&lt;br&gt;Line 2&lt;br&gt;Line 3&lt;/div&gt;
</code></pre>
<p>But I want it to be just always forced to one line, no <code>br</code>'s. Seems Redactor used to have configuration for this but I can't see any alternatives. Does anyone know if this is possible?</p>

CC BY-SA 4.0
2022-01-13T08:44:05.797Z
Redactor is broken as hell, configuration is mostly ignored when pasting. You might have to just filter out newlines using a save hook (using strip_tags with a white-list of allowed tags, for example).
MoritzLost
CC BY-SA 4.0
2022-01-13T22:07:08.893Z
...or use the `|striptags` filter in Twig when outputting. Or, use CSS (i.e. `br { display: none; }`). Or something like `|replace('<br>', ' ')` (also Twig), if the breaks need to be replaced with spaces instead of just removed. None of these answer the question, but are possibly viable workarounds.
Mats Mikkel Rummelhoff
CC BY-SA 4.0
2024-08-08T07:22:00.523Z
I think you are looking for `"pasteInlineTags": ["a", "strong", "del" ,"sup", "sub", "small", "b", "u", "em", "i"],`
Ignis
<craft3><redactor>
Prevent breaks in redactor
# Prevent breaks in redactor

(Asked by: username_0 on 2022-01-13)

I'm trying to configure redactor in Craft 3 to only allow a single line. Setting "enterKey" to false seems great for typing, but pasting content still makes it add breaks.
Here's my configuration:
{
  "removeNewLines": true,
  "markup": "div",
  "enterKey": false,
  "structure": false,
  "pastePlainText": true,
  "pasteLinks": false,
  "pasteImages": false,
  "linebreaks": false,
  "pasteKeepStyle": false,
  "pasteKeepClass": false,
  "pasteKeepAttrs": false,
  "pasteBlockTags": false,
  "pasteInlineTags": false
}

Sample content that I paste in:
Line 1
Line 2
Line 3

Which becomes:
Line 1Line 2Line 3

But I want it to be just always forced to one line, no br's. Seems Redactor used to have configuration for this but I can't see any alternatives. Does anyone know if this is possible?

**Tags:** craft3, redactor

> **Comments:**
> **username_1**: Redactor is broken as hell, configuration is mostly ignored when pasting. You might have to just filter out newlines using a save hook (using strip_tags with a white-list of allowed tags, for example).  
> **username_2**: ...or use the `|striptags` filter in Twig when outputting. Or, use CSS (i.e. `br { display: none; }`). Or something like `|replace('<br>', ' ')` (also Twig), if the breaks need to be replaced with spaces instead of just removed. None of these answer the question, but are possibly viable workarounds.  
> **username_3**: I think you are looking for `"pasteInlineTags": ["a", "strong", "del" ,"sup", "sub", "small", "b", "u", "em", "i"],`  

---

## 0 answers

