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 type = UTType(typeIdentifier)!
|
||||
|
||||
// this seems to only occur when the item is a UIImage, rather than just image data,
|
||||
// which seems to only occur when sharing a screenshot directly from the markup screen
|
||||
// the type is .image in certain circumstances:
|
||||
// - macOS: image copied from macOS Safari -> only UIImage(data: data) works
|
||||
// - iOS: sharing screenshot from markup -> only NSKeyedUnarchiver works
|
||||
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() {
|
||||
data = pngData
|
||||
type = .png
|
||||
|
|
Loading…
Reference in New Issue