Editing content using the Gutenberg editor, adding an image using the Media Library doesn't work.
To reproduce:
- Enable Media and Media Library modules
- Install Gutenberg editor version 8x-1.11
- In the Article or Basic page content type enable the Gutenberg editor
- Add content
- In the Gutenberg editor, add an image or media block
- Click on Media Library
- A modal window with a title of Media Library appears with white space and Insert/Cancel buttons at the bottom but no library of image.
I tested this on a brand new site installed using Drupal 9.0.0.
I also tested on a brand new site installed using Drupal 8.9.0 which did not have the issue, but after upgrading the 8.9.0 site to 9.0.0 the issue appears.
I noted this message in the logs:
ArgumentCountError: Too few arguments to function Drupal\media_library\MediaLibraryUiBuilder::__construct(), 4 passed in /var/www/*****/html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 257 and exactly 5 expected in Drupal\media_library\MediaLibraryUiBuilder->__construct() (line 76 of /var/www/*****/html/core/modules/media_library/src/MediaLibraryUiBuilder.php)
Comment | File | Size | Author |
---|---|---|---|
#17 | gutenberg-d9_media_library_support-3150127-17.patch | 991 bytes | kjankowski |
#13 | interdiff-3150127-3-13.diff.txt | 263 bytes | szeidler |
#13 | gutenberg-d9_media_library_support-3150127-13.patch | 1.39 KB | szeidler |
#5 | Comparion of Gutenberg Blocks text formats.png | 64.59 KB | feridun |
#4 | gutenberg-d9_media_library_support-3150127-4.patch | 1.27 KB | szeidler |
Comments
Comment #2
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedIn #3038254: Delegate media library access to the "thing" that opened the library the Drupal core service has gotten a 5th parameter "@media_library.opener_resolver".
The constructor of MediaLibraryUiBuilder in Drupal 8 states.
So I see two ways to go.
1. Either dropping < Drupal 8.7 support on Gutenberg and adding the argument to gutenberg.services.yml definition.
2. Or we need to basically mimic the constructor of
MediaLibraryUiBuilder
in Drupal 8 to the Gutenberg moduleGutenbergMediaLibraryUiBuilder
.Comment #3
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedHere's a patch for approach 1.
Comment #4
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedThis is actually more correct, as the parameter was added in Drupal 8.7.4
Comment #5
feridun CreditAttribution: feridun commentedA bit more information, on a site that is running 8.9.0 and the Media Library works as expected, there is a difference in the Gutenberg Blocks text format at admin/config/content/formats as per the screenshot below. The one on the left is from the 8.9.0 system and the one on the right is from 9.0.0.
Comment #6
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedActually #3 + #4 makes media_library an implicit dependency, because otherwise the service will not be available. So it might not be the best solution.
So either going with approach 2 described in #2 or we need to make media_library a dependency.
Comment #7
Johan den Hollander CreditAttribution: Johan den Hollander at Finalist commentedTested #4. The mediabrowser is functioning with D9.
Comment #8
Johan den Hollander CreditAttribution: Johan den Hollander at Finalist commentedStill needed this patch in 2.0-beta-2
It works well with the patch. It does't work at all without the patch.
Comment #9
Johan den Hollander CreditAttribution: Johan den Hollander at Finalist commentedComment #10
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedThanks for pushing this forward. Unfortunately we still need to resolve my comment in #6 where I like to hear the maintainers step into the discussion.
Patch #4 currently only works when the media library module is enabled. Means it's an implicit dependency, which either would need to be added explicitly or worked around.
Comment #11
natted CreditAttribution: natted commentedPatch #4 worked for me. I'm not a maintainer but I will chime in.
Is there a reason why media library wouldn't be a required dependency?
The first thing I did when testing the Gutenberg module is try to add Images/Cover blocks etc. This is the type of functionality that Wordpress has out of the box. Perhaps the idea is for a stripped down Gutenberg (letting site builders control content editing) - I am not sure if this is what the maintainers intend? However, from my perspective: the most obvious use case for Gutenberg within Drupal is to have an editor like that of Wordpress - wouldn't media library be essential then?
Comment #12
Johan den Hollander CreditAttribution: Johan den Hollander commentedAs seen in this commit Media module should be a requirement.
Comment #13
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedThank you for the observation. Then it's probably alright to make both media and media_library a dependency.
Comment #14
Johan den Hollander CreditAttribution: Johan den Hollander commentedJust did a quick test agains 2.0.0-beta2, the patch does not apply.
Will check later if 2.x needs a different patch.
Comment #15
Johan den Hollander CreditAttribution: Johan den Hollander commentedThe patch does work on 2.x-dev.
Should be ok to commit then.
Comment #16
Johan den Hollander CreditAttribution: Johan den Hollander commentedComment #17
kjankowski CreditAttribution: kjankowski at Frontkom commentedThanks for your work and the insightful discussion.
We don't want to drop support for non-media-library applications, so it's better to avoid making media and media_library dependencies.
The commit mentioned in #12 doesn't make media a dependency as Media API is in core anyway.
Here's a patch that adds
media_library.opener_resolver
as an optional argument to servicegutenberg.media_library.ui_builder
. You can check Symfony docs on that here.Comment #18
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedThat's a good solution and works like charm.
Comment #19
flyke CreditAttribution: flyke commentedJust to inform that patch #17 fixes the issue and also works on Gutenberg 1.11
Comment #20
Claudio Fabio Mazzarago CreditAttribution: Claudio Fabio Mazzarago commentedHi,
it doesn't work for me.
I try to apply all of patch in this page.
Drupal 9.1.0
Gutenberg 8.x-2.0-beta2
any suggestions?
thanks so much.
Edit: Now the patch work. I needed to clear the cache.
My apoligize for that and thanks for patch!!!
Comment #21
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedDid the patch not apply for you or do you still see a blank window? Do you get any error logged? Have you cleared the cache after applying the patch?
Comment #22
Johan den Hollander CreditAttribution: Johan den Hollander commentedThe patch should be applied to the DEV version.
Comment #23
mountcrowthe patch works for me with:
Drupal 9.1.0
Gutenberg 1.11
Comment #24
janoka CreditAttribution: janoka at BORN Commerce commentedI tested the latest patch with:
I didn't get a blank page anymore.
It works for me perfecly. Thanks!
Comment #25
pelatho CreditAttribution: pelatho commentedUhm... I seem to have this problem even on Drupal 9.1.2, Gutenberg Editor 2.0.0-beta2 :\
Edit: OH, this patch is not in Gutenberg 2.0.0-beta2?
Comment #26
T-Ortan CreditAttribution: T-Ortan as a volunteer commentedI tested the latest patch with:
Drupal core 9.1.2
Gutenberg Editor 8.x-2.0-beta2
This patch didn't work for 8.x-2.0-beta2 (as stated), after downgrading to Gutenberg 8.x-1.11 the latest patch fixed the problem!
Thanks
Comment #27
roborn CreditAttribution: roborn at Frontkom commentedComment #28
henrikakselsen CreditAttribution: henrikakselsen at Frontkom commentedTested on a fresh install on Drupal 8.9.13 with 8.x-2.0-beta2 and it seems to work for me without any need for patch
Comment #30
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedThe issue happens on Drupal 9
Comment #32
kjankowski CreditAttribution: kjankowski at Frontkom commentedExactly, it happens because of changes in Media Library in Drupal 9.
Committed patch on 8.x-1.x and 8.x-2.x.
Comment #33
kjankowski CreditAttribution: kjankowski at Frontkom commented