front / gutenberg-js

JavaScript only version of the WordPress Gutenberg editor (DEPRECATED)
GNU General Public License v2.0
390 stars 42 forks source link

Use original "Medial Library" #31

Closed eugenchio closed 5 years ago

eugenchio commented 5 years ago

First of all, thank you for this great package! Originally in Gutenberg media library opens in a separate window. In Gutenberg-JS it opens a small popup with maximum of 10 images, with no pagination. From what I've found the original media library component is overrode here: https://github.com/front/gutenberg-js/blob/master/src/js/gutenberg-overrides/%40wordpress/edit-post/build-module/hooks/components/media-upload/index.js Am I correct? If yes - what is the purpose of overriding original component and is there a possibility to use the original one?

Qoraiche commented 5 years ago

I don't think this is possible, you need to create a custom media library or use a third party!

eugenchio commented 5 years ago

@Qoraiche , Thanks for reply! Can you please advice me the way of attaching my custom library to the gutenberg-js?

Qoraiche commented 5 years ago

Take a look at front/g-editor i think they already using a simple local media library you can start with it. (@SofiaSousa correct me if i'm wrong)

Hope this helps.

SofiaSousa commented 5 years ago

The original one opens the Wordpress Gallery window, that's why we did the override.

Now there is a filter (editor.MediaUpload) to replace the component.

https://github.com/WordPress/gutenberg/blob/master/packages/edit-post/src/hooks/components/index.js

Check filters docs here: https://github.com/WordPress/gutenberg/tree/master/docs/designers-developers/developers/filters

vonloxx commented 5 years ago

@eugenchio You need to use wp.hooks.addFilter() to add a "editor.MediaUpload" filter. For an example, check how it was done on Drupal Gutenberg module: https://cgit.drupalcode.org/gutenberg/tree/js/filters/media-upload.es6.js

eugenchio commented 5 years ago

@Qoraiche , @SofiaSousa , @vonloxx , Thanks a lot, guys! Will check the docs.