Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
67d2796
Fix request import to send the correct information.
SergioEstevao Oct 24, 2019
b8f574b
Make MediaInfo properties public
SergioEstevao Oct 24, 2019
7a5f155
Update gutenberg ref
etoledom Oct 25, 2019
65964a8
Update release notes.
SergioEstevao Oct 25, 2019
bb8d92a
Update RELEASE-NOTES.txt
etoledom Oct 25, 2019
6dfba3d
Update gutenberg ref
etoledom Oct 25, 2019
2abde85
Merge pull request #1495 from wordpress-mobile/issue/fix-block-picker…
etoledom Oct 25, 2019
d65c7f9
Add left right borders to inner blocks (#1496)
pinarol Oct 25, 2019
f190247
Remove alignment options from Media & Text until they are fixed (#1500)
pinarol Oct 25, 2019
9624986
Add extension to encode MediaInfo to JS.
SergioEstevao Oct 25, 2019
a4bab40
Merge branch 'release/1.15.2' into issue/fix_request_import_on_bridge
SergioEstevao Oct 25, 2019
e243459
Merge pull request #1494 from wordpress-mobile/issue/fix_request_impo…
etoledom Oct 28, 2019
59022ee
Update JS Bundles
etoledom Oct 28, 2019
73c2873
Bump version to 1.15.2
etoledom Oct 28, 2019
1811d84
[FIX] Scroll position android (#1478)
dratwas Oct 28, 2019
c1f86ea
Update gutenberg ref
etoledom Oct 28, 2019
f42bc54
Fix: Media & Text Loses upload status if post is closed/reopened duri…
pinarol Oct 29, 2019
d502c46
Update JS Bundles
etoledom Oct 29, 2019
649a22a
Update gutenberg ref
etoledom Oct 29, 2019
6e4b4f2
Update bundles
mchowning Oct 29, 2019
6865978
Merge pull request #1503 from wordpress-mobile/release/1.15.2
mchowning Oct 29, 2019
4ed5523
Merge remote-tracking branch 'origin/develop' into master_develop_1.1…
mchowning Oct 29, 2019
0f0bde6
Update gutenberg ref
etoledom Oct 30, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
* Add support for pexels images
* Add left, center, and right image alignment controls

1.15.2
------
* Fix issue when copy/paste photos from other apps, was not inserting an image on the post.
* Fix issue where the block inserter layout wasn't correct after device rotation.

1.15.0
------
* Fix issue when multiple media selection adds only one image or video block on Android
Expand Down
116 changes: 58 additions & 58 deletions bundle/android/App.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/App.js.map

Large diffs are not rendered by default.

116 changes: 58 additions & 58 deletions bundle/ios/App.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/App.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gutenberg
18 changes: 10 additions & 8 deletions ios/gutenberg/GutenbergViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@ extension GutenbergViewController: GutenbergBridgeDelegate {
switch currentFilter {
case .image:
if(allowMultipleSelection) {
callback([(1, "https://cldup.com/cXyG__fTLN.jpg", "image"), (3, "https://cldup.com/cXyG__fTLN.jpg", "image")])
callback([MediaInfo(id: 1, url: "https://cldup.com/cXyG__fTLN.jpg", type: "image"),
MediaInfo(id: 3, url: "https://cldup.com/cXyG__fTLN.jpg", type: "image")])
} else {
callback([(1, "https://cldup.com/cXyG__fTLN.jpg", "image")])
callback([MediaInfo(id: 1, url: "https://cldup.com/cXyG__fTLN.jpg", type: "image")])
}
case .video:
if(allowMultipleSelection) {
callback([(2, "https://i.cloudup.com/YtZFJbuQCE.mov", "video"), (4, "https://i.cloudup.com/YtZFJbuQCE.mov", "video")])
callback([MediaInfo(id: 2, url: "https://i.cloudup.com/YtZFJbuQCE.mov", type: "video"),
MediaInfo(id: 4, url: "https://i.cloudup.com/YtZFJbuQCE.mov", type: "video")])
} else {
callback([(2, "https://i.cloudup.com/YtZFJbuQCE.mov", "video")])
callback([MediaInfo(id: 2, url: "https://i.cloudup.com/YtZFJbuQCE.mov", type: "video")])
}
default:
break
Expand All @@ -96,18 +98,18 @@ extension GutenbergViewController: GutenbergBridgeDelegate {
}
}

func gutenbergDidRequestImport(from url: URL, with callback: @escaping MediaPickerDidPickMediaCallback) {
func gutenbergDidRequestImport(from url: URL, with callback: @escaping MediaImportCallback) {
let id = mediaUploadCoordinator.upload(url: url)
callback([(id, url.absoluteString, "image")])
callback(MediaInfo(id: id, url: url.absoluteString, type: "image"))
}

func pickAndUpload(from source: UIImagePickerController.SourceType, filter: MediaFilter, callback: @escaping MediaPickerDidPickMediaCallback) {
mediaPickCoordinator = MediaPickCoordinator(presenter: self, filter: filter, callback: { (url) in
guard let url = url, let mediaID = self.mediaUploadCoordinator.upload(url: url) else {
callback([(nil, nil, nil)])
callback([MediaInfo(id: nil, url: nil, type: nil)])
return
}
callback([(mediaID, url.absoluteString, "image")])
callback([MediaInfo(id: mediaID, url: url.absoluteString, type: "image")])
self.mediaPickCoordinator = nil
} )
mediaPickCoordinator?.pick(from: source)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gutenberg-mobile",
"version": "1.15.1",
"version": "1.15.2",
"private": true,
"config": {
"jsfiles": "./*.js src/*.js src/**/*.js src/**/**/*.js",
Expand Down
18 changes: 16 additions & 2 deletions react-native-gutenberg-bridge/ios/GutenbergBridgeDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
public typealias MediaPickerDidPickMediaCallback = (_ media: [(Int32?,String?,String?)]?) -> Void
public struct MediaInfo {
public let id: Int32?
public let url: String?
public let type: String?

public init(id: Int32?, url: String?, type: String?) {
self.id = id
self.url = url
self.type = type
}
}

public typealias MediaPickerDidPickMediaCallback = (_ media: [MediaInfo]?) -> Void

public typealias MediaImportCallback = (_ media: MediaInfo?) -> Void

public enum MediaPickerSource: String {
case mediaLibrary = "SITE_MEDIA_LIBRARY"
Expand Down Expand Up @@ -71,7 +85,7 @@ public protocol GutenbergBridgeDelegate: class {
/// - url: the url to import
/// - callback: A callback block to be called with an array of upload mediaIdentifiers and a placeholder images file url, use nil on both parameters to signal that the action has failed.
//
func gutenbergDidRequestImport(from url: URL, with callback: @escaping MediaPickerDidPickMediaCallback)
func gutenbergDidRequestImport(from url: URL, with callback: @escaping MediaImportCallback)

/// Tells the delegate that an image block requested to reconnect with media uploads coordinator.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,20 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter {
callback(nil)
return
}
if (allowMultipleSelection) {
let formattedMedia = media.map { (id, url, type) in
return [mediaDictKeys.IDKey: id, mediaDictKeys.URLKey: url, mediaDictKeys.TypeKey: type]
}
callback([formattedMedia])
let mediaToReturn: [MediaInfo]
if allowMultipleSelection {
mediaToReturn = media
} else {
guard let (mediaID, mediaURL, mediaType) = media.first else {
callback(nil)
return
}
callback([[mediaDictKeys.IDKey: mediaID, mediaDictKeys.URLKey: mediaURL, mediaDictKeys.TypeKey: mediaType]])
mediaToReturn = Array(media.prefix(1))
}

let jsFormattedMedia = mediaToReturn.map { mediaInfo in
return mediaInfo.encodeForJS()
}
if allowMultipleSelection {
callback([jsFormattedMedia])
} else {
callback(jsFormattedMedia)
}
})
}
Expand All @@ -60,12 +63,12 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter {
return
}
DispatchQueue.main.async {
self.delegate?.gutenbergDidRequestImport(from: url, with: { mediaList in
guard let mediaList = mediaList else {
self.delegate?.gutenbergDidRequestImport(from: url, with: { mediaInfo in
guard let mediaInfo = mediaInfo else {
callback(nil)
return
}
callback(mediaList)
}
callback([mediaInfo.id as Any, mediaInfo.url as Any])
})
}
}
Expand Down Expand Up @@ -207,3 +210,14 @@ extension RNReactNativeGutenbergBridge {
static let TypeKey = "type"
}
}

extension MediaInfo {

func encodeForJS() -> [String: Any] {
return [
RNReactNativeGutenbergBridge.mediaDictKeys.IDKey: id as Any,
RNReactNativeGutenbergBridge.mediaDictKeys.URLKey: url as Any,
RNReactNativeGutenbergBridge.mediaDictKeys.TypeKey: type as Any
]
}
}