kirby icon indicating copy to clipboard operation
kirby copied to clipboard

Extending blocks type "text" adds p tags to the input

Open jnetzlr opened this issue 3 years ago • 8 comments

Description
I’m currently extending the text block type:

text:
  extends: blocks/text
  fields:
    text:
      type: textarea

But when editing the block, there are p tags added to the content. Even while writing in the input field (while the right side modal of the block is opened) there are p tags added to each typed character.

Expected behavior
p tags shouldn't be added to the input field.

Kirby version
3.5

Desktop

  • OS: macOS 10.15.7
  • Browser: Chrome
  • Version: 87

jnetzlr avatar Dec 18 '20 19:12 jnetzlr

Forum discussion: https://forum.getkirby.com/t/issue-extending-blocks-type-text/20416

afbora avatar Dec 18 '20 19:12 afbora

@bastianallgeier Is this an issue or enhancement or expected behavior?

afbora avatar Dec 22 '20 19:12 afbora

@afbora I consider this an expected behaviour. The text blocks expects a writer field. But we need to document it and/or add error handling if another field type is chosen.

bastianallgeier avatar Dec 29 '20 09:12 bastianallgeier

If the previews do not meet certain requirements, it would be nice if the default block appears instead of the warning.

afbora avatar Dec 29 '20 23:12 afbora

@afbora that's a fantastic idea!

bastianallgeier avatar Dec 30 '20 11:12 bastianallgeier

It also happens when using a custom block with a field called “text”. The only workaround i found is renaming the field or setting preview: false in the block’s blueprint

marianruberg avatar Jan 19 '21 15:01 marianruberg

I can confirm the behavior described by @marianruberg

I would like to point out that a lot of people were using the builder plugins definining a custom text block, with a textarea field named "text" inside, a pretty common naming choice. Now switching to the new blocks field suddenly those textarea fields are broken because - I guess - the writer features kick in making the textare field totally unusable.

Having a feature somehow based on a field name without making that name reserved complicates a lot of real world situations.

SkidX avatar Feb 19 '21 17:02 SkidX

What we could do is

  • Use k-textarea-input instead of k-writer for the block preview whenever the drawer's text field isn't of type writer
  • Add a new "plaintext only" mode to k-writer and activate it when the drawer's text field isn't of type writer

distantnative avatar Mar 28 '22 14:03 distantnative

afbora avatar Aug 16 '22 10:08 afbora