diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..915d0ef
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+/RichTextEditor.xcodeproj/xcuserdata/
+
+UserInterfaceState.xcuserstate
+
+RichTextEditor.xccheckout
diff --git a/RichTextEditor.xcodeproj/project.pbxproj b/RichTextEditor.xcodeproj/project.pbxproj
index 236b1e9..35e16df 100644
--- a/RichTextEditor.xcodeproj/project.pbxproj
+++ b/RichTextEditor.xcodeproj/project.pbxproj
@@ -101,6 +101,7 @@
1AFAED8617C804AB00E450B0 /* numlist@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFAED8417C804AB00E450B0 /* numlist@2x.png */; };
1AFAED8717C804AB00E450B0 /* bullist@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFAED8517C804AB00E450B0 /* bullist@2x.png */; };
1AFAED8917C80FC600E450B0 /* dropDownTriangle@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFAED8817C80FC600E450B0 /* dropDownTriangle@2x.png */; };
+ E1A1B1E1196ABAE900513A15 /* RichTextEditorInsertLinkViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E1A1B1E0196ABAE900513A15 /* RichTextEditorInsertLinkViewController.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -229,6 +230,8 @@
1AFAED8417C804AB00E450B0 /* numlist@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "numlist@2x.png"; sourceTree = ""; };
1AFAED8517C804AB00E450B0 /* bullist@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "bullist@2x.png"; sourceTree = ""; };
1AFAED8817C80FC600E450B0 /* dropDownTriangle@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "dropDownTriangle@2x.png"; sourceTree = ""; };
+ E1A1B1DF196ABAE800513A15 /* RichTextEditorInsertLinkViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RichTextEditorInsertLinkViewController.h; sourceTree = ""; };
+ E1A1B1E0196ABAE900513A15 /* RichTextEditorInsertLinkViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RichTextEditorInsertLinkViewController.m; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -275,6 +278,8 @@
153F9581179F9953005B2487 /* RichTextEditorFontSizePickerViewController.h */,
153F9582179F9953005B2487 /* RichTextEditorFontSizePickerViewController.m */,
153F9583179F9953005B2487 /* RichTextEditorPopover.h */,
+ E1A1B1DF196ABAE800513A15 /* RichTextEditorInsertLinkViewController.h */,
+ E1A1B1E0196ABAE900513A15 /* RichTextEditorInsertLinkViewController.m */,
);
path = Source;
sourceTree = "";
@@ -658,6 +663,7 @@
153F95A0179F9953005B2487 /* RichTextEditor.m in Sources */,
153F958C179F9953005B2487 /* UIView+RichTextEditor.m in Sources */,
153F959F179F9953005B2487 /* WETouchableView.m in Sources */,
+ E1A1B1E1196ABAE900513A15 /* RichTextEditorInsertLinkViewController.m in Sources */,
158389231735A5D7006DE713 /* AppDelegate.m in Sources */,
158389321735A5D7006DE713 /* ViewController.m in Sources */,
153F95A1179F9953005B2487 /* RichTextEditorColorPickerViewController.m in Sources */,
diff --git a/RichTextEditor.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/RichTextEditor.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..242f037
--- /dev/null
+++ b/RichTextEditor.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/RichTextEditor/Source/Assets/link.png b/RichTextEditor/Source/Assets/link.png
index b261c63..d23bd07 100644
Binary files a/RichTextEditor/Source/Assets/link.png and b/RichTextEditor/Source/Assets/link.png differ
diff --git a/RichTextEditor/Source/Assets/link@2x.png b/RichTextEditor/Source/Assets/link@2x.png
new file mode 100644
index 0000000..7b809b0
Binary files /dev/null and b/RichTextEditor/Source/Assets/link@2x.png differ
diff --git a/RichTextEditor/Source/Categories/NSAttributedString+RichTextEditor.h b/RichTextEditor/Source/Categories/NSAttributedString+RichTextEditor.h
index 423f99c..1d25b6f 100644
--- a/RichTextEditor/Source/Categories/NSAttributedString+RichTextEditor.h
+++ b/RichTextEditor/Source/Categories/NSAttributedString+RichTextEditor.h
@@ -33,5 +33,6 @@
- (NSRange)firstParagraphRangeFromTextRange:(NSRange)range;
- (NSArray *)rangeOfParagraphsFromTextRange:(NSRange)textRange;
- (NSString *)htmlString;
+- (NSString *)simpleHtmlString;
@end
diff --git a/RichTextEditor/Source/Categories/NSAttributedString+RichTextEditor.m b/RichTextEditor/Source/Categories/NSAttributedString+RichTextEditor.m
index 15052e2..d7aea6a 100644
--- a/RichTextEditor/Source/Categories/NSAttributedString+RichTextEditor.m
+++ b/RichTextEditor/Source/Categories/NSAttributedString+RichTextEditor.m
@@ -41,7 +41,7 @@ - (NSRange)firstParagraphRangeFromTextRange:(NSRange)range
range.location-1 :
range.location;
- for (int i=startingRange ; i>=0 ; i--)
+ for (NSInteger i=startingRange ; i>=0 ; i--)
{
char c = [self.string characterAtIndex:i];
if (c == '\n')
@@ -55,7 +55,7 @@ - (NSRange)firstParagraphRangeFromTextRange:(NSRange)range
NSInteger moveForwardIndex = (range.location > start) ? range.location : start;
- for (int i=moveForwardIndex; i<= self.string.length-1 ; i++)
+ for (NSInteger i=moveForwardIndex; i<= self.string.length-1 ; i++)
{
char c = [self.string characterAtIndex:i];
if (c == '\n')
@@ -131,7 +131,10 @@ - (NSString *)htmlString
BOOL hasUnderline = (!underline || underline.intValue == NSUnderlineStyleNone) ? NO :YES;
NSNumber *strikeThrough = [dictionary objectForKey:NSStrikethroughStyleAttributeName];
BOOL hasStrikeThrough = (!strikeThrough || strikeThrough.intValue == NSUnderlineStyleNone) ? NO :YES;
-
+ NSURL *url = [dictionary objectForKey:NSLinkAttributeName];
+
+
+
[fontString appendFormat:@""];
[fontString appendString:[[self.string substringFromIndex:range.location] substringToIndex:range.length]];
[fontString appendString:@""];
-
+
+ if(url){
+ [fontString insertString:[NSString stringWithFormat:@"",[url absoluteString]] atIndex:0];
+ [fontString insertString:@"" atIndex:fontString.length];
+ }
+
if ([font isBold])
{
[fontString insertString:@"" atIndex:0];
@@ -187,6 +195,71 @@ - (NSString *)htmlString
return htmlString;
}
+-(NSString *)simpleHtmlString{
+ NSMutableString *htmlString = [NSMutableString string];
+ NSArray *paragraphRanges = [self rangeOfParagraphsFromTextRange:NSMakeRange(0, self.string.length-1)];
+
+ for (int i=0 ; i"];
+
+
+ [self enumerateAttributesInRange:range
+ options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired
+ usingBlock:^(NSDictionary *dictionary, NSRange range, BOOL *stop){
+
+ NSMutableString *fontString = [NSMutableString string];
+ UIFont *font = [dictionary objectForKey:NSFontAttributeName];
+ NSNumber *underline = [dictionary objectForKey:NSUnderlineStyleAttributeName];
+ BOOL hasUnderline = (!underline || underline.intValue == NSUnderlineStyleNone) ? NO :YES;
+ NSNumber *strikeThrough = [dictionary objectForKey:NSStrikethroughStyleAttributeName];
+ BOOL hasStrikeThrough = (!strikeThrough || strikeThrough.intValue == NSUnderlineStyleNone) ? NO :YES;
+ NSURL *url = [dictionary objectForKey:NSLinkAttributeName];
+
+ [fontString appendString:[[self.string substringFromIndex:range.location] substringToIndex:range.length]];
+
+ if(url){
+ [fontString insertString:[NSString stringWithFormat:@"",[url absoluteString]] atIndex:0];
+ [fontString insertString:@"" atIndex:fontString.length];
+ }
+
+ if ([font isBold])
+ {
+ [fontString insertString:@"" atIndex:0];
+ [fontString insertString:@"" atIndex:fontString.length];
+ }
+
+ if ([font isItalic])
+ {
+ [fontString insertString:@"" atIndex:0];
+ [fontString insertString:@"" atIndex:fontString.length];
+ }
+
+ if (hasUnderline)
+ {
+ [fontString insertString:@"" atIndex:0];
+ [fontString insertString:@"" atIndex:fontString.length];
+ }
+
+ if (hasStrikeThrough)
+ {
+ [fontString insertString:@"" atIndex:0];
+ [fontString insertString:@"" atIndex:fontString.length];
+ }
+
+
+ [htmlString appendString:fontString];
+ }];
+
+ [htmlString appendString:@"
"];
+ }
+
+ return htmlString;
+}
+
#pragma mark - Helper Methods -
- (NSString *)htmlTextAlignmentString:(NSTextAlignment)textAlignment
diff --git a/RichTextEditor/Source/RichTextEditor.m b/RichTextEditor/Source/RichTextEditor.m
index 86231e9..e742cf0 100644
--- a/RichTextEditor/Source/RichTextEditor.m
+++ b/RichTextEditor/Source/RichTextEditor.m
@@ -94,6 +94,11 @@ - (void)commonInitialization
[self updateToolbarState];
}
+-(void)setDataSource:(id)dataSource{
+ _dataSource = dataSource;
+ [self setupMenuItems];
+}
+
#pragma mark - Override Methods -
- (void)setSelectedTextRange:(UITextRange *)selectedTextRange
@@ -157,8 +162,36 @@ - (void)setupMenuItems
UIMenuItem *italicItem = [[UIMenuItem alloc] initWithTitle:@"Italic" action:@selector(richTextEditorToolbarDidSelectItalic)];
UIMenuItem *underlineItem = [[UIMenuItem alloc] initWithTitle:@"Underline" action:@selector(richTextEditorToolbarDidSelectUnderline)];
UIMenuItem *strikeThroughItem = [[UIMenuItem alloc] initWithTitle:@"Strike" action:@selector(richTextEditorToolbarDidSelectStrikeThrough)];
-
- [[UIMenuController sharedMenuController] setMenuItems:@[selectParagraph, boldItem, italicItem, underlineItem, strikeThroughItem]];
+
+ RichTextEditorFeature features = [self featuresEnabledForRichTextEditorToolbar];
+ if(features == RichTextEditorFeatureAll){
+ [[UIMenuController sharedMenuController] setMenuItems:@[selectParagraph, boldItem, italicItem, underlineItem, strikeThroughItem]];
+ }else{
+ NSMutableArray *array = [NSMutableArray array];
+
+ if(features & RichTextEditorFeatureParagraphIndentation){
+ [array addObject:selectParagraph];
+ }
+
+ if(features & RichTextEditorFeatureBold){
+ [array addObject:boldItem];
+ }
+
+ if(features & RichTextEditorFeatureItalic){
+ [array addObject:italicItem];
+ }
+
+ if(features & RichTextEditorFeatureUnderline){
+ [array addObject:underlineItem];
+ }
+
+ if(features & RichTextEditorFeatureStrikeThrough){
+ [array addObject:strikeThroughItem];
+ }
+
+ [[UIMenuController sharedMenuController] setMenuItems:array];
+ }
+
}
- (void)selectParagraph:(id)sender
@@ -322,6 +355,38 @@ - (void)richTextEditorToolbarDidSelectBulletPoint
// TODO: implement this
}
+- (void)richTextEditorToolbarDidInsertLink:(NSURL*) link displayText:(NSString*)displayText{
+
+ NSMutableAttributedString *attributedString = [self.attributedText mutableCopy];
+
+ NSMutableDictionary *attributes = [[self dictionaryAtIndex:self.selectedRange.location] mutableCopy];
+ UIFont *font = [attributes objectForKey:NSFontAttributeName];
+ font = [UIFont fontWithName:[font familyName] size:[font pointSize] boldTrait:NO italicTrait:NO];
+ [attributes setObject:font forKey:NSFontAttributeName];
+
+ NSMutableDictionary *cop = [attributes mutableCopy];
+ [cop setObject:link forKey:NSLinkAttributeName];
+ NSAttributedString *string = [[NSAttributedString alloc] initWithString:displayText attributes:cop];
+
+ NSRange oldRange = self.selectedRange;
+ oldRange.length = 0;
+ oldRange.location += displayText.length;
+
+ [attributedString insertAttributedString:string atIndex:self.selectedRange.location];
+
+ NSAttributedString *space = [[NSAttributedString alloc] initWithString:@" " attributes:attributes];
+ [attributedString insertAttributedString:space atIndex:oldRange.location];
+ oldRange.location += 1;
+
+ [self setAttributedText:attributedString];
+
+ [self updateToolbarState];
+ [self resignFirstResponder];
+ [self scrollRangeToVisible:oldRange];
+ [self becomeFirstResponder];
+ [self setSelectedRange:oldRange];
+}
+
#pragma mark - Private Methods -
- (CGRect)frameOfTextAtRange:(NSRange)range
@@ -358,6 +423,11 @@ - (void)enumarateThroughParagraphsInRange:(NSRange)range withBlock:(void (^)(NSR
[self setSelectedRange:fullRange];
}
+-(void)setAttributedText:(NSAttributedString *)attributedText{
+ [super setAttributedText:attributedText];
+ [self updateToolbarState];
+}
+
- (void)updateToolbarState
{
// If no text exists or typing attributes is in progress update toolbar using typing attributes instead of selected text
@@ -367,10 +437,16 @@ - (void)updateToolbarState
}
else
{
- int location = [self offsetFromPosition:self.beginningOfDocument toPosition:self.selectedTextRange.start];
-
- if (location == self.text.length)
- location --;
+ NSInteger location = [self offsetFromPosition:self.beginningOfDocument toPosition:self.selectedTextRange.start];
+ if(self.selectedRange.length > 0){
+ if (location == self.text.length)
+ location --;
+ }else{
+ if (location != 0)
+ location --;
+ }
+
+
[self.toolBar updateStateWithAttributes:[self.attributedText attributesAtIndex:location effectiveRange:nil]];
}
@@ -389,9 +465,13 @@ - (NSRange)fullRangeFromArrayOfParagraphRanges:(NSArray *)paragraphRanges
- (UIFont *)fontAtIndex:(NSInteger)index
{
// If index at end of string, get attributes starting from previous character
- if (index == self.attributedText.string.length && [self hasText])
- --index;
-
+ if(self.selectedRange.length > 0){
+ if (index == self.attributedText.string.length && [self hasText])
+ index --;
+ }else{
+ if (index != 0)
+ index --;
+ }
// If no text exists get font from typing attributes
NSDictionary *dictionary = ([self hasText])
? [self.attributedText attributesAtIndex:index effectiveRange:nil]
@@ -403,8 +483,13 @@ - (UIFont *)fontAtIndex:(NSInteger)index
- (NSDictionary *)dictionaryAtIndex:(NSInteger)index
{
// If index at end of string, get attributes starting from previous character
- if (index == self.attributedText.string.length && [self hasText])
- --index;
+ if(self.selectedRange.length > 0){
+ if (index == self.attributedText.string.length && [self hasText])
+ index --;
+ }else{
+ if (index != 0)
+ index --;
+ }
// If no text exists get font from typing attributes
return ([self hasText])
diff --git a/RichTextEditor/Source/RichTextEditorColorPickerViewController.h b/RichTextEditor/Source/RichTextEditorColorPickerViewController.h
index 0bdaeb5..6f23eca 100644
--- a/RichTextEditor/Source/RichTextEditorColorPickerViewController.h
+++ b/RichTextEditor/Source/RichTextEditorColorPickerViewController.h
@@ -29,10 +29,10 @@
#import
#import "UIView+RichTextEditor.h"
-typedef enum {
- RichTextEditorColorPickerActionTextForegroudColor,
- RichTextEditorColorPickerActionTextBackgroundColor
-}RichTextEditorColorPickerAction;
+typedef NS_ENUM(NSUInteger, RichTextEditorColorPickerAction) {
+ RichTextEditorColorPickerActionTextForegroudColor,
+ RichTextEditorColorPickerActionTextBackgroundColor
+};
@protocol RichTextEditorColorPickerViewControllerDelegate
- (void)richTextEditorColorPickerViewControllerDidSelectColor:(UIColor *)color withAction:(RichTextEditorColorPickerAction)action;
diff --git a/RichTextEditor/Source/RichTextEditorInsertLinkViewController.h b/RichTextEditor/Source/RichTextEditorInsertLinkViewController.h
new file mode 100644
index 0000000..e4cf641
--- /dev/null
+++ b/RichTextEditor/Source/RichTextEditorInsertLinkViewController.h
@@ -0,0 +1,27 @@
+//
+// RichTextEditorInsertLinkViewController.h
+// RichTextEditor
+//
+// Created by Andreas Lillebø Holm on 07/07/14.
+// Copyright (c) 2014 Aryan Ghassemi. All rights reserved.
+//
+
+#import
+
+@protocol RichTextEditorInsertLinkViewControllerDelegate
+
+- (void)richTextEditorInsertLinkViewControllerInsertURL:(NSURL *)url withDisplayText:(NSString *)displayText;
+- (void)richTextEditorInsertLinkViewControllerDidCancel;
+
+@end
+
+@interface RichTextEditorInsertLinkViewController : UIViewController
+
+@property(nonatomic, weak) id delegate;
+
+- (void)doneSelected:(id)sender;
+- (void)closeSelected:(id)sender;
+
+@end
+
+
diff --git a/RichTextEditor/Source/RichTextEditorInsertLinkViewController.m b/RichTextEditor/Source/RichTextEditorInsertLinkViewController.m
new file mode 100644
index 0000000..2e8d110
--- /dev/null
+++ b/RichTextEditor/Source/RichTextEditorInsertLinkViewController.m
@@ -0,0 +1,86 @@
+//
+// RichTextEditorInsertLinkViewController.m
+// RichTextEditor
+//
+// Created by Andreas Lillebø Holm on 07/07/14.
+// Copyright (c) 2014 Aryan Ghassemi. All rights reserved.
+//
+
+#import "RichTextEditorInsertLinkViewController.h"
+
+@implementation RichTextEditorInsertLinkViewController{
+ UITextField *_urlField;
+ UITextField *_displayField;
+}
+
+-(void)viewDidLoad{
+ [super viewDidLoad];
+ self.view.frame = CGRectMake(0, 0, 235, 100);
+ self.view.backgroundColor = [UIColor whiteColor];
+
+ UIButton *btnClose = [[UIButton alloc] initWithFrame:CGRectMake(5, 5, 60, 30)];
+ [btnClose addTarget:self action:@selector(closeSelected:) forControlEvents:UIControlEventTouchUpInside];
+ [btnClose.titleLabel setFont:[UIFont boldSystemFontOfSize:12]];
+ [btnClose setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
+ [btnClose setTitle:@"Close" forState:UIControlStateNormal];
+ [self.view addSubview:btnClose];
+
+ UIButton *btnDone = [[UIButton alloc] initWithFrame:CGRectMake(170, 5, 60, 30)];
+ [btnDone addTarget:self action:@selector(doneSelected:) forControlEvents:UIControlEventTouchUpInside];
+ [btnDone.titleLabel setFont:[UIFont boldSystemFontOfSize:12]];
+ [btnDone setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
+ [btnDone setTitle:@"Done" forState:UIControlStateNormal];
+ [self.view addSubview:btnDone];
+
+ _urlField = [[UITextField alloc] initWithFrame:CGRectMake(5, 33, 225, 30)];
+ [_urlField setFont:[UIFont systemFontOfSize:12]];
+ [_urlField setPlaceholder:@"Skriv link her (http://)"];
+ [_urlField setBorderStyle:UITextBorderStyleLine];
+ [_urlField setAutocorrectionType:UITextAutocorrectionTypeNo];
+ [_urlField setAutocapitalizationType:UITextAutocorrectionTypeNo];
+ [self.view addSubview:_urlField];
+
+ _displayField = [[UITextField alloc] initWithFrame:CGRectMake(5, 65, 225, 30)];
+ [_displayField setFont:[UIFont systemFontOfSize:12]];
+ [_displayField setPlaceholder:@"Link beskrivelse her"];
+ [_displayField setBorderStyle:UITextBorderStyleLine];
+ [_displayField setAutocorrectionType:UITextAutocorrectionTypeNo];
+ [_displayField setAutocapitalizationType:UITextAutocorrectionTypeNo];
+ [self.view addSubview:_displayField];
+
+ [_urlField becomeFirstResponder];
+}
+
+- (void)doneSelected:(id)sender{
+ if([[_displayField text] isEqualToString:@""] || [[_displayField text] isEqualToString:@" "]){
+ [_displayField becomeFirstResponder];
+ return;
+ }
+
+ if([[_urlField text] isEqualToString:@""] || [[_urlField text] isEqualToString:@" "]){
+ [_urlField becomeFirstResponder];
+ return;
+ }
+
+ NSString *urlString = [self replaceURLWithLink:[_urlField text]];
+
+ [self.delegate richTextEditorInsertLinkViewControllerInsertURL:[NSURL URLWithString:urlString] withDisplayText:[_displayField text]];
+}
+- (void)closeSelected:(id)sender{
+ [self.delegate richTextEditorInsertLinkViewControllerDidCancel];
+}
+
+-(NSString*)replaceURLWithLink:(NSString*)text{
+ NSDataDetector* detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:nil];
+ NSArray* matches = [detector matchesInString:text options:0 range:NSMakeRange(0, [text length])];
+ NSString *retstring = text;
+ for (NSTextCheckingResult* result in [matches reverseObjectEnumerator]) {
+ NSString *match = [[result URL] absoluteString];
+ NSRange range = [result range];
+ retstring = [retstring stringByReplacingCharactersInRange:range withString:match];
+ }
+
+ return retstring;
+}
+
+@end
diff --git a/RichTextEditor/Source/RichTextEditorToolbar.h b/RichTextEditor/Source/RichTextEditorToolbar.h
index ff6be4d..b7ae4d8 100644
--- a/RichTextEditor/Source/RichTextEditorToolbar.h
+++ b/RichTextEditor/Source/RichTextEditorToolbar.h
@@ -27,18 +27,18 @@
#import
-typedef enum{
- RichTextEditorToolbarPresentationStyleModal,
- RichTextEditorToolbarPresentationStylePopover
-}RichTextEditorToolbarPresentationStyle;
+typedef NS_ENUM(NSUInteger, RichTextEditorToolbarPresentationStyle) {
+ RichTextEditorToolbarPresentationStyleModal,
+ RichTextEditorToolbarPresentationStylePopover
+};
-typedef enum{
- ParagraphIndentationIncrease,
- ParagraphIndentationDecrease
-}ParagraphIndentation;
+typedef NS_ENUM(NSUInteger, ParagraphIndentation) {
+ ParagraphIndentationIncrease,
+ ParagraphIndentationDecrease
+};
-typedef enum{
- RichTextEditorFeatureNone = 0,
+typedef NS_ENUM(NSUInteger, RichTextEditorFeature) {
+ RichTextEditorFeatureNone = 0,
RichTextEditorFeatureFont = 1 << 0,
RichTextEditorFeatureFontSize = 1 << 1,
RichTextEditorFeatureBold = 1 << 2,
@@ -53,8 +53,9 @@ typedef enum{
RichTextEditorFeatureTextForegroundColor = 1 << 11,
RichTextEditorFeatureParagraphIndentation = 1 << 12,
RichTextEditorFeatureParagraphFirstLineIndentation = 1 << 13,
- RichTextEditorFeatureAll = 1 << 14
-}RichTextEditorFeature;
+ RichTextEditorFeatureAll = 1 << 14,
+ RichTextEditorFeatureLink = 1 << 15
+};
@protocol RichTextEditorToolbarDelegate
- (void)richTextEditorToolbarDidSelectBold;
@@ -69,6 +70,7 @@ typedef enum{
- (void)richTextEditorToolbarDidSelectTextBackgroundColor:(UIColor *)color;
- (void)richTextEditorToolbarDidSelectTextForegroundColor:(UIColor *)color;
- (void)richTextEditorToolbarDidSelectTextAlignment:(NSTextAlignment)textAlignment;
+- (void)richTextEditorToolbarDidInsertLink:(NSURL*) link displayText:(NSString*)displayText;
@end
@protocol RichTextEditorToolbarDataSource
diff --git a/RichTextEditor/Source/RichTextEditorToolbar.m b/RichTextEditor/Source/RichTextEditorToolbar.m
index 7cc443d..a9328e7 100644
--- a/RichTextEditor/Source/RichTextEditorToolbar.m
+++ b/RichTextEditor/Source/RichTextEditorToolbar.m
@@ -31,6 +31,7 @@
#import "RichTextEditorFontSizePickerViewController.h"
#import "RichTextEditorFontPickerViewController.h"
#import "RichTextEditorColorPickerViewController.h"
+#import "RichTextEditorInsertLinkViewController.h"
#import "WEPopoverController.h"
#import "RichTextEditorToggleButton.h"
#import "UIFont+RichTextEditor.h"
@@ -39,7 +40,8 @@
#define ITEM_TOP_AND_BOTTOM_BORDER 5
#define ITEM_WITH 40
-@interface RichTextEditorToolbar()
+@interface RichTextEditorToolbar()
@property (nonatomic, strong) id popover;
@property (nonatomic, strong) RichTextEditorToggleButton *btnBold;
@property (nonatomic, strong) RichTextEditorToggleButton *btnItalic;
@@ -57,6 +59,7 @@ @interface RichTextEditorToolbar()