Skip to content

Commit 22c2ceb

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feature/rich-text-formats
2 parents 0e3599a + e57deec commit 22c2ceb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2578
-1908
lines changed

.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ gutenberg
33
symlinked-packages-in-parent
44
react-native-aztec
55
bundle
6-
6+
react-native-aztec-old-submodule

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "gutenberg"]
22
path = gutenberg
33
url = ../../WordPress/gutenberg.git
4+
[submodule "react-native-aztec"]
5+
path = react-native-aztec-old-submodule
6+
url = ../react-native-aztec.git
File renamed without changes.

bin/generate-podspecs.sh

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ node_modules/react-native/ReactCommon/yoga/yoga.podspec
1616
node_modules/react-native/third-party-podspecs/Folly.podspec
1717
node_modules/react-native/third-party-podspecs/DoubleConversion.podspec
1818
node_modules/react-native/third-party-podspecs/glog.podspec
19-
react-native-aztec/RNTAztecView.podspec
2019
EOP
2120
)
2221

bundle/android/App.js

+906-881
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/android/App.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/ios/App.js

+912-887
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/ios/App.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ios/gutenberg.xcodeproj/project.pbxproj

+37
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
F151983C2100DC3D000F6E97 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F15198392100DC3D000F6E97 /* AppDelegate.swift */; };
4646
F151983D2100DC3D000F6E97 /* MediaProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = F151983A2100DC3D000F6E97 /* MediaProvider.swift */; };
4747
F19CFDA821021EB100EAB240 /* Aztec.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = F1289ECA2100E4320091E81D /* Aztec.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
48+
F1EE6F7821E7F0A500241744 /* NotoSerif-BoldItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = F1EE6F7421E7F0A500241744 /* NotoSerif-BoldItalic.ttf */; };
49+
F1EE6F7921E7F0A500241744 /* NotoSerif-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = F1EE6F7521E7F0A500241744 /* NotoSerif-Regular.ttf */; };
50+
F1EE6F7A21E7F0A500241744 /* NotoSerif-Italic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = F1EE6F7621E7F0A500241744 /* NotoSerif-Italic.ttf */; };
51+
F1EE6F7B21E7F0A500241744 /* NotoSerif-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = F1EE6F7721E7F0A500241744 /* NotoSerif-Bold.ttf */; };
52+
FF9A6F4121FA8E2500D36D14 /* MediaPickAndUploadCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF9A6F1621FA8E2500D36D14 /* MediaPickAndUploadCoordinator.swift */; };
4853
/* End PBXBuildFile section */
4954

5055
/* Begin PBXContainerItemProxy section */
@@ -423,7 +428,12 @@
423428
F15198372100DC3C000F6E97 /* gutenberg-Bridging-Header.h */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = "gutenberg-Bridging-Header.h"; sourceTree = "<group>"; tabWidth = 1; };
424429
F15198392100DC3D000F6E97 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = gutenberg/AppDelegate.swift; sourceTree = "<group>"; tabWidth = 1; };
425430
F151983A2100DC3D000F6E97 /* MediaProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; name = MediaProvider.swift; path = gutenberg/MediaProvider.swift; sourceTree = "<group>"; tabWidth = 1; usesTabs = 0; };
431+
F1EE6F7421E7F0A500241744 /* NotoSerif-BoldItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NotoSerif-BoldItalic.ttf"; sourceTree = "<group>"; };
432+
F1EE6F7521E7F0A500241744 /* NotoSerif-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NotoSerif-Regular.ttf"; sourceTree = "<group>"; };
433+
F1EE6F7621E7F0A500241744 /* NotoSerif-Italic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NotoSerif-Italic.ttf"; sourceTree = "<group>"; };
434+
F1EE6F7721E7F0A500241744 /* NotoSerif-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NotoSerif-Bold.ttf"; sourceTree = "<group>"; };
426435
F619623252704B46A619C33C /* RNTAztecView.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNTAztecView.xcodeproj; path = "../react-native-aztec/ios/RNTAztecView.xcodeproj"; sourceTree = "<group>"; };
436+
FF9A6F1621FA8E2500D36D14 /* MediaPickAndUploadCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MediaPickAndUploadCoordinator.swift; path = gutenberg/MediaPickAndUploadCoordinator.swift; sourceTree = "<group>"; };
427437
/* End PBXFileReference section */
428438

