Sitelet https://github.com/processwire/processwire-issues/issues/2032
Skip to content

Update InputfieldTextLength.js to work with InputfieldTinyMCE #2032

Description

@elabx

Currently the word count is not updated while typing on the TinyMCE editor as it is now with CKEditor. Also, while testing TinyMCE's word count, it seems to throw a different number which seems to give a better estimate, here is a norred down example I made:

Image

Code is:

Image

Activity

  1. ryancramerdesign commented on Feb 6, 2025

    @ryancramerdesign
    Member

    @elabx Since TinyMCE has the word count built in, is there any reason to use the InputfieldTextLength version? The InputfieldTextLength is really more intended for plain text fields rather than rich text. So I'm wondering if maybe the best bet is just to disable the option from being selected for TinyMCE?

  2. elabx commented on Feb 6, 2025

    @elabx
    Author

    I agree! Not sure if there is any other backend validation for this?

    Maybe it would be nice to flag the Inputfield with an error, like the Input character limit does. Although this would have to work with words not characters? Something I liked about the previous counter is that it gave live feedback about reaching a character count limit. I think it showed the limit in red?

    I guess TinyMCE could write it's count to a hidden input or similar but unfortunately I cannot find any docs about customizing the wordcount Tiny plugin.

  3. BrendonKoz commented on Mar 19, 2025

    @BrendonKoz

    It might cause a breaking change, but passing the value from InputfieldTextLength when handling word count through strip_tags first would likely provide a more appropriate value/estimate. Typically word counts are intended to be just the words, not the markup.

    I just noticed the InputfieldTextLength is JavaScript, but the same idea could apply. Replacing all elements with a space (to prevent unintentional word merging), then getting the innerText/textContent, and then calculating the word count. The breaking change could be mitigated by offering a showCount value of 3 for a new option.

  4. matjazpotocnik commented on Sep 11, 2026

    @matjazpotocnik
    Collaborator

    @elabx, what is the status of this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions