Problem/Motivation
Given that the ckeditor module is enabled, when adding a new text format and selecting "ckeditor" in the Text editor select field, a javascript error is thrown.
This is caused by the Internal ckeditor plugin (\Drupal\ckeditor\Plugin\CKEditorPlugin\Internal::generateFormatTagsSetting()).
The method is returning an empty array when the editor is not associated with a filter format.
The documentation for that method is also wrong. It says that the return value is an array, but that is not true.
When the editor is associated with a text format, the return value is a string with tags separated with a semi-colon (;)
i.e "h1;h2;h3.."
Proposed resolution
Seems like returning an empty string instead of an empty array causes other javascript errors, so my guess is that the
$config["format_tags"]
should not even exists when the editor is not associated with a filter format.
Comment | File | Size | Author |
---|---|---|---|
#24 | interdiff_17-24.txt | 1.27 KB | raman.b |
#24 | 2763075-24.patch | 2.4 KB | raman.b |
#24 | 2763075-24-test-only.patch | 884 bytes | raman.b |
#17 | 2763075-17.patch | 1.54 KB | Martijn de Wit |
#12 | 2763075-12.patch | 1.54 KB | Martijn de Wit |
Comments
Comment #2
anonAlso noticed that this issue blocks javascripts tests from testing stuff in the text format add form.
Comment #3
anonComment #4
anonComment #6
thpoul CreditAttribution: thpoul at Pixual commentedNice catch! Manually tested and I was able to replicate the bug and confirm that the patch works great. We should have some testing for it.
Just a nit:
s/string|false/mixed
Comment #12
Martijn de WitStill encountered this issue at 8.6.
Converted patch to 8.6/8.7
Added comment from #6
Comment #13
Wim LeersReproduced. Ran into it over at #3060749: entity_embed_filter_format_edit_form_validate() Logic is Faulty.
Best of all: there is an explicit JS test over there! We can reuse that here, to justify the core fix :)
Comment #14
borisson_So I think #13 means this already had to go back to needs work. But I have some additional nitpicks. The only one actually being actionable being the second.
I personally don't like doing assingments in if statements, however I don't see a way to do this in a cleaner way, without introducing more nesting. So let's keep it like this in this case.
false/mixed is not a valid type I think, we should probably keep just the false and remove the /mixed.
So the docs say that this used to return an empty array or a string. That doesn't make sense.
I was going to complain about introducing a mixed return type where it might've been avoidable, but it looks like this was already broken.
Comment #17
Martijn de WitMade patch working for > 8.8.7
Comment #18
Hardik_Patel_12 CreditAttribution: Hardik_Patel_12 at QED42 commentedComment #19
Martijn de WitIt was still on needs work because tests are needed.
Comment #20
pratik_kambleComment #21
pratik_kambleComment #23
douggreen CreditAttribution: douggreen as a volunteer commentedThe solution fixes the problem. I understand why we hold up merging this waiting on tests ... but this is a pretty fundamental broken feature (adding buttons to the editor) that takes some skill to work around. Can we consider merging this without tests?
Comment #24
raman.b CreditAttribution: raman.b at OpenSense Labs commentedAdding a failing test case to demonstrate the reported issue. CKEditor plugin settings are not visible without applying this patch
Also this should address #14
Comment #27
Wim LeersManually reproduced, with this patch applied it works correctly! 👍
Thanks, @raman.b for adding the failing test case!
Comment #30
alexpottCommitted and pushed 190aae1079 to 9.3.x and c051ff7508 to 9.2.x. Thanks!
Backported to 9.2.x since this is a low-risk bug fix.