mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 21:41:33 +00:00

Provide (in descending priority order): 1. an StoryTitleAttributedString object which provides attributed string containing the (optional) image and a link, for drops into apps such as Notes, or if rich text is unsupported, Story Title <story URL>. 2. a URL (alone) This avoids the issue where a “2” or “3” is displayed and multiple items appear to be being dragged (see #1072). Correctly return an empty array rather than nil if we have nothing to drag.
37 lines
1.2 KiB
Objective-C
37 lines
1.2 KiB
Objective-C
//
|
|
// StoryTitleAttributedString.m
|
|
// NewsBlur
|
|
//
|
|
// Created by Nicholas Riley on 1/6/2018.
|
|
// Copyright © 2018 NewsBlur. All rights reserved.
|
|
//
|
|
|
|
#import "StoryTitleAttributedString.h"
|
|
|
|
@implementation StoryTitleAttributedString
|
|
|
|
- (instancetype)initWithAttributedString:(NSAttributedString *)attrStr plainString:(NSString *)plainStr {
|
|
if ( (self = [self init]) != nil) {
|
|
attributedString = attrStr;
|
|
plainString = plainStr;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
+ (NSArray<NSString *> *)writableTypeIdentifiersForItemProvider {
|
|
return NSAttributedString.writableTypeIdentifiersForItemProvider;
|
|
}
|
|
|
|
#pragma mark - NSItemProviderWriting
|
|
|
|
- (nullable NSProgress *)loadDataWithTypeIdentifier:(nonnull NSString *)typeIdentifier forItemProviderCompletionHandler:(nonnull void (^)(NSData * _Nullable, NSError * _Nullable))completionHandler {
|
|
|
|
NSLog(@"requested: %@", typeIdentifier);
|
|
|
|
if ([typeIdentifier isEqualToString:(NSString *)kUTTypeUTF8PlainText])
|
|
return [plainString loadDataWithTypeIdentifier:typeIdentifier forItemProviderCompletionHandler:completionHandler];
|
|
|
|
return [attributedString loadDataWithTypeIdentifier:typeIdentifier forItemProviderCompletionHandler:completionHandler];
|
|
}
|
|
|
|
@end
|