0

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:

<div>Line 1<br>Line 2<br>Line 3</div>

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?

New contributor
Mik is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • 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
    Jan 13 at 8:44
  • ...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. Jan 13 at 22:07

Your Answer

Mik is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.