Problem/Motivation

Currently it is not documented how to pass configuration to CKE5 plugins that is not of a datatype natively supported in yaml.

Example:

The wordcount plugin has a config parameter onUpdate that has the datatype function: https://ckeditor.com/docs/ckeditor5/latest/api/module_word-count_wordcou...

It is possible to set this parameter by using

...
onUpdate:
  func:
    name: some.niceFunction
...

But it is not documented how that works.

CommentFileSizeAuthor
#13 3311239-13.patch3.82 KBwim leers

Comments

Harlor created an issue. See original summary.

wim leers’s picture

Priority: Normal » Major

Wow, excellent find!

nod_’s picture

Just so we're clear, this is not working as of today but it is a proposal on how to encode a reference to a function to be run when needed right?

And the scope for this is CKE5 config, not for other things like drupalSettings or other places where we want a config key to reference a function to run or something?

wim leers’s picture

Actually, JS functions are working as of today. See this example:

media_media:
…
    config:
      drupalMedia:
        toolbar: [mediaImageTextAlternative]
        themeError:
          func:
            name: Drupal.theme
            args: [mediaEmbedPreviewError]
            invoke: true

See processConfig() in core/modules/ckeditor5/js/ckeditor5.js. The two "special cases" are func and regexp. Are there more we should support?

nod_’s picture

Ohh I see, nice.

Not sure where to document. We don't have accessible/generated JS documentation and we don't have yml documentation at all :/

harlor’s picture

@Wim Leers, HTMLElements maybe? The wordcount plugin seems to use that too: https://ckeditor.com/docs/ckeditor5/latest/api/module_word-count_wordcou...

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture

This came up again as a blocker for CKEditor 5 ecosystem adoption: https://drupal.slack.com/archives/C01GWN3QYJD/p1684981833259909?thread_t....

Wim Leers credited mglaman.

wim leers’s picture

Thanks for surfacing, Bryan & Matt!

wim leers’s picture

Status: Active » Needs review
Issue tags: +JavaScript
StatusFileSize
new3.82 KB

The reason this was never documented is cited by @nod_:

Not sure where to document. We don't have accessible/generated JS documentation and we don't have yml documentation at all :/

I propose we are pragmatic and just document it in ckeditor5.api.php, where the documentation already lives of what the ckeditor5.config key expects as values.

Status: Needs review » Needs work

The last submitted patch, 13: 3311239-13.patch, failed testing. View results

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.