429439
/* Begin PBXFrameworksBuildPhase section */
@@ -574,6 +584,7 @@
574584
F15198372100DC3C000F6E97 /* gutenberg-Bridging-Header.h */,
575585
F15198392100DC3D000F6E97 /* AppDelegate.swift */,
576586
7EC7328E21907E3F00FED2E6 /* GutenbergViewController.swift */,
587+
FF9A6F1621FA8E2500D36D14 /* MediaPickAndUploadCoordinator.swift */,
577588
F151983A2100DC3D000F6E97 /* MediaProvider.swift */,
578589
13B07FB51A68108700A75B9A /* Images.xcassets */,
579590
13B07FB61A68108700A75B9A /* Info.plist */,
@@ -678,6 +689,7 @@
678689
isa = PBXGroup;
679690
children = (
680691
13B07FAE1A68108700A75B9A /* gutenberg */,
692+
F1EE6F7221E7F0A500241744 /* resources */,
681693
832341AE1AAA6A7D00B99B32 /* Libraries */,
682694
00E356EF1AD99517003FC87E /* gutenbergTests */,
683695
83CBBA001A601CBA00E9B192 /* Products */,
@@ -744,6 +756,26 @@
744756
name = Products;
745757
sourceTree = "<group>";
746758
};
759+
F1EE6F7221E7F0A500241744 /* resources */ = {
760+
isa = PBXGroup;
761+
children = (
762+
F1EE6F7321E7F0A500241744 /* fonts */,
763+
);
764+
name = resources;
765+
path = ../resources;
766+
sourceTree = "<group>";
767+
};
768+
F1EE6F7321E7F0A500241744 /* fonts */ = {
769+
isa = PBXGroup;
770+
children = (
771+
F1EE6F7421E7F0A500241744 /* NotoSerif-BoldItalic.ttf */,
772+
F1EE6F7521E7F0A500241744 /* NotoSerif-Regular.ttf */,
773+
F1EE6F7621E7F0A500241744 /* NotoSerif-Italic.ttf */,
774+
F1EE6F7721E7F0A500241744 /* NotoSerif-Bold.ttf */,
775+
);
776+
path = fonts;
777+
sourceTree = "<group>";
778+
};
747779
FFEDF6EF21241BDF007FCC6D /* Products */ = {
748780
isa = PBXGroup;
749781
children = (
@@ -1266,7 +1298,11 @@
12661298
buildActionMask = 2147483647;
12671299
files = (
12681300
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
1301+
F1EE6F7B21E7F0A500241744 /* NotoSerif-Bold.ttf in Resources */,
1302+
F1EE6F7921E7F0A500241744 /* NotoSerif-Regular.ttf in Resources */,
1303+
F1EE6F7A21E7F0A500241744 /* NotoSerif-Italic.ttf in Resources */,
12691304
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
1305+
F1EE6F7821E7F0A500241744 /* NotoSerif-BoldItalic.ttf in Resources */,
12701306
);
12711307
runOnlyForDeploymentPostprocessing = 0;
12721308
};
@@ -1332,6 +1368,7 @@
13321368
buildActionMask = 2147483647;
13331369
files = (
13341370
F151983C2100DC3D000F6E97 /* AppDelegate.swift in Sources */,
1371+
FF9A6F4121FA8E2500D36D14 /* MediaPickAndUploadCoordinator.swift in Sources */,
13351372
F151983D2100DC3D000F6E97 /* MediaProvider.swift in Sources */,
13361373
7EC7328F21907E3F00FED2E6 /* GutenbergViewController.swift in Sources */,
13371374
);

ios/gutenberg/GutenbergViewController.swift

+35-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class GutenbergViewController: UIViewController {
77

88
fileprivate lazy var gutenberg = Gutenberg(dataSource: self)
99
fileprivate var htmlMode = false
10-
10+
fileprivate var mediaPickAndUploadCoordinator: MediaPickAndUploadCoordinator?
11+
1112
override func loadView() {
1213
view = gutenberg.rootView
1314
}
@@ -29,24 +30,51 @@ class GutenbergViewController: UIViewController {
2930
}
3031

3132
extension GutenbergViewController: GutenbergBridgeDelegate {
32-
func gutenbergDidLoad() {
3333

34+
func gutenbergDidLoad() {
35+
3436
}
3537

36-
func gutenbergDidProvideHTML(_ html: String, changed: Bool) {
37-
print("Did receive HTML: \(html) changed: \(changed)")
38+
func gutenbergDidProvideHTML(title: String, html: String, changed: Bool) {
39+
print("didProvideHTML:")
40+
print("↳ Content changed: \(changed)")
41+
print("↳ Title: \(title)")
42+
print("↳ HTML: \(html)")
43+
}
44+
45+
func gutenbergDidRequestMedia(from source: MediaPickerSource, with callback: @escaping MediaPickerDidPickMediaCallback) {
46+
switch source {
47+
case .mediaLibrary:
48+
print("Gutenberg did request media picker, passing a sample url in callback")
49+
callback(1, "https://cldup.com/cXyG__fTLN.jpg")
50+
case .deviceLibrary:
51+
print("Gutenberg did request a device media picker, opening the device picker")
52+
mediaPickAndUploadCoordinator = MediaPickAndUploadCoordinator(presenter: self, gutenberg: gutenberg, mediaCallback: callback, finishCallback: {
53+
self.mediaPickAndUploadCoordinator = nil
54+
} )
55+
mediaPickAndUploadCoordinator?.pickAndUpload(from: .savedPhotosAlbum)
56+
case .deviceCamera:
57+
print("Gutenberg did request a device media picker, opening the camera picker")
58+
mediaPickAndUploadCoordinator = MediaPickAndUploadCoordinator(presenter: self, gutenberg: gutenberg, mediaCallback: callback, finishCallback: {
59+
self.mediaPickAndUploadCoordinator = nil
60+
} )
61+
mediaPickAndUploadCoordinator?.pickAndUpload(from: .camera)
62+
}
3863
}
3964

40-
func gutenbergDidRequestMediaPicker(with callback: @escaping MediaPickerDidPickMediaCallback) {
41-
print("Gutenberg did request media picker, passing a sample url in callback")
42-
callback("https://cldup.com/cXyG__fTLN.jpg")
65+
func gutenbergDidRequestMediaUploadSync() {
66+
print("Gutenberg request for media uploads to be resync")
4367
}
4468
}
4569

4670
extension GutenbergViewController: GutenbergBridgeDataSource {
4771
func gutenbergInitialContent() -> String? {
4872
return nil
4973
}
74+
75+
func gutenbergInitialTitle() -> String? {
76+
return nil
77+
}
5078

5179
func aztecAttachmentDelegate() -> TextViewAttachmentDelegate {
5280
return ExampleAttachmentDelegate()

ios/gutenberg/Info.plist

+18-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>UIAppFonts</key>
6+
<array>
7+
<string>NotoSerif-BoldItalic.ttf</string>
8+
<string>NotoSerif-Regular.ttf</string>
9+
<string>NotoSerif-Italic.ttf</string>
10+
<string>NotoSerif-Bold.ttf</string>
11+
</array>
512
<key>CFBundleDevelopmentRegion</key>
613
<string>en</string>
714
<key>CFBundleDisplayName</key>
@@ -39,9 +46,18 @@
3946
<key>UIViewControllerBasedStatusBarAppearance</key>
4047
<false/>
4148
<key>NSLocationWhenInUseUsageDescription</key>
42-
<string></string>
49+
<string>The app would like to add your location to posts on sites where you have enabled geotagging.</string>
50+
<key>NSCameraUsageDescription</key>
51+
<string>To take photos or videos to use in your posts.</string>
52+
<key>NSLocationUsageDescription</key>
53+
<string>The app would like to add your location to posts on sites where you have enabled geotagging.</string>
54+
<key>NSMicrophoneUsageDescription</key>
55+
<string>Enable microphone access to record sound in your videos.</string>
56+
<key>NSPhotoLibraryUsageDescription</key>
57+
<string>To add photos or videos to your posts.</string>
58+
<key>NSPhotoLibraryAddUsageDescription</key>
59+
<string>To add photos or videos to your posts.</string>
4360
<key>NSAppTransportSecurity</key>
44-
<!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->
4561
<dict>
4662
<key>NSExceptionDomains</key>
4763
<dict>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
2+
import Foundation
3+
import UIKit
4+
import RNReactNativeGutenbergBridge
5+
6+
class MediaPickAndUploadCoordinator: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
7+
8+
private let presenter: UIViewController
9+
private let mediaCallback: MediaPickerDidPickMediaCallback
10+
private let gutenberg: Gutenberg
11+
12+
init(presenter: UIViewController,
13+
gutenberg: Gutenberg,
14+
mediaCallback: @escaping MediaPickerDidPickMediaCallback,
15+
finishCallback: @escaping () -> Void) {
16+
self.presenter = presenter
17+
self.gutenberg = gutenberg
18+
self.mediaCallback = mediaCallback
19+
}
20+
21+
func pickAndUpload(from source: UIImagePickerController.SourceType) {
22+
guard UIImagePickerController.isSourceTypeAvailable(source) else {
23+
// Camera not available, bound to happen in the simulator
24+
mediaCallback(nil, nil)
25+
return
26+
}
27+
let pickerController = UIImagePickerController()
28+
pickerController.sourceType = source
29+
pickerController.delegate = self
30+
presenter.show(pickerController, sender: nil)
31+
}
32+
33+
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
34+
presenter.dismiss(animated: true, completion: nil)
35+
mediaCallback(nil, nil)
36+
}
37+
38+
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
39+
presenter.dismiss(animated: true, completion: nil)
40+
let mediaID = UUID().uuidString
41+
let url = URL(fileURLWithPath: NSTemporaryDirectory() + mediaID + ".jpg")
42+
guard
43+
let image = info[UIImagePickerControllerOriginalImage] as? UIImage,
44+
let data = UIImageJPEGRepresentation(image, 1.0)
45+
else {
46+
return
47+
}
48+
do {
49+
try data.write(to: url)
50+
mediaCallback(mediaID.hashValue, url.absoluteString)
51+
let progress = Progress(parent: nil, userInfo: [ProgressUserInfoKey.mediaID: mediaID, ProgressUserInfoKey.mediaURL: url])
52+
progress.totalUnitCount = 100
53+
54+
Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(timerFireMethod(_:)), userInfo: progress, repeats: true)
55+
} catch {
56+
mediaCallback(nil, nil)
57+
}
58+
}
59+
60+
@objc func timerFireMethod(_ timer: Timer) {
61+
guard let progress = timer.userInfo as? Progress,
62+
let mediaID = progress.userInfo[.mediaID] as? String,
63+
let mediaURL = progress.userInfo[.mediaURL] as? URL
64+
//let otherURL = URL(string: "https://cldup.com/cXyG__fTLN.jpg")
65+
else {
66+
timer.invalidate()
67+
return
68+
}
69+
progress.completedUnitCount += 1
70+
71+
if progress.fractionCompleted < 1 {
72+
gutenberg.mediaUploadUpdate(id: mediaID.hashValue, state: .uploading, progress: Float(progress.fractionCompleted), url: nil, serverID: nil)
73+
} else if progress.fractionCompleted >= 1 {
74+
timer.invalidate()
75+
gutenberg.mediaUploadUpdate(id: mediaID.hashValue, state: .succeeded, progress: 1, url: mediaURL, serverID: 124)
76+
}
77+
}
78+
}
79+
80+
extension ProgressUserInfoKey {
81+
static let mediaID = ProgressUserInfoKey("mediaID")
82+
static let mediaURL = ProgressUserInfoKey("mediaURL")
83+
}

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = {
2323
'/gutenberg/packages/',
2424
],
2525
testURL: 'http://localhost/',
26-
modulePathIgnorePatterns: [ '<rootDir>/gutenberg/gutenberg-mobile' ],
26+
modulePathIgnorePatterns: [ '<rootDir>/gutenberg/gutenberg-mobile', 'react-native-aztec-old-submodule' ],
2727
moduleDirectories: [ 'node_modules', 'symlinked-packages' ],
2828
moduleNameMapper: {
2929
// Mock the CSS modules. See https://facebook.github.io/jest/docs/en/webpack.html#handling-static-assets

jest/setup.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ jest.mock( '../react-native-gutenberg-bridge', () => {
44
removeEventListener: jest.fn(),
55
subscribeParentGetHtml: jest.fn(),
66
subscribeParentToggleHTMLMode: jest.fn(),
7+
subscribeSetTitle: jest.fn(),
78
subscribeUpdateHtml: jest.fn(),
89
};
910
} );

jitpack.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
before_install:
2+
- yes | $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-27"
3+
- yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;27.0.3"
14
install:
25
- echo "Changing into the android folder of the Bridge module"
36
- pushd react-native-gutenberg-bridge/android && ./gradlew --stacktrace clean -Pgroup=com.github.wordpress-mobile.gutenberg-mobile -Pversion=$VERSION install && popd

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gutenberg-mobile",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"private": true,
55
"config": {
66
"jsfiles": "./*.js src/*.js src/**/*.js src/**/**/*.js",

react-native-aztec/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## Notice: We have git subtree'd this repo into https://github.com/wordpress-mobile/gutenberg-mobile. It is recommended that any new development happens on that one instead. Thanks!
2+
13
# react-native-aztec
24

35
Wrapping Aztec Android and Aztec iOS in a React Native component

react-native-aztec/android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ buildscript {
1212
wordpressUtilsVersion = '1.22'
1313
espressoVersion = '3.0.1'
1414

15-
aztecVersion = 'v1.3.14'
15+
aztecVersion = 'v1.3.18'
1616
}
1717

1818
repositories {

0 commit comments

Comments
 (0)