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.


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.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 3196146-14.patch | 49.99 KB | _utsavsharma |
| #14 | interdiff_13-14.txt | 1.87 KB | _utsavsharma |
| #13 | 3196146-ckeditor4-plugins.patch | 49.96 KB | igorbiki |
| #7 | 3196146-media-undefined-error-d9.patch | 816 bytes | ebremner |
| #5 | 3196146-media-undefined-error-reroll.patch | 18.72 KB | ebremner |
Issue fork drupal-3196146
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
Comment #2
ebremner commentedAdding patch to fix.
https://www.drupal.org/files/issues/2021-02-02/3196146-media-undefined-e...
Comment #3
inteeka-help commentedHi 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:
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).
Comment #4
liam morlandIf 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).
Comment #5
ebremner commentedRe-rolling for 8.9.19
Comment #6
liam morland8.9.19 has now been merged into 8.9.x. This can be put into an issue fork.
Comment #7
ebremner commentedAdding patch for 9.2.x
Comment #8
liam morlandComment #10
liam morlandThe patch needs to update plugin.es6.js from which plugin.js is generated. See "Drupal core now using ES6 for JavaScript development".
Comment #13
igorbiki commentedUpdated patch for CKEditor4 and Drupal 9.5.x
Comment #14
_utsavsharma commentedFixed CCF for #13.
Comment #16
smustgrave commentedCame up as a daily BSI target
Can anyone confirm this is still an issue in D11?
Comment #17
smustgrave commentedGoing to give 1 more bump before closing.
Comment #18
smustgrave commentedSince there's been no follow up going to close out. If still valid please re-open.