Skip to content

Commit

Permalink
Merge branch 'release-1.6.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Nov 19, 2015
2 parents 8ea347a + 501a669 commit 013f41c
Show file tree
Hide file tree
Showing 21 changed files with 512 additions and 628 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
#osx_image: xcode6.4
language: objective-c

before_install:
- git submodule update --init --recursive

script:
- xctool -project DTRichTextEditor.xcodeproj -scheme "Demo App" clean build -sdk iphonesimulator -arch x86_64
- xctool -project DTRichTextEditor.xcodeproj -scheme "DTRichTextEditor (iOS)" clean build -sdk iphonesimulator -arch x86_64
- appledoc -o /tmp .
2 changes: 1 addition & 1 deletion AppledocSettings.plist
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<string>Demo</string>
</array>
<key>--index-desc</key>
<string>Documentation/Readme.markdown</string>
<string>Readme.markdown</string>
<key>--include</key>
<array>
<string>./Documentation/Known Issues-template.markdown</string>
Expand Down
2 changes: 1 addition & 1 deletion Core/Externals/DTWebArchive
115 changes: 65 additions & 50 deletions Core/Source/DTRichTextEditorView+Dictation.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,72 +23,87 @@ - (void)_inputDelegateTextDidChange;
@implementation DTRichTextEditorView (Dictation)


- (void)insertDictationResult:(NSArray *)dictationResult
{
NSMutableString *tmpString = [NSMutableString string];

for (UIDictationPhrase *phrase in dictationResult)
{
[tmpString appendString:phrase.text];
}

unichar lastChar = [tmpString characterAtIndex:[tmpString length]-1];

if ([[NSCharacterSet punctuationCharacterSet] characterIsMember:lastChar])
{
[tmpString appendString:@" "];
}

[self insertText:tmpString];
[self.undoManager setActionName:NSLocalizedString(@"Dictation", @"Undo Action when text is entered via dictation")];
}
// insertDictationResult: is invoked when there is more than one possible interpretation of the dictated phrase.
// Rather than simply inserting every possibility, the UI could somehow indicate that multiple results exist.
// (A standard UITextView will underline an ambiguous result and provide alternatives when tapped.)
// If this method is not implemented, the default behavior is to choose the most likely interpretation.

//- (void)insertDictationResult:(NSArray *)dictationResult
//{
// NSMutableString *tmpString = [NSMutableString string];
//
// for (UIDictationPhrase *phrase in dictationResult)
// {
// [tmpString appendString:phrase.text];
// }
//
// unichar lastChar = [tmpString characterAtIndex:[tmpString length]-1];
//
// if ([[NSCharacterSet punctuationCharacterSet] characterIsMember:lastChar])
// {
// [tmpString appendString:@" "];
// }
//
// [self insertText:tmpString];
// [self.undoManager setActionName:NSLocalizedString(@"Dictation", @"Undo Action when text is entered via dictation")];
//}


- (void)dictationRecordingDidEnd
// insertDictationResultPlaceholder is invoked after "Done" is tapped.
// Preliminary results may already have been inserted into the text by the time this method is called.
- (id)insertDictationResultPlaceholder
{
[self.undoManager endUndoGrouping];
// make a placeholder attachment, will be creating a placeholderView at run time
DTDictationPlaceholderTextAttachment *attachment = [[DTDictationPlaceholderTextAttachment alloc] init];
[self.undoManager endUndoGrouping];
// make a placeholder attachment, will be creating a placeholderView at run time
DTDictationPlaceholderTextAttachment *attachment = [[DTDictationPlaceholderTextAttachment alloc] init];

UITextRange *range = (DTTextRange *)[self selectedTextRange];
// remember the replaced text in the attachment
attachment.replacedAttributedString = [self attributedSubstringForRange:range];

// we don't want the inserting of the image to be an undo step
[self.undoManager disableUndoRegistration];

// no need for an extra space, dictation does that for us
// no need for an extra space, dictation does that for us
// replace the selected text with the placeholder
[self replaceRange:range withAttachment:attachment inParagraph:NO];
[self replaceRange:range withAttachment:attachment inParagraph:NO];
[self.undoManager enableUndoRegistration];

// this hides the selection until replaceRange:withText: inserts the result
self.waitingForDictionationResult = YES;

return attachment;
}

