Repository navigation
Rnmobile/upload media file - #13128
Conversation
Add upload media file callback Show spinner and opacity when image is uploading
| style={ { textAlign: 'center' } } | ||
| underlineColorAndroid="transparent" | ||
| value={ caption } | ||
| placeholder={ 'Write caption…' } |
There was a problem hiding this comment.
This could be passed through i18n, like _( 'Write caption...' )
| { toolbarEditButton } | ||
| </BlockControls> | ||
| <Image | ||
| style={ { width: '100%', height: 200, opacity: opacity } } |
There was a problem hiding this comment.
I can see this value was there before this change, but wondering why height: 200, is there anything specific to that value?
There was a problem hiding this comment.
Maybe we can ask @etoledom about this one, as this change was made a long time ago?
| const toolbarEditButton = ( | ||
| <Toolbar> | ||
| <ToolbarButton | ||
| className="components-toolbar__control" |
There was a problem hiding this comment.
is there a reason for having a double underscore "__" in this name? should it be a normal dash?
There was a problem hiding this comment.
It is part of the CSS coding standards for Gutenberg. I would ask if we actually need the className in the native implementation
There was a problem hiding this comment.
Yeah, thanks @koke. We don't need that one, I removed it.
There was a problem hiding this comment.
It is part of the CSS coding standards for Gutenberg.
TIL - thanks @koke
| ); | ||
|
|
||
| const http = 'http'; | ||
| const showSpinner = url !== undefined ? ! url.includes( http ) : false; |
There was a problem hiding this comment.
can we perhaps extend this logic to a more generic Utils class or if not, at least method on its own? I'm thinking something more explicit like isRemoteUrl() that hides the logic inside to determine whether an URI is a remote resource or not, etc. Such const http constant should belong within the scope of such function only, etc.
There was a problem hiding this comment.
See for reference https://github.com/wordpress-mobile/WordPress-Android/pull/8879/files#diff-02f567e707c1df878dfea548cfec3da7R453, this:
URLUtil.isNetworkUrl(mediaUrl)
as in Android's utils https://developer.android.com/reference/android/webkit/URLUtil#isNetworkUrl(java.lang.String)
There was a problem hiding this comment.
You can import { isURL } from '@wordpress/url' 😉
https://github.com/WordPress/gutenberg/blob/master/packages/url/README.md
There was a problem hiding this comment.
Hey @marecar3 ! Thank you for your great work!
I like the idea of leaving all the networking to the parents app, while we use Gutenberg to show the upload state to the user. 👌
I tried a fast implementation on the iOS side of media upload to see if we could have any compatibility issue. Sadly I did found a complication that didn't let me finish it. I explained that on a code comment.
Apart of that it looks good! I also added a small clean up comment but I don't think that is a blocking thing.
One more comment: I was working on another PR (#13096) that modifies the image/edit.native.js file quite a lot too. I think that we will have a big merge conflict there. Let's chat to see what we can do about it. 😛
| } | ||
|
|
||
| addMediaUploadListener( mediaId ) { | ||
| gutenbergBridgeEvents.addListener( 'mediaUpload' + mediaId, this.mediaUpload ); |
There was a problem hiding this comment.
I believe we will have a problem here with iOS. As you can see here, on iOS we need to know ahead of time what events do we support by overriding - (NSArray<NSString *> *)supportedEvents and returning an array with the event names.
Because of that, we can not have dynamic events names like appending the media id to it.
Do you think it would be possible to send the media id as a parameter instead?
There was a problem hiding this comment.
Do you think it would be possible to send the media id as a parameter instead?
Good call there 👍
There was a problem hiding this comment.
Hey @etoledom, thanks for the update. I wasn't aware of this one as this approach was working in some lower version. I will fix this. Thanks for letting me know.
cc: @SergioEstevao
| } | ||
|
|
||
| removeMediaUploadListener( mediaId ) { | ||
| gutenbergBridgeEvents.removeListener( 'mediaUpload' + mediaId, this.mediaUpload ); |
There was a problem hiding this comment.
I think it would be good to hide the implementation of adding/removing listeners inside the react-native-gutenberg-bridge module. Something similar to what we already have in here.
If we can also hide the RNReactNativeGutenbergBridge.onMediaLibraryPress it would be great too. Even though we didn't do it before, probably is good to have all the available communication methods in one place.
There was a problem hiding this comment.
Hey @etoledom, thanks for the comments. I have changed the code as we discussed.
Removed className from ToolbarButton
# Conflicts: # packages/block-library/src/image/edit.native.js
Looking good! Thank you for that. ✨ |
* Add serverID to finish media upload with success event. * Refactor code to have early exit. * Support setting id when selecting from media library.
…rnmobile/372-add-title-to-gutenberg-mobile * 'master' of https://github.com/WordPress/gutenberg: (56 commits) Save package-lock.json file changes (#13481) Plugin: Deprecate gutenberg_add_responsive_body_class (#13461) Add speak messages to the feature toggle component. (#13385) Plugin: Deprecate gutenberg_kses_allowedtags (#13460) Plugin: Deprecate gutenberg_bulk_post_updated_messages (#13472) Plugin: Avoid calling deprecated gutenberg_silence_rest_errors (#13446) Plugin: Deprecate gutenberg_remove_wpcom_markdown_support (#13473) Fix: Categories block: add custom classes only to wrapper (#13439) is-shallow-equal: Use ES5 ruleset from eslint-plugin module (#13428) Update and Organize Contributors Guide per #12916 (#13352) Dismissible-notices: fix text overlapping icon (X) (#13371) Framework: Remove 5.0-merged REST API integrations (#13408) Plugin: Remove 5.0-merged block registration functions, integrations (#13412) Framework: Bump minimum required WP to 5.x (#13370) [Mobile] Improve keyboard hide button (#13415) Improve castError handling of non strings (#13315) Fix: File block add custom class (#13432) Consider making Fullscreen Mode effects visible only on larger screens (#13425) Update plugin version to 4.9.0 (#13436) DateTimePicker: fix prop warning for (#12933) ...
…le/upload_media_file
*Upload captured photo
Description
This is the supporting PR for upload image file from react native Gutenberg editor
How has this been tested?
This PR can be tested from WPAndroid PR
Screenshots