Panel character count + word count

Sometimes it can be good to have a character counter on the field, especially text and textarea field types. Sometimes it can be good to have a word counter on the textara field type.

Character count

Good for…

  • the SEO title field. Google has a limit in length.
  • the SEO description fields. Google has a limit in length.
  • adding text in tiny spaces like a little box and don’t want it to be messy.

Blueprint field types…

  • text
  • textarea

Word count

Good for…

  • every long text content you create, to see if it is long enough, for users and for Google.

Blueprint field types…

  • textarea

WordPress has word count built in on their TinyMCE (like the textarea field).

Optional

I think it should be optional in the blueprint, especially in the text field type.

In most fields we probably don’t need the character counter. In textarea I’m not sure. There are already buttons so it would probably don’t hurt with a word counter and a character counter in there.

1 Like

I made such a replacemnt field for Kirby’s standard input field a while ago. It uses the min/max values specified in the blueprint validate section: https://github.com/iksi/KirbyInputField

1 Like

How simple!

Is it really safe to override the default fields like that? Or do just inherit the original fields and add the counters?

It’s a replacement. But that’s save, because Kirby uses the custom fields instead of the built-in ones if there is one with the same name. That’s a Kirby feature.

The only disadvantage is that it could break when updating the Panel. But since every custom field has that problem, it’s not that dangerous.

BTW: Good job @iksi! I think that this could become an optional core feature that could be turned on in the blueprint. You can create a PR to the Panel repo if you want.

2 Likes

Made the pull request: https://github.com/getkirby/panel/pull/596

1 Like