If anyone can make a live word count eXtension (or even goals), I’d be eternally grateful. lol.
Just looking at the API, I can’t see any event handling hooks which can be used for something like this. So you could count the words on the page with the API published today but not initiate a count every time a block is updated.
You could create a button in the extension sidebar to initiate a count, but that’s not much more useful than the existing word count
Though I may have missed something
You should be able to re-count every two hundred microseconds or so.
However, I have no idea about the efficiency of this kind of action.
Having some sort of callbacks for updates would be awesome but it’s non-trivial to implement considering non-local edits can change the page you’re looking at.
Here’s a super simple implementation It updates the word count every 2 seconds. Due to the limited developer tools, I wasn’t able to check the performance within the Craft app. So it could be, that it get’s laggy with long documents. If that’s the case, I have some ideas for adding optimizations.
@thestopbutton you mentioned goals: what are you needs for that feature? Setting the target word count for a page and then have some progress bar show the comparison to the actual word count? Anything else needed there? Ideally the word goal should be saved, I think.
I was thinking of goals like Ulysses has them, like a basic one would be once you hit a minimum word count…
Do you mind if I add your extension to the Awesome Craft?
Not at all, feel free to add it!
Thanks for your work!
I checked out what Ulysses does, they also show the “Average reading time”, I think that could be valuable too. I’ll add the goal feature soon!