- πΊπΈUnited States kevinquillen
I think this needs exploring at least, because a 3.x branch could certainly be CKEditor 5 only and 2.x could be sunset.
The core functionality in CKEditor 5 has less than the CKEditor 4 one did. It should be relatively straightforward at least to get the basic example working:
https://ckeditor.com/docs/ckeditor5/latest/features/word-count.html
You can see on the 'full demo' that the counts are attached to the editor footer, like the previous version:
https://ckeditor.com/docs/ckeditor5/latest/examples/builds-custom/full-f...
@Harlor if you want to continue the effort for a 3.x branch you can. I'd rather do that than displace 4100 users.
- π©πͺGermany a.dmitriiev
There is already a sandbox project https://www.drupal.org/sandbox/fisherman90/3324938 β but I can't clone it for some reason and therefor can't test. But it looks that it does what is needed.
- π©πͺGermany Harlor Berlin
Yes, We got the CKE5 wordcount plugin working but later abandoned the project because we switched to maxlength's cke5 integration: https://www.drupal.org/project/maxlength/issues/3267413 π Countdown not working for ckeditor5 Fixed
- π©πͺGermany rgpublic DΓΌsseldorf π©πͺ πͺπΊ
NB: The sandbox project does implement its own custom counting mechanism instead of relying on the existing CKE5 functionality which may or may not be what's desired. Just wanted to mention this.
- First commit to issue fork.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Note that in the demo at https://ckeditor.com/ckeditor-5/demo/feature-rich/, the word count is integrated in the CKEditor 5 UI in a way that's very similar to how it was in CKEditor 4.
- π©πͺGermany rgpublic DΓΌsseldorf π©πͺ πͺπΊ
We implemented this plugin properly - relying on the official CKE5 mechanism for counting words/characters. I'm donating the source code here. Feel free to copy all/everything as you see fit :-)
- πΊπΈUnited States calebtr
Keep in mind, this module provides more functionality than the CKEditor5 Word Count plugin. It implements https://github.com/w8tcha/CKEditor-WordCount-Plugin for CKeditor 4 on Drupal. The plugin developer which has no plans for supporting CKEditor5.
Current features:
* count characters
* count words
* count paragraphs
* count bytes
* count spaces as characters
* count html as characters
* count line breaks
* maximum for word count
* maximum for character count
* lock editor when limit is reachedI might be missing something, but I don't think any of the examples here do all that.
For character counts and character limits, the maxlength module appears to be doing the job.
The ckwordcount module could add functionality:
* showing word count (I need this for our projects)
* giving the option to lock the editor when character or word counts are reached (Harlor requests, above)What about the other features?
* counting paragraphs, and bytes(?)
* giving the option to count spaces, html and line breaks as characters - πΊπΈUnited States kevinquillen
I haven't had time to get too deep into it, but my assumption was we'd have to integrate the main functionality (the new WC in CK5) and then backport those old features. But given how the underlying model has changed (literal CK5 models) I am not sure if some of them can be done, or is worth doing (counting bytes?).
- π©πͺGermany rgpublic DΓΌsseldorf π©πͺ πͺπΊ
Well, my very personal opinion is that it'd be the best to rely on features already in CKEditor5 instead of reinventing the wheel. My proof-of-concept module does that. I think relying on existing CKEditor5 features is also better performance-wise (in contrast to constant polling and analyzing the whole text). @calebtr is right though about the features we might lose. Although limit/locking could be implemented with CKEditor5's API quite easily and this is even documented in their docs:
https://ckeditor.com/docs/ckeditor5/latest/features/word-count.html (isLimitExceeded)
What's currently missing though is the different settings on how to calculate the exact count (with or w/o spaces and so on). One solution to implement this (if its decided that it's worthwhile to do so) and still rely on the original CKEditor5 API might me to subclass their plugin...
https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-wor...
...and modify the RegEx. Unfortunately it seems to be hidden away in a private property :-( Perhaps it might also be helpful to actually ask the CKEditor folks about whether they want to implement stuff upstream and/or at least make this property public. That might simplify things a lot.
- πΊπΈUnited States kevinquillen
features already in CKEditor5 instead of reinventing the wheel
Right, thats what I meant.
- π©πͺGermany marcoka
Downloaded the zip, installed. Where should the count appear? As far as i can see there are no settings, i read the code.
The idea here seems right. Use ckΒ΄s core feature and let the module just provide the settings.
- π¬π§United Kingdom cbrody
Thanks for the plugin @rgpublic. I also need the facility to show the word count and enforce a hard limit.
- π©πͺGermany rgpublic DΓΌsseldorf π©πͺ πͺπΊ
There should be two values. One for word count and one for character count (see attached screenshot). Don't know why it isn't visible for @marcoka. It should work out-of-the-box. Perhaps change for any JS errors etc.? Sorry for dropping this here somewhat as-is. Unfortunately I cannot take care of this ATM as I'm inundated with other D10/CKE5 work. Like I mentioned before, if anyone wants to implemented limit/locking I'd suggest checking the example given here:
https://ckeditor.com/docs/ckeditor5/latest/features/word-count.html
- π©πͺGermany marcoka
Checked console for errors. Found only this:
- ckeditor5-dll.js?v=39.0.1:5 matcher-pattern-deprecated-attributes-class-key Object
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#erro...
- ckeditor5-dll.js?v=39.0.1:5 matcher-pattern-deprecated-attributes-class-key Object
- π©πͺGermany rgpublic DΓΌsseldorf π©πͺ πͺπΊ
@marcoka: Hm, weird. I don't get this message but I don't think this is the cause of the problem because the message only says that sth. is deprecated - not unsupported. Sorry, I can't help you there :-( I've posted a screenshot on how it should look like. Are you using the newest Drupal version 10.x ? You're not using D9 right? I haven't tested this on D9. Perhaps others might be able to find out what's going wrong - I'm at a loss here.
- π©πͺGermany marcoka
I use D10, 10.1
I will check on this later as i have so many problems with D10. - π©πͺGermany h1nds1ght
@rgpublic For me it works as described with d10.1, thank you!
Do you think it would be possible to integrate some settings like in the current module?
https://git.drupalcode.org/project/ckwordcount/-/blob/3.x/src/Plugin/CKE...
Mostly I miss the "hard limit" option. I think it should be possible to integrate that:
https://ckeditor.com/docs/ckeditor5/latest/features/word-count.html#demo...
- π©πͺGermany marcoka
@h1nds1ght did you only download the module put it into modules/custom an enabled it on the modules page?
- First commit to issue fork.
- First commit to issue fork.
- π¨πSwitzerland berdir Switzerland
Fixed the incorrectly named form elements in the plugin, so the settings were never stored and I guess it only worked initially.
Can confirm it technically works then, but there's currently no styling at all, the info is just shown as regular text after the editor on separate lines, so that takes up quite a bit of space.
- π¦πΊAustralia gordon Melbourne
Can we get this committed into a 3.x branch which only supports CKEditor 5.
Installing 2.x, currently has dependencies on CKEditor 4 which gets it installed even if we don't need it. Also deploying to a 3.x branch will make it a lot easier for people to test and it is it just a dev release everyone knows what to expect.
I have done this for other projects and it really speeds up the final development as it easier to deploy and test.
- Status changed to Needs work
4 months ago 12:17am 16 July 2024 - π¦πΊAustralia gordon Melbourne
I have done some more testing and this is working great and is just about RTBTC, except for 1 thing. Basically the HTML structure is there but there is no styling for the word/character count.
It is looking really good.
- π¦πΊAustralia nterbogt
Can we update the target branch of the merge request to 2.x please? I'm not sure how to do it or I don't have permission.