-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rnmobile/upload media file #13128
Rnmobile/upload media file #13128
Conversation
Add upload media file callback Show spinner and opacity when image is uploading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again nice job @marecar3 , left some comments!
style={ { textAlign: 'center' } } | ||
underlineColorAndroid="transparent" | ||
value={ caption } | ||
placeholder={ 'Write caption…' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be passed through i18n, like _( 'Write caption...' )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mzorz ! Fixed and pushed.
{ toolbarEditButton } | ||
</BlockControls> | ||
<Image | ||
style={ { width: '100%', height: 200, opacity: opacity } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can ask @etoledom about this one, as this change was made a long time ago?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const toolbarEditButton = ( | ||
<Toolbar> | ||
<ToolbarButton | ||
className="components-toolbar__control" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, thanks @koke. We don't need that one, I removed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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