|
|
@ -209,126 +209,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
return [self.text ows_stripped];
|
|
|
|
return [self.text ows_stripped];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
|
|
|
|
//#import <QuartzCore/QuartzCore.h>
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//#import "NSString+JSQMessages.h"
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//@implementation JSQMessagesComposerTextView
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//#pragma mark - Initialization
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//- (void)jsq_configureTextView
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// [self jsq_addTextViewNotificationObservers];
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//- (void)dealloc
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// [self jsq_removeTextViewNotificationObservers];
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//#pragma mark - Composer text view
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//- (BOOL)hasText
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// return ([[self.text jsq_stringByTrimingWhitespace] length] > 0);
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//- (void)paste:(id)sender
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// if (!self.jsqPasteDelegate || [self.jsqPasteDelegate composerTextView:self shouldPasteWithSender:sender]) {
|
|
|
|
|
|
|
|
// [super paste:sender];
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//#pragma mark - Drawing
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//- (void)drawRect:(CGRect)rect
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// [super drawRect:rect];
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if ([self.text length] == 0 && self.placeHolder) {
|
|
|
|
|
|
|
|
// [self.placeHolderTextColor set];
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// [self.placeHolder drawInRect:CGRectInset(rect, 7.0f, 5.0f)
|
|
|
|
|
|
|
|
// withAttributes:[self jsq_placeholderTextAttributes]];
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//#pragma mark - Notifications
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//- (void)jsq_addTextViewNotificationObservers
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// [[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
|
|
|
|
// selector:@selector(jsq_didReceiveTextViewNotification:)
|
|
|
|
|
|
|
|
// name:UITextViewTextDidChangeNotification
|
|
|
|
|
|
|
|
// object:self];
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// [[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
|
|
|
|
// selector:@selector(jsq_didReceiveTextViewNotification:)
|
|
|
|
|
|
|
|
// name:UITextViewTextDidBeginEditingNotification
|
|
|
|
|
|
|
|
// object:self];
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// [[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
|
|
|
|
// selector:@selector(jsq_didReceiveTextViewNotification:)
|
|
|
|
|
|
|
|
// name:UITextViewTextDidEndEditingNotification
|
|
|
|
|
|
|
|
// object:self];
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//- (void)jsq_removeTextViewNotificationObservers
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// [[NSNotificationCenter defaultCenter] removeObserver:self
|
|
|
|
|
|
|
|
// name:UITextViewTextDidChangeNotification
|
|
|
|
|
|
|
|
// object:self];
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// [[NSNotificationCenter defaultCenter] removeObserver:self
|
|
|
|
|
|
|
|
// name:UITextViewTextDidBeginEditingNotification
|
|
|
|
|
|
|
|
// object:self];
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// [[NSNotificationCenter defaultCenter] removeObserver:self
|
|
|
|
|
|
|
|
// name:UITextViewTextDidEndEditingNotification
|
|
|
|
|
|
|
|
// object:self];
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//- (void)jsq_didReceiveTextViewNotification:(NSNotification *)notification
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// [self setNeedsDisplay];
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//#pragma mark - Utilities
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//- (NSDictionary *)jsq_placeholderTextAttributes
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
|
|
|
|
|
|
|
// paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;
|
|
|
|
|
|
|
|
// paragraphStyle.alignment = self.textAlignment;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// return @{ NSFontAttributeName : self.font,
|
|
|
|
|
|
|
|
// NSForegroundColorAttributeName : self.placeHolderTextColor,
|
|
|
|
|
|
|
|
// NSParagraphStyleAttributeName : paragraphStyle };
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//#pragma mark - UIMenuController
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//- (BOOL)canBecomeFirstResponder
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// return [super canBecomeFirstResponder];
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//- (BOOL)becomeFirstResponder
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// return [super becomeFirstResponder];
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
|
|
|
|
|
|
|
|
// [UIMenuController sharedMenuController].menuItems = nil;
|
|
|
|
|
|
|
|
// return [super canPerformAction:action withSender:sender];
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - UITextViewDelegate
|
|
|
|
#pragma mark - UITextViewDelegate
|
|
|
|
|
|
|
|
|
|
|
|