2017-11-06 22:20:29 +01:00
|
|
|
//
|
|
|
|
// ArticlePasteboardWriter.swift
|
|
|
|
// Evergreen
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 11/6/17.
|
|
|
|
// Copyright © 2017 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
import Data
|
|
|
|
|
|
|
|
@objc final class ArticlePasteboardWriter: NSObject, NSPasteboardWriting {
|
|
|
|
|
|
|
|
private let article: Article
|
|
|
|
|
|
|
|
init(article: Article) {
|
|
|
|
|
|
|
|
self.article = article
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - NSPasteboardWriting
|
|
|
|
|
|
|
|
func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] {
|
|
|
|
|
2017-11-06 22:29:53 +01:00
|
|
|
// TODO: add more types
|
|
|
|
|
|
|
|
var types = [NSPasteboard.PasteboardType]()
|
|
|
|
|
|
|
|
if let _ = article.title {
|
|
|
|
types += [.string]
|
|
|
|
}
|
|
|
|
|
|
|
|
return types // TODO: add types
|
2017-11-06 22:20:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func pasteboardPropertyList(forType type: NSPasteboard.PasteboardType) -> Any? {
|
|
|
|
|
2017-11-06 22:29:53 +01:00
|
|
|
// TODO: write data for all types declared in writableTypes.
|
|
|
|
|
|
|
|
let plist: Any?
|
|
|
|
|
|
|
|
switch type {
|
|
|
|
case .string:
|
|
|
|
plist = article.title ?? ""
|
|
|
|
default:
|
|
|
|
plist = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return plist
|
2017-11-06 22:20:29 +01:00
|
|
|
}
|
|
|
|
}
|