[Meta] Create new major branch and add support for CKEditor 5

Created on 22 April 2022, over 2 years ago
Updated 30 July 2024, 5 months ago

Problem/Motivation

In preparation for Drupal 10 we'll need to port this plugin to CKeditor 5

https://www.drupal.org/docs/core-modules-and-themes/core-modules/ckedito... β†’ has some documentation

The wordcount plugin is provided by https://ckeditor.com/docs/ckeditor5/latest/features/word-count.html

Proposed resolution

Hatch a plan to release a CKEditor 5 version in a new major branch

Remaining tasks

User interface changes

API changes

Data model changes

🌱 Plan
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡Έ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.

  • πŸ‡ΊπŸ‡ΈUnited States kevinquillen

    Sure, I will reach out to Harlor.

  • πŸ‡©πŸ‡ͺ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.
  • Merge request !1start work on #3276563 "Meta create new" β†’ (Open) created by calebtr
  • πŸ‡§πŸ‡ͺ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 reached

    I 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:

  • πŸ‡©πŸ‡ͺ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 5 months ago
  • πŸ‡¦πŸ‡Ί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.

Production build 0.71.5 2024