-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Word Count #1624
Add Word Count #1624
Conversation
Some thoughts:
For an example in core, see https://github.com/WordPress/WordPress/blob/4.8/wp-admin/js/post.js#L1216. |
Replying to #1569 (comment) here:
This is fixed in 8b1a7bf and the The relevant portion of the script dependency tree now looks like this:
I think this is a good exercise for playing nice with the rest of core's JS and we should leave it in place at |
Echoing @iseulde's feedback above and adding some further notes. I am not sure that "Post Settings" is the best place for this. You can't see the word count while writing, because it lives inside the base post settings, but when a block is selected, the block's settings appear in the inspector instead. However, while writing is the time that you most want to see the word count. We should probably put this in a more prominent location, cc @jasmussen @mtias for design thoughts. We will need to be a good bit more clever with serializing the post content, as this can be a very expensive operation, and currently it is being done for every single Redux action. One possibility would be to simply debounce the serialization. Another would be to make the While there are a lot of code differences (Redux vs Flux, for one), it's probably worth taking a look at the PR that introduced this in Calypso: We had to add a new event for this - Finally this PR should probably have a more human-readabale title, such as simply "Add word count feature". |
Right, currently Editables are not synced on typing, only blur, while inputs and textareas are. This will probably change in the future, also to enable us to manage undo levels. |
James makes an excellent point here, however I think this is a question that might be worth opening up wider, because in my personal opinion, the word count feature isn't that useful. And because of this, I like the idea behind where @jwold put it in the mockup in #1557 — it's in Post Settings which means if you need to see it, it lives where the document metadata is. But it is not present when the post settings sidebar is closed, which is the closest we have to a "distraction free" environment. However personal opinions should probably not inform where this lives. If a bunch of people rely on this to the point where they want the word count to be accessible even with the sidebar toggled off, we can utilize one of the bottom corners of the editor for a floating counter, like we do on WordPress.com: However this is not a great UI either, as it brings a bunch of headaches to mobile and small viewports. When you've written a long document and your caret is at the end of the doc, it gets very crowded with a word counter that's near where you're writing. Which is another argument for putting it in post settings: there when you need it, not there all the time. |
In my experience keeping this sort of info (word count, paragraph count, character count, read time) makes sense to keep hidden with one or two clicks. I'd vote to keep it in post settings unless there's a strong user case for pulling it out. |
…cher/gutenberg into feature/post-settings-word-count
Ok, given the above discussion, for a first iteration it seems fine to me to solve some of the efficiency issues via a |
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from 'i18n'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note with #2172, these need to be updated to prefix the dependencies with @wordpress/
. You will need to perform a rebase against the latest version of master and apply your changes:
git fetch origin
git rebase origin/master
It was superceded by #2684. Should we close this one? |
After some thinking, I decided to close this one. Thank your for investing your time on this PR. Much appreciated. Feel free to reopen this one if you think it is still relevant. |
Adding a the Word Count feature as mention in #1557.
There is an issue with load order due to #1569 in that the WordCounter is not available when the component is initialized. Ideally, the core
wp.utils
should be loaded before Gutenbergs