- Issue created by @gedvan
- Merge request !6999Issue #3427200 - CKEditor 5: Javascript error when plugin settings has NULL value โ (Open) created by gedvan
- Status changed to Needs review
9 months ago 2:47pm 12 March 2024 - ๐ง๐ทBrazil gedvan Joรฃo Pessoa
By mistake, I created this for 10.2.x. I've changed the Version field to 10.3.x, but I don't know how to rebase the issue branch and MR. If someone can help, I'd appreciate it.
- Status changed to Needs work
9 months ago 3:24pm 12 March 2024 - ๐บ๐ธUnited States smustgrave
Should actually target 11.x as the current "main" branch. Bugs can be backported.
MR should be updated too.
The scenario may be valid, not sure if it's a bug in the custom code though. But will need a failing test to show the problem.
- Status changed to Postponed: needs info
9 months ago 8:47am 15 March 2024 - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
It's not clear to me what the steps to reproduce are. It's also not clear to me if "just
NULL
" ever makes sense โ it'd make more sense to not have any configuration at that point? ๐ค๐ - ๐ง๐ทBrazil gedvan Joรฃo Pessoa
@wim-leers I bumped into this when I was writing a plugin to add the Text Transformation feature into CKEditor 5. I've made it (BTW, I've written a module for that โ ), but trying some plugin advanced configs, I noticed some of them needed returning NULL values. For example, the
extra
config with regular expressions:Looking at
core/modules/ckeditor5/js/ckeditor5.js
code, I found out that I could return a RegExp as config using a structure like this (on aCKEditor5Plugin
orhook_ckeditor5_plugin_info_alter
implementation):return [ // ... 'extra' => [ [ 'from' => ['regexp' => ['pattern' => '/(^|\s)(")([^"]*)(")$/']], 'to' => [NULL, 'ยซ', NULL, 'ยป'], ], ] ];
However, when I did this, the editor got broken, and a JS error on the browser console pointed to an error on ckeditor5.js. Then, looking at
processConfig()
's code, it assumes the config parameter is always a valid Object, but in Javascript,typeof null === 'object'
(which is crazy), so when config is null, the error occurs.My MR just adds a null check for the config parameter.
- Status changed to RTBC
9 months ago 9:29am 20 March 2024 - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
Oh โฆ intriguing! Thanks a lot for that clear explanation! ๐
Explicit test coverage for this seems totally overkill for that simple oversight and trivial code addition ๐
- ๐ฌ๐งUnited Kingdom alexpott ๐ช๐บ๐
Committed and pushed 695c6a53ca to 11.x and 0590956f51 to 10.3.x and 4fb6e509bf to 10.2.x. Thanks!
-
alexpott โ
committed 4fb6e509 on 10.2.x
Issue #3427200 by gedvan, Wim Leers: CKEditor 5: Javascript error when...
-
alexpott โ
committed 4fb6e509 on 10.2.x
-
alexpott โ
committed 0590956f on 10.3.x
Issue #3427200 by gedvan, Wim Leers: CKEditor 5: Javascript error when...
-
alexpott โ
committed 0590956f on 10.3.x
- Status changed to Fixed
9 months ago 10:30am 25 March 2024 -
alexpott โ
committed 695c6a53 on 11.x
Issue #3427200 by gedvan, Wim Leers: CKEditor 5: Javascript error when...
-
alexpott โ
committed 695c6a53 on 11.x
Automatically closed - issue fixed for 2 weeks with no activity.