- (void)dictationRecognitionFailed
// removeDictationResultPlaceholder:willInsertResult: is invoked after the dictation has been processed.
// Despite the "willInsert" nomenclature, the dictation result has already been inserted into the text by the time this method is called.
- (void)removeDictationResultPlaceholder:(id)placeholder willInsertResult:(BOOL)willInsertResult
{
// we don't want the removal of the image to be an undo step
[self.undoManager disableUndoRegistration];

UITextRange *range = [self textRangeOfDictationPlaceholder];

if (range)
{
// first try the dummy will change + did change. On iOS 8 this calls replaceRange with @"".
[self _inputDelegateTextWillChange];
[self _inputDelegateTextDidChange];

// if we are still waiting for dictation result, then the dummy change did not work, do it the old way
if (self.waitingForDictionationResult)
{
[self replaceRange:range withText:@""];
}
}

[self.undoManager enableUndoRegistration];
// placeholder is the object returned by insertDictationResultPlaceholder.

UITextRange *range = [self textRangeOfDictationPlaceholder];

if (range)
{
// we don't want the removal of the placeholder to be an undo step
[self.undoManager disableUndoRegistration];

[self replaceRange:range withText:@""];

[self.undoManager enableUndoRegistration];
}
}

-(void)dictationRecognitionFailed
{
//removeDictationResultPlaceholder is not invoked if no text was inserted, calling it manually
[self removeDictationResultPlaceholder:[NSNull null] willInsertResult:NO];
//workaround for the mic to be enabled again
[self.inputDelegate selectionWillChange:self];
[self.inputDelegate selectionDidChange:self];
}

- (UITextRange *)textRangeOfDictationPlaceholder
Expand Down
31 changes: 6 additions & 25 deletions Core/Source/DTRichTextEditorView.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#import <DTFoundation/DTCoreGraphicsUtils.h>
#import <DTFoundation/DTTiledLayerWithoutFade.h>
#import <DTFoundation/DTWeakSupport.h>
#import <DTWebArchive/DTWebArchive.h>
#import <DTWebArchive/UIPasteboard+DTWebArchive.h>

#import "DTRichTextEditor.h"

Expand All @@ -26,10 +28,8 @@

#import "DTCursorView.h"

#import "DTWebArchive.h"
#import "NSAttributedString+DTWebArchive.h"
#import "NSAttributedString+DTRichText.h"
#import "UIPasteboard+DTWebArchive.h"
#import "DTRichTextEditorContentView.h"
#import "DTRichTextEditorView+Manipulation.h"
#import "DTUndoManager.h"
Expand Down Expand Up @@ -1205,7 +1205,7 @@ - (void)handleDoubleTap:(UITapGestureRecognizer *)gesture
// Select a word closest to the touchPoint
[self.inputDelegate selectionWillChange:self];

UITextPosition *position = (id)[self closestPositionToPoint:touchPoint withinRange:nil];
UITextPosition *position = (id)[self closestPositionToPoint:touchPoint];
UITextRange *wordRange = [self textRangeOfWordAtPosition:position];

// Bail out if there isn't a word range or if we are editing and it's the same as the current word range
Expand Down Expand Up @@ -1262,7 +1262,7 @@ - (void)handleTripleTap:(UITapGestureRecognizer *)gesture
}

// Select a paragraph containing the touchPoint
UITextPosition *position = (id)[self closestPositionToPoint:touchPoint withinRange:nil];
UITextPosition *position = (id)[self closestPositionToPoint:touchPoint];
UITextRange *textRange = [DTTextRange textRangeFromStart:position toEnd:position];
textRange = [self textRangeOfParagraphsContainingRange:textRange];

Expand Down Expand Up @@ -2264,25 +2264,6 @@ - (void)replaceRange:(DTTextRange *)range withText:(id)text

NSAttributedString *attributedStringBeingReplaced = nil;

if (_waitingForDictationResult)
{
NSString *dictationText = text;

if ([dictationText length] && ![[dictationText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length])
{
return;
}

// get selection range of placeholder
range = (DTTextRange *)[self textRangeOfDictationPlaceholder];

// iOS adds white space smartly, so we keep that

// get placeholder
DTDictationPlaceholderTextAttachment *attachment = [self dictationPlaceholderAtPosition:[range start]];
attributedStringBeingReplaced = attachment.replacedAttributedString;
}

NSAttributedString *attributedText = self.attributedText;
NSString *string = [attributedText string];

Expand Down Expand Up @@ -3171,7 +3152,7 @@ - (void)_inputDelegateSelectionDidChange
return;
}

[self.inputDelegate selectionWillChange:self];
[self.inputDelegate selectionDidChange:self];
}

- (void)_inputDelegateTextWillChange
Expand All @@ -3181,7 +3162,7 @@ - (void)_inputDelegateTextWillChange

- (void)_inputDelegateTextDidChange
{
[self.inputDelegate textWillChange:self];
[self.inputDelegate textDidChange:self];
}

- (void)_editorViewDelegateDidChangeSelection
Expand Down
6 changes: 3 additions & 3 deletions Core/Source/DTTextSelectionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ - (void)tintColorDidChange
#pragma mark Utilities
- (CGRect)beginCaretRect
{
__block CGRect rect = CGRectNull;
__block CGRect rect = CGRectZero;

// find the first selection rectangle the has the beginning
[_selectionRectangles enumerateObjectsUsingBlock:^(DTTextSelectionRect *oneTextSelectionRect, NSUInteger idx, BOOL *stop) {
Expand All @@ -219,7 +219,7 @@ - (CGRect)beginCaretRect

- (CGRect)endCaretRect
{
__block CGRect rect = CGRectNull;
__block CGRect rect = CGRectZero;

// find the first selection rectangle from the back the has the end
[_selectionRectangles enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(DTTextSelectionRect *oneTextSelectionRect, NSUInteger idx, BOOL *stop) {
Expand All @@ -239,7 +239,7 @@ - (CGRect)selectionEnvelope
{
if (![_selectionRectangles count])
{
return CGRectNull;
return CGRectZero;
}

CGRect unionRect = [[_selectionRectangles objectAtIndex:0] rect];
Expand Down
8 changes: 6 additions & 2 deletions Core/Source/NSMutableAttributedString+DTRichText.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

@class DTTextAttachment, DTCoreTextParagraphStyle, DTCoreTextFontDescriptor;

// block used for enumerating paragraph styles
/**
Block used for enumerating paragraph styles
*/
typedef BOOL (^NSMutableAttributedStringParagraphStyleEnumerationBlock)(DTCoreTextParagraphStyle *paragraphStyle, BOOL *stop);

// block used for enumerating font styles
/**
Block used for enumerating font styles
*/
typedef BOOL (^NSMutableAttributedStringFontStyleEnumerationBlock)(DTCoreTextFontDescriptor *fontDescriptor, BOOL *stop);

/**
Expand Down
6 changes: 3 additions & 3 deletions DTRichTextEditor.podspec
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Pod::Spec.new do |spec|
spec.name = 'DTRichTextEditor'
spec.version = '1.6.10'
spec.version = '1.6.12'
spec.platform = :ios, '6.0'
spec.license = 'BSD'
spec.source = { :git => 'https://github.com/Cocoanetics/DTRichTextEditor.git', :tag => spec.version.to_s }
spec.source_files = 'Core/Source/*.{h,m,c}', 'Core/*.h'
spec.prefix_header_contents = '#import "DTLog.h"'
spec.dependency 'DTCoreText', '~>1.6.16'
spec.dependency 'DTWebArchive', '~>0.0.2'
spec.dependency 'DTLoupe', '~>1.5.6'
spec.dependency 'DTFoundation/Core', '~>1.7.6'
spec.dependency 'DTLoupe', '~>1.5.8'
spec.dependency 'DTFoundation/Core', '~>1.7.8'
spec.frameworks = 'AssetsLibrary'
spec.requires_arc = true
spec.homepage = 'http://www.cocoanetics.com/parts/dtrichtexteditor/'
Expand Down
Loading

0 comments on commit 013f41c

Please sign in to comment.