# FastTextView
**Repository Path**: caishangshu/FastTextView
## Basic Information
- **Project Name**: FastTextView
- **Description**: github上引用的
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2016-12-23
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
FastTextView
============
The best rich editor (TextView) on IOS platform , should be the fastest , opensourced by [www.chineseall.com](http://www.chineseall.com/ "http://chineseall.com/") ,developed by gfthr (gfthr@sina.com).
FastTextView is inspired by EGOTextView , and made some significant improvement to enchance peformance on large text input speed , changed about 50% code , so named new project FastTextView.
some feature list blow:
1)insert text is very fast on large text input (about 50K on iphone4), because we introduced a new subclass of NSMutableAttributedString named 'FastTextStorage',any modification on text only need little time to rebuild some invalidate paragragh,this is a good base and could be more fast and more stable
2)insert attachment cell is easy and you can custom youself attachment cell
3)caret behaviour like normal editor
4)eliminate duplicate setNeedDisplay request
5)surpport IOS7
6)demo app surpport emotion
Thank you the ChinesAll.com , the china best digital content puslisher !
This editor is used on the ChinesAll's writing and reading mobile app tangyuan (see www.itangyuan.com)
demo
============


Install Method 1 :
============
1.put FastTextViewLib to the parrael directory, add FastTextViewLib.xcodeproj to your main project
2.TARGETS->your target->link binary with libraries->add libFastTextViewLib.a
3.PROJECT->header search paths-> ../FastTextViewLib/FastTextViewLib/Class
4.TARGETS->header search paths-> ../FastTextViewLib/FastTextViewLib/Class
5.PROJECT->Other linker Flags ->-all_load
6.TARGETS->Other linker Flags ->-all_load
7.import framework: QuartzCore.framework,CoreText.framework,AssetsLibrary.framework,CoreGraphics.framework
Install Method 2 :
============
1.copy all files in FastTextViewLib 's folder Resources and Class to you project folder and add these files to your project
2.build
that's all!
below is example code for export html
============
```
- (NSString *)htmlStringWithAttachmentPath:(NSString *)attachpath ChapterAuthor:(ChapterAuthor *)chapterAuthor
{
NSString *storeString = @"";
NSAttributedString *newAttrStr=[self copy];
NSMutableDictionary *textParagraphMap=[[NSMutableDictionary alloc]init];
TextParagraph *textParagraph;
NSRange longRange;
unsigned int longPos = 0;
while ((longPos < [newAttrStr length]) &&
(textParagraph = [newAttrStr attribute:FastTextParagraphAttributeName atIndex:longPos longestEffectiveRange:&longRange inRange:NSMakeRange(0, [newAttrStr length])])){
NSLog(@"textParagraph %@",textParagraph);
[textParagraphMap setValue:NSStringFromRange(longRange) forKey:textParagraph.key];
longPos = longRange.location + longRange.length;
}
NSDictionary *effectiveAttributes;
NSRange range;
unsigned int pos = 0;
while ((pos < [newAttrStr length]) &&
(effectiveAttributes = [newAttrStr attributesAtIndex:pos effectiveRange:&range])) {
NSString *plainString=[[newAttrStr attributedSubstringFromRange:range] string];
//一下三个替换步骤不可错误!
//替换img的魔术占位符
unichar attachmentCharacter = FastTextAttachmentCharacter;
plainString=[plainString stringByReplacingOccurrencesOfString:[NSString stringWithCharacters:&attachmentCharacter length:1] withString:@""];
//编码html标签
plainString = [plainString stringByAddingHTMLEntities];
//替换\n为
标签
plainString=[plainString stringByReplacingOccurrencesOfString:@"\n" withString:@"
"];
NSRange paragraphRange = NSMakeRange(NSNotFound, NSNotFound) ;
TextParagraph *textParagraph=[effectiveAttributes objectForKey:FastTextParagraphAttributeName];
if (textParagraph!=nil) {
NSString *rangstr= [textParagraphMap objectForKey:[NSString md5:[textParagraph description]]];
paragraphRange=NSRangeFromString(rangstr);
}
if (paragraphRange.location!=NSNotFound && paragraphRange.location==range.location) {
storeString=[storeString stringByAppendingString:@"
"];
}
//附件处理
id"];
}
}
}else{
//文本
storeString=[storeString stringByAppendingFormat:@"%@", plainString];
}
if (paragraphRange.length!=NSNotFound
&& (paragraphRange.location+paragraphRange.length)==(range.location+range.length)) {
storeString=[storeString stringByAppendingString:@"