Problem/Motivation

When adding some native ckeditor plugins, in this case mathjax, when adding blocks the first load will look fine, as soon as you go to configure the block, the ckeditor does not appear and a JS error is thrown.
Ckeditor not showing
JS error

Steps to reproduce

Add a new ckeditor plugin to a text format. On a block use that new text format. The first load inside layout builder will work fine, as soon as you go back to configure the block, the ckeditor will not be displayed.

Proposed resolution

Add a check inside drupalmedia plugin.js to check for undefined editor.widgets.

Issue fork drupal-3196146

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ebremner created an issue. See original summary.

ebremner’s picture

inteeka-help’s picture

StatusFileSize
new9.81 KB

Hi there,

We are also having this issue, we have created a new Plugin module for "imagetoolbar", it works initially on page load, but once you open an IEF (Inline Entity Form), it goes blank, we also receive a JS error.

JS ERROR:

Uncaught TypeError: Cannot read property 'on' of undefined
at Object.beforeInit (plugin.js?t=qqqsi5:189)
at Object. (ckeditor.js?v=4.15.1:273)
at n (ckeditor.js?v=4.15.1:253)
at Object.load (ckeditor.js?v=4.15.1:253)
at ckeditor.js?v=4.15.1:273
at window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.resourceManager. (ckeditor.js?v=4.15.1:260)
at window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.resourceManager. (ckeditor.js?v=4.15.1:259)
at n (ckeditor.js?v=4.15.1:253)
at Object.load (ckeditor.js?v=4.15.1:253)
at window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.resourceManager.load (ckeditor.js?v=4.15.1:258)

Line 189: editor.widgets.on('instanceCreated', function (event) {

plugin.js in question is: drupalimage located in core/modules/ckeditor/js/plugins/drupalimage/plugin.js which is triggered

Our Plugin sourcecode:

<?php
namespace Drupal\ckeditor_plugins\Plugin\CKEditorPlugin;

use Drupal\ckeditor\CKEditorPluginInterface;
use Drupal\ckeditor\CKEditorPluginButtonsInterface;
use Drupal\ckeditor\CKEditorPluginContextualInterface;
use Drupal\Component\Plugin\PluginBase;
use Drupal\editor\Entity\Editor;
use Drupal\ckeditor\CKEditorPluginBase;


/**
 * Defines the "imagetoolbar" plugin, with a CKEditor.
 *
 * @CKEditorPlugin(
 *   id = "imagetoolbar",
 *   label = @Translation("Image Toolbar")
 * )
 */
class ImageToolbar extends PluginBase implements CKEditorPluginInterface,CKEditorPluginContextualInterface {

  /**
   * {@inheritdoc}
   */
  public function getDependencies(Editor $editor) {
    return [
    	// 'image2',
      'drupalimage',
    ];
  }
  public function getButtons() {
    return [];
  }
  /**
   * {@inheritdoc}
   */
  public function getLibraries(Editor $editor) {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function isInternal() {
    return FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function isEnabled(Editor $editor){
     return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function getFile() {
    // return NULL;
    return drupal_get_path('module', 'ckeditor_plugins') . '/js/plugins/'.$this->getPluginId().'/plugin.js';
  }
  /**
   * {@inheritdoc}
   */
  public function getConfig(Editor $editor) {
    $config = [];
    return $config;
  }

}

Our Drupal environment:

Drupal Core: 9.1.4
PHP: 7.4
CKEditor: 4.15.1
Inline Entity Form Version: 8.x.1.0-rc8

How to produce:

- Install IEF.
- Create a new custom plugin on any CKEditor that uses drupalimage plugin.
- Enable this on the editor settings.
- Create a entity reference within a content type with unlimited cardinality.
- Set Form display to IEF (Complex).

liam morland’s picture

Status: Active » Needs work

If this is still needed, it will have to be re-rolled against 9.3.x.

It also needs a re-roll to apply after 8.9.19 (which has yet to be merged into 8.9.x).

ebremner’s picture

StatusFileSize
new18.72 KB

Re-rolling for 8.9.19

liam morland’s picture

8.9.19 has now been merged into 8.9.x. This can be put into an issue fork.

ebremner’s picture

StatusFileSize
new816 bytes

Adding patch for 9.2.x

liam morland’s picture

Version: 8.9.x-dev » 9.2.x-dev

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

liam morland’s picture

The patch needs to update plugin.es6.js from which plugin.js is generated. See "Drupal core now using ES6 for JavaScript development".

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

igorbiki’s picture

StatusFileSize
new49.96 KB

Updated patch for CKEditor4 and Drupal 9.5.x

_utsavsharma’s picture

StatusFileSize
new1.87 KB
new49.99 KB

Fixed CCF for #13.

Version: 9.5.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. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Bug Smash Initiative

Came up as a daily BSI target

Can anyone confirm this is still an issue in D11?

smustgrave’s picture

Going to give 1 more bump before closing.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Since there's been no follow up going to close out. If still valid please re-open.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.