Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Gutenberg/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
#
# LOCAL_GUTENBERG=../my-gutenberg-fork bundle exec pod install
ref:
tag: v1.110.0
commit: 2adb610d0dc192e2e18a66c03852d37a92461cc7
github_org: wordpress-mobile
repo_name: gutenberg-mobile
12 changes: 4 additions & 8 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ PODS:
- FSInteractiveMap (0.1.0)
- Gifu (3.3.1)
- Gridicons (1.2.0)
- Gutenberg (1.110.0)
- Gutenberg (1.108.0)
- JTAppleCalendar (8.0.5)
- Kanvas (1.4.9):
- CropViewController
Expand Down Expand Up @@ -107,7 +107,7 @@ DEPENDENCIES:
- FSInteractiveMap (from `https://github.com/wordpress-mobile/FSInteractiveMap.git`, tag `0.2.0`)
- Gifu (= 3.3.1)
- Gridicons (~> 1.2)
- Gutenberg (from `https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-v1.110.0.podspec`)
- Gutenberg (from `https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-2adb610d0dc192e2e18a66c03852d37a92461cc7.podspec`)
- JTAppleCalendar (~> 8.0.5)
- Kanvas (~> 1.4.4)
- MediaEditor (>= 1.2.2, ~> 1.2)
Expand Down Expand Up @@ -176,16 +176,12 @@ EXTERNAL SOURCES:
:git: https://github.com/wordpress-mobile/FSInteractiveMap.git
:tag: 0.2.0
Gutenberg:
:podspec: https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-v1.110.0.podspec
:podspec: https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-2adb610d0dc192e2e18a66c03852d37a92461cc7.podspec

CHECKOUT OPTIONS:
FSInteractiveMap:
:git: https://github.com/wordpress-mobile/FSInteractiveMap.git
:tag: 0.2.0
Gutenberg:
:git: https://github.com/wordpress-mobile/gutenberg-mobile.git
:submodules: true
:tag: v1.100.2

SPEC CHECKSUMS:
Alamofire: 3ec537f71edc9804815215393ae2b1a8ea33a844
Expand All @@ -199,7 +195,7 @@ SPEC CHECKSUMS:
FSInteractiveMap: a396f610f48b76cb540baa87139d056429abda86
Gifu: 416d4e38c4c2fed012f019e0a1d3ffcb58e5b842
Gridicons: 4455b9f366960121430e45997e32112ae49ffe1d
Gutenberg: 0e64ef7d9c46ba0a681c82f5969622f3db9bf033
Gutenberg: d307b15bdf6c82f499774e1f73d0491b8916fa1a
JTAppleCalendar: 16c6501b22cb27520372c28b0a2e0b12c8d0cd73
Kanvas: cc027f8058de881a4ae2b5aa5f05037b6d054d08
MediaEditor: d08314cfcbfac74361071a306b4bc3a39b3356ae
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import WordPressFlux
import Kanvas
import React

class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelegate, PublishingEditor {
class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelegate, PublishingEditor, UIDropInteractionDelegate {
let errorDomain: String = "GutenbergViewController.errorDomain"

enum RequestHTMLReason {
Expand Down Expand Up @@ -355,6 +355,53 @@ class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelega
}, failure: { (error) in
DDLogError("Error syncing JETPACK: \(String(describing: error))")
})

let dropInteraction = UIDropInteraction(delegate: self)
view.addInteraction(dropInteraction)
}

func saveToDisk(image: UIImage) -> URL? {
let fileName = "\(ProcessInfo.processInfo.globallyUniqueString)_file.jpg"

guard let data = image.jpegData(compressionQuality: 0.9) else {
return nil
}

let fileURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(fileName)

guard (try? data.write(to: fileURL, options: [.atomic])) != nil else {
return nil
}

return fileURL
}

func dropInteraction(_ interaction: UIDropInteraction, canHandle session: UIDropSession) -> Bool {
return session.canLoadObjects(ofClass: UIImage.self)
}

func dropInteraction(_ interaction: UIDropInteraction, sessionDidUpdate session: UIDropSession) -> UIDropProposal {
let dropLocation = session.location(in: view)
self.gutenberg.filesOver(coords: dropLocation)
return UIDropProposal(operation: .copy)
}

func dropInteraction(_ interaction: UIDropInteraction, performDrop session: UIDropSession) {
session.loadObjects(ofClass: UIImage.self) { items in
guard let images = items as? [UIImage] else {
return
}
let imagesURLs = images.compactMap({ self.saveToDisk(image: $0)?.absoluteString })
self.gutenberg.filesDrop(imagesURLs)
}
}

func dropInteraction(_ interaction: UIDropInteraction, sessionDidExit session: UIDropSession) {
self.gutenberg.filesDropOutside()
}

func dropInteraction(_ interaction: UIDropInteraction, sessionDidEnd session: UIDropSession) {
self.gutenberg.filesDropEnded()
}

override func viewWillAppear(_ animated: Bool) {
Expand Down
20 changes: 10 additions & 10 deletions WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10767,7 +10767,7 @@
path = Classes;
sourceTree = "<group>";
};
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
29B97314FDCFA39411CA2CEA = {
isa = PBXGroup;
children = (
3F20FDF3276BF21000DA3CAD /* Packages */,
Expand Down Expand Up @@ -19113,13 +19113,13 @@
bg,
sk,
);
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
mainGroup = 29B97314FDCFA39411CA2CEA;
packageReferences = (
3FF1442E266F3C2400138163 /* XCRemoteSwiftPackageReference "ScreenObject" */,
3FC2C33B26C4CF0A00C6D98F /* XCRemoteSwiftPackageReference "XCUITestHelpers" */,
17A8858B2757B97F0071FCA3 /* XCRemoteSwiftPackageReference "AutomatticAbout-swift" */,
3F3B23C02858A1B300CACE60 /* XCRemoteSwiftPackageReference "test-collector-swift" */,
3F411B6D28987E3F002513AE /* XCRemoteSwiftPackageReference "lottie-ios" */,
3F411B6D28987E3F002513AE /* XCRemoteSwiftPackageReference "lottie-ios.git" */,
3F338B6F289BD3040014ADC5 /* XCRemoteSwiftPackageReference "Nimble" */,
0CD9FB852AFA71B9009D9C7A /* XCRemoteSwiftPackageReference "Charts" */,
);
Expand Down Expand Up @@ -20700,11 +20700,11 @@
files = (
);
inputPaths = (
$SRCROOT/../Scripts/BuildPhases/CopyGutenbergJS.inputs.xcfilelist,
"$SRCROOT/../Scripts/BuildPhases/CopyGutenbergJS.inputs.xcfilelist",
);
name = "Copy Gutenberg JS";
outputFileListPaths = (
$SRCROOT/../Scripts/BuildPhases/CopyGutenbergJS.outputs.xcfilelist,
"$SRCROOT/../Scripts/BuildPhases/CopyGutenbergJS.outputs.xcfilelist",
);
outputPaths = (
"",
Expand Down Expand Up @@ -20893,13 +20893,13 @@
files = (
);
inputFileListPaths = (
$SRCROOT/../Scripts/BuildPhases/CopyGutenbergJS.inputs.xcfilelist,
"$SRCROOT/../Scripts/BuildPhases/CopyGutenbergJS.inputs.xcfilelist",
);
inputPaths = (
);
name = "Copy Gutenberg JS";
outputFileListPaths = (
$SRCROOT/../Scripts/BuildPhases/CopyGutenbergJS.outputs.xcfilelist,
"$SRCROOT/../Scripts/BuildPhases/CopyGutenbergJS.outputs.xcfilelist",
);
outputPaths = (
);
Expand Down Expand Up @@ -30298,7 +30298,7 @@
minimumVersion = 0.3.0;
};
};
3F411B6D28987E3F002513AE /* XCRemoteSwiftPackageReference "lottie-ios" */ = {
3F411B6D28987E3F002513AE /* XCRemoteSwiftPackageReference "lottie-ios.git" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/airbnb/lottie-ios.git";
requirement = {
Expand Down Expand Up @@ -30387,12 +30387,12 @@
};
3F411B6E28987E3F002513AE /* Lottie */ = {
isa = XCSwiftPackageProductDependency;
package = 3F411B6D28987E3F002513AE /* XCRemoteSwiftPackageReference "lottie-ios" */;
package = 3F411B6D28987E3F002513AE /* XCRemoteSwiftPackageReference "lottie-ios.git" */;
productName = Lottie;
};
3F44DD57289C379C006334CD /* Lottie */ = {
isa = XCSwiftPackageProductDependency;
package = 3F411B6D28987E3F002513AE /* XCRemoteSwiftPackageReference "lottie-ios" */;
package = 3F411B6D28987E3F002513AE /* XCRemoteSwiftPackageReference "lottie-ios.git" */;
productName = Lottie;
};
3F9F23242B0AE1AC00B56061 /* JetpackStatsWidgetsCore */ = {
Expand Down