Forbid newlines in Writer field

We need a single-line input with some inline HTML formatting, but without the ability to create new paragraphs or line breaks. The text field doesn’t support any HTML formatting, so we’re using writer in inline mode. However, this still allows inserting linebreaks (which get saved as <br> tags). Is there a way to prevent line breaks in the writer field in inline mode, so that pressing enter key doesn’t create a new line?

What were you trying with the Text field? It does indeed support HTML and Markdown, If you output it with the ->kt() or ->kti() field methods. The latter will omit the outer paragraph tag.

Entering something like:

and outputting the feild with ->kt()

results in

<p>Kirby is a <em>flat file</em>, awesome <strong>CMS</strong> <strong> lets make this bold </strong></p>

I don’t think so, you could remove the br tags when rendering the content, though.

Apart from that, what @jimbobrjames wrote.

Thank you for the suggestions. Unfortunately, this won’t work for us, as we don’t want our editors to have to enter markdown or HTML manually, and we don’t want to allow any arbitrary HTML, just the limited set of inline formatting options provided by the writer field.

I don’t think so, you could remove the br tags when rendering the content, though.

@texnixe Thanks, we’ll consider this as a last resort. However, it’s not great as it creates a discrepancy between what the editor sees and what appears in the frontend – for the editor, this will look like an error. So having the single-line behaviour enforced in the panel would be optimal.

I’ve created a feature-request for this: https://kirby.nolt.io/501

A help prop which explains the behavior could help here.

@MoritzLost You might want to take a look at the Kirby Markdown plugin which, with a quick look at the readme, it looks like you can configure it to act like the single line Text field BUT with the tool bar still in place.

1 Like

Thank you for the suggestion. A help text is always an option, but I try to avoid it – the best interface is one you don’t have to explain.

@MoritzLost You might want to take a look at the Kirby Markdown plugin which, with a quick look at the readme, it looks like you can configure it to act like the single line Text field BUT with the tool bar still in place.

@jimbobrjames Thank you! I’ll give that a try.