Fix copying/pasting images from Safari on macOS not working
Closes #453
This commit is contained in:
parent
e8ef9345e9
commit
e09935125f
|
@ -157,10 +157,11 @@ extension DraftAttachment: NSItemProviderReading {
|
||||||
var data = data
|
var data = data
|
||||||
var type = UTType(typeIdentifier)!
|
var type = UTType(typeIdentifier)!
|
||||||
|
|
||||||
// this seems to only occur when the item is a UIImage, rather than just image data,
|
// the type is .image in certain circumstances:
|
||||||
// which seems to only occur when sharing a screenshot directly from the markup screen
|
// - macOS: image copied from macOS Safari -> only UIImage(data: data) works
|
||||||
|
// - iOS: sharing screenshot from markup -> only NSKeyedUnarchiver works
|
||||||
if type == .image,
|
if type == .image,
|
||||||
let image = try? NSKeyedUnarchiver.unarchivedObject(ofClass: UIImage.self, from: data),
|
let image = UIImage(data: data) ?? (try? NSKeyedUnarchiver.unarchivedObject(ofClass: UIImage.self, from: data)),
|
||||||
let pngData = image.pngData() {
|
let pngData = image.pngData() {
|
||||||
data = pngData
|
data = pngData
|
||||||
type = .png
|
type = .png
|
||||||
|
|
Loading…
Reference in New Issue