0

I'm including the wordcount plugin to CKEditor in D8. I'm including some configuration (maxWordCount) through the configurable interface. The issue I'm having is that no matter what I return from getConfig there's no affect on the editor.

class WordCount extends CKEditorPluginBase implements CKEditorPluginContextualInterface {

  public function isEnabled(Editor $editor) {
    return TRUE;
  }

  public function isInternal() {
    return FALSE;
  }

  public function getFile() {
  return drupal_get_path('module', 'ckeditor_maxlength') . '/wordcount/plugin.js';
  }


  public function getConfig(Editor $editor) {
  // just return a hardcoded maxWordCount.
    return [
      'maxWordCount' => 10,
    ];
  }

  public function getButtons() {
  // No buttons needed.
  }
}

To be clear the counter works as expected, but I don't seem to be able to override the default configuration.

Inside the core ckeditor module the getConfig function has this notation:

* @return array
*   A keyed array, whose keys will end up as keys under CKEDITOR.config.

When I inspect CKEditor.config in the console I don't see the configurations, and infact, the wordcount plugin is buried in CKEditor.plugins.externals.

1 Answer 1

0

It turns out I was just formatting the array improperly. In order to return the configuration to my wordcount plugin I did this:

 return ['wordcount' => ['maxWordCount' => '10']];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.