BathyScapheで画像のインラインプレビューを可能にするプラグイン
Revisão | 7b3eec2b5ea36f57aa4332a1a9f15713924bd97a (tree) |
---|---|
Hora | 2013-04-15 21:36:48 |
Autor | masakih <masakih@user...> |
Commiter | masakih |
[Fix] BathyScaphe2.3.2で複数選択時のプレビューが出来ない問題を解消
@@ -159,6 +159,28 @@ static NSString *ThumbnailSizeKey = @"com.masakih.BSInlinePreviewer.thumbnailSiz | ||
159 | 159 | return YES; |
160 | 160 | } |
161 | 161 | |
162 | +- (BOOL)isValiableLinkAttr:(id)attr | |
163 | +{ | |
164 | + if([attr isKindOfClass:NSClassFromString(@"BSInnerLinkValueRep")]) { | |
165 | + attr = [attr stringValue]; | |
166 | + } else if(![attr isKindOfClass:[NSString class]]) { | |
167 | + return NO; | |
168 | + } | |
169 | + | |
170 | + return attr | |
171 | + && ![attr hasPrefix:@"cmonar"] | |
172 | + && ![attr hasPrefix:@"cmbe"] | |
173 | + && ![attr hasPrefix:@"mailto"]; | |
174 | +} | |
175 | +- (NSString *)URLStringFromAttr:(id)attr | |
176 | +{ | |
177 | + if([attr isKindOfClass:NSClassFromString(@"BSInnerLinkValueRep")]) { | |
178 | + attr = [attr stringValue]; | |
179 | + } else if(![attr isKindOfClass:[NSString class]]) { | |
180 | + return nil; | |
181 | + } | |
182 | + return attr; | |
183 | +} | |
162 | 184 | - (BOOL)previewLinks:(NSArray *)urls |
163 | 185 | { |
164 | 186 | // get document. |
@@ -188,12 +210,9 @@ static NSString *ThumbnailSizeKey = @"com.masakih.BSInlinePreviewer.thumbnailSiz | ||
188 | 210 | atIndex:location |
189 | 211 | longestEffectiveRange:NULL |
190 | 212 | inRange:range]) ? YES : NO; |
191 | - if(!didChecked && attr | |
192 | - && ![attr hasPrefix:@"cmonar"] | |
193 | - && ![attr hasPrefix:@"cmbe"] | |
194 | - && ![attr hasPrefix:@"mailto"]) { | |
213 | + if(!didChecked && [self isValiableLinkAttr:attr]) { | |
195 | 214 | BSILinkInfomation *link = [[[BSILinkInfomation alloc] init] autorelease]; |
196 | - link.urlString = attr; | |
215 | + link.urlString = [self URLStringFromAttr:attr]; | |
197 | 216 | link.range = longest; |
198 | 217 | [links addObject:link]; |
199 | 218 | } |