From 28f60a903b2bde261a74f117da9d5c23d6d77901 Mon Sep 17 00:00:00 2001 From: Jorge Leandro Perez Date: Mon, 28 Aug 2017 16:45:23 -0300 Subject: [PATCH 1/6] TextViewStubAttachmentDelegate: Updating closure signature --- AztecTests/TextKit/TextViewStubAttachmentDelegate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AztecTests/TextKit/TextViewStubAttachmentDelegate.swift b/AztecTests/TextKit/TextViewStubAttachmentDelegate.swift index 434ac91bc..2398b3de5 100644 --- a/AztecTests/TextKit/TextViewStubAttachmentDelegate.swift +++ b/AztecTests/TextKit/TextViewStubAttachmentDelegate.swift @@ -4,7 +4,7 @@ import UIKit class TextViewStubAttachmentDelegate: TextViewAttachmentDelegate, TextViewAttachmentImageProvider { - func textView(_ textView: TextView, attachment: NSTextAttachment, imageAt url: URL, onSuccess success: @escaping (UIImage) -> Void, onFailure failure: @escaping (Void) -> Void) { + func textView(_ textView: TextView, attachment: NSTextAttachment, imageAt url: URL, onSuccess success: @escaping (UIImage) -> Void, onFailure failure: @escaping () -> Void) { // NO OP! } From ae165bc1f5377f054bd2bbd6d3b2a3c6bca9c90f Mon Sep 17 00:00:00 2001 From: Jorge Leandro Perez Date: Mon, 28 Aug 2017 16:45:39 -0300 Subject: [PATCH 2/6] String+RangeConversion: Nukes dead methods --- .../Extensions/String+RangeConversion.swift | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/Aztec/Classes/Extensions/String+RangeConversion.swift b/Aztec/Classes/Extensions/String+RangeConversion.swift index 628c835ae..1ab74a117 100644 --- a/Aztec/Classes/Extensions/String+RangeConversion.swift +++ b/Aztec/Classes/Extensions/String+RangeConversion.swift @@ -81,15 +81,6 @@ public extension String { return start ..< end } - func range(from unicodeNSRange: Range) -> Range? { - guard let lowerBound = unicodeNSRange.lowerBound.samePosition(in: self), - let upperBound = unicodeNSRange.upperBound.samePosition(in: self) else { - return nil - } - - return lowerBound ..< upperBound - } - func nsRange(of string: String) -> NSRange? { guard let range = self.range(of: string) else { return nil @@ -131,20 +122,6 @@ public extension String { return NSRange(location: location, length: length) } - /// Converts a `Range` into an Unicod Scalar `NSRange`. - /// - /// - Parameters: - /// - range: the range to convert. - /// - /// - Returns: the requested `NSRange`. - /// - func nsRange(from range: Range) -> NSRange { - let location = unicodeScalars.distance(from: unicodeScalars.startIndex, to: range.lowerBound) - let length = unicodeScalars.distance(from: range.lowerBound, to: range.upperBound) - - return NSRange(location: location, length: length) - } - /// Returns a NSRange with a starting location at the very end of the string /// func endOfStringNSRange() -> NSRange { From fdf5d3a58045bb7e028aa30cba5138c48bcc7ded Mon Sep 17 00:00:00 2001 From: Jorge Leandro Perez Date: Mon, 28 Aug 2017 16:47:41 -0300 Subject: [PATCH 3/6] HTMLStorage: Fixing UIColor warnings --- Aztec/Classes/TextKit/HTMLStorage.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Aztec/Classes/TextKit/HTMLStorage.swift b/Aztec/Classes/TextKit/HTMLStorage.swift index cebbab7cf..6de859049 100644 --- a/Aztec/Classes/TextKit/HTMLStorage.swift +++ b/Aztec/Classes/TextKit/HTMLStorage.swift @@ -147,7 +147,7 @@ private extension HTMLStorage { /// struct Styles { static let defaultCommentColor = UIColor.lightGray - static let defaultTagColor = UIColor(colorLiteralRed: 0x00/255.0, green: 0x75/255.0, blue: 0xB6/255.0, alpha: 0xFF/255.0) - static let defaultQuotedColor = UIColor(colorLiteralRed: 0x6E/255.0, green: 0x96/255.0, blue: 0xB1/255.0, alpha: 0xFF/255.0) + static let defaultTagColor = UIColor(red: 0x00/255.0, green: 0x75/255.0, blue: 0xB6/255.0, alpha: 0xFF/255.0) + static let defaultQuotedColor = UIColor(red: 0x6E/255.0, green: 0x96/255.0, blue: 0xB1/255.0, alpha: 0xFF/255.0) } } From a1d9edae41731cd6e920dcfd936e293654f5d485 Mon Sep 17 00:00:00 2001 From: Jorge Leandro Perez Date: Mon, 28 Aug 2017 16:47:54 -0300 Subject: [PATCH 4/6] UIColorHexParserTests: Fixing UIColor Warnings --- AztecTests/Extensions/UIColorHexParserTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AztecTests/Extensions/UIColorHexParserTests.swift b/AztecTests/Extensions/UIColorHexParserTests.swift index c8de37b83..5085dba9c 100644 --- a/AztecTests/Extensions/UIColorHexParserTests.swift +++ b/AztecTests/Extensions/UIColorHexParserTests.swift @@ -28,7 +28,7 @@ class UIColorHexParserTests: XCTestCase { color = UIColor(hexString: "#FFFFFF") - XCTAssertEqual(color, UIColor.init(colorLiteralRed: 1, green: 1, blue: 1, alpha: 1)) + XCTAssertEqual(color, UIColor(red: 1, green: 1, blue: 1, alpha: 1)) } func testParseOf32bitsHexColors() { @@ -46,7 +46,7 @@ class UIColorHexParserTests: XCTestCase { color = UIColor(hexString: "#FFFFFFFF") - XCTAssertEqual(color, UIColor.init(colorLiteralRed: 1, green: 1, blue: 1, alpha: 1)) + XCTAssertEqual(color, UIColor(red: 1, green: 1, blue: 1, alpha: 1)) } func testFailingColor() { From 09e83f90a7a5d85c610e8d9c5d5db3f5e852a5a4 Mon Sep 17 00:00:00 2001 From: Jorge Leandro Perez Date: Mon, 28 Aug 2017 16:51:29 -0300 Subject: [PATCH 5/6] TextViewTests: Wiring missing Image Provider --- AztecTests/TextKit/TextViewTests.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/AztecTests/TextKit/TextViewTests.swift b/AztecTests/TextKit/TextViewTests.swift index efa75c94d..77b1b6afc 100644 --- a/AztecTests/TextKit/TextViewTests.swift +++ b/AztecTests/TextKit/TextViewTests.swift @@ -33,6 +33,7 @@ class TextViewTests: XCTestCase { func createTextView(withHTML html: String) -> TextView { let richTextView = Aztec.TextView(defaultFont: UIFont.systemFont(ofSize: 14), defaultMissingImage: UIImage()) richTextView.textAttachmentDelegate = attachmentDelegate + richTextView.registerAttachmentImageProvider(attachmentDelegate) richTextView.setHTML(html) return richTextView From b318d1be7693673c61f1e0657e56b06767e35ba9 Mon Sep 17 00:00:00 2001 From: Jorge Leandro Perez Date: Mon, 28 Aug 2017 17:40:44 -0300 Subject: [PATCH 6/6] NSRange+Helpers: NSRange Equality Implementation conditionally for Swift 3 --- Aztec/Classes/Extensions/NSRange+Helpers.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Aztec/Classes/Extensions/NSRange+Helpers.swift b/Aztec/Classes/Extensions/NSRange+Helpers.swift index f4cccefbf..6cadcd5f6 100644 --- a/Aztec/Classes/Extensions/NSRange+Helpers.swift +++ b/Aztec/Classes/Extensions/NSRange+Helpers.swift @@ -139,8 +139,13 @@ extension Sequence where Iterator.Element == NSRange { } } -extension NSRange: Equatable { - public static func ==(lhs: NSRange, rhs: NSRange) -> Bool{ - return lhs.location == rhs.location && lhs.length == rhs.length +#if swift(>=3.2) + // No Op +#else + extension NSRange: Equatable { + public static func ==(lhs: NSRange, rhs: NSRange) -> Bool{ + return lhs.location == rhs.location && lhs.length == rhs.length + } } -} +#endif +