From 8201fd98defa9e2d8613ce218a5a79bd0710e550 Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Wed, 15 Nov 2017 10:37:21 -0300 Subject: [PATCH 1/3] Merges a fix from develop. --- Aztec/Classes/TextKit/HTMLStorage.swift | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Aztec/Classes/TextKit/HTMLStorage.swift b/Aztec/Classes/TextKit/HTMLStorage.swift index 30b2f38b7..7fcdf4c18 100644 --- a/Aztec/Classes/TextKit/HTMLStorage.swift +++ b/Aztec/Classes/TextKit/HTMLStorage.swift @@ -83,20 +83,13 @@ open class HTMLStorage: NSTextStorage { endEditing() } - override open func addAttribute(_ name: String, value: Any, range: NSRange) { - textStore.addAttribute(name, value: value, range: range) - } - - override open func removeAttribute(_ name: String, range: NSRange) { - textStore.removeAttribute(name, range: range) - } - override open func replaceCharacters(in range: NSRange, with str: String) { beginEditing() textStore.replaceCharacters(in: range, with: str) edited([.editedAttributes, .editedCharacters], range: range, changeInLength: string.characters.count - range.length) + colorizeHTML() endEditing() } @@ -106,12 +99,8 @@ open class HTMLStorage: NSTextStorage { textStore.replaceCharacters(in: range, with: attrString) edited([.editedAttributes, .editedCharacters], range: range, changeInLength: attrString.length - range.length) - endEditing() - } - - override open func processEditing() { colorizeHTML() - super.processEditing() + endEditing() } } @@ -129,6 +118,7 @@ private extension HTMLStorage { addAttribute(NSFontAttributeName, value: font, range: fullStringRange) let tags = RegExes.html.matches(in: string, options: [], range: fullStringRange) + for tag in tags { addAttribute(NSForegroundColorAttributeName, value: tagColor, range: tag.range) @@ -137,11 +127,13 @@ private extension HTMLStorage { addAttribute(NSForegroundColorAttributeName, value: quotedColor, range: quote.range) } } - + let comments = RegExes.comments.matches(in: string, options: [], range: fullStringRange) for comment in comments { addAttribute(NSForegroundColorAttributeName, value: commentColor, range: comment.range) } + + edited(.editedAttributes, range: fullStringRange, changeInLength: 0) } } From 005e06c304a277274f1d3e5fdb7ba1b0bafe63a7 Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Wed, 15 Nov 2017 12:11:44 -0300 Subject: [PATCH 2/3] Removes some empty lines with whitespace. --- 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 7fcdf4c18..2a6c2a2e1 100644 --- a/Aztec/Classes/TextKit/HTMLStorage.swift +++ b/Aztec/Classes/TextKit/HTMLStorage.swift @@ -118,7 +118,7 @@ private extension HTMLStorage { addAttribute(NSFontAttributeName, value: font, range: fullStringRange) let tags = RegExes.html.matches(in: string, options: [], range: fullStringRange) - + for tag in tags { addAttribute(NSForegroundColorAttributeName, value: tagColor, range: tag.range) @@ -127,7 +127,7 @@ private extension HTMLStorage { addAttribute(NSForegroundColorAttributeName, value: quotedColor, range: quote.range) } } - + let comments = RegExes.comments.matches(in: string, options: [], range: fullStringRange) for comment in comments { addAttribute(NSForegroundColorAttributeName, value: commentColor, range: comment.range) From b11d9df36d83e3b137d0fdc1476c386356895883 Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Wed, 15 Nov 2017 12:12:36 -0300 Subject: [PATCH 3/3] Removes an empty line with whitespace. --- Aztec/Classes/TextKit/HTMLStorage.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Aztec/Classes/TextKit/HTMLStorage.swift b/Aztec/Classes/TextKit/HTMLStorage.swift index 2a6c2a2e1..f949e5347 100644 --- a/Aztec/Classes/TextKit/HTMLStorage.swift +++ b/Aztec/Classes/TextKit/HTMLStorage.swift @@ -132,7 +132,7 @@ private extension HTMLStorage { for comment in comments { addAttribute(NSForegroundColorAttributeName, value: commentColor, range: comment.range) } - + edited(.editedAttributes, range: fullStringRange, changeInLength: 0) } }