Skip to content

Commit

Permalink
Only paste images if we have some
Browse files Browse the repository at this point in the history
  • Loading branch information
lukakerr committed Mar 8, 2019
1 parent bfd1059 commit d0d0ce9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Twig/Views/MarkdownTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import Cocoa
class MarkdownTextView: NSTextView {

override func paste(_ sender: Any?) {
if let fileURLs = NSPasteboard.general.readObjects(
let fileURLs = NSPasteboard.general.readObjects(
forClasses: [NSURL.self],
options: [.urlReadingFileURLsOnly : 1]
) as? [URL] {
let markdownImages = fileURLs.filter { $0.isImage }
options: [.urlReadingFileURLsOnly: 1]
) as? [URL]

let images = fileURLs?.filter { $0.isImage }

if let markdownImages = images, markdownImages.count > 0 {
self.pasteImages(markdownImages)
return
}
Expand Down

0 comments on commit d0d0ce9

Please sign in to comment.