From cb2b2d82581d0bfcce9b40022fae45cb87eeb224 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 26 May 2020 11:26:22 +0100 Subject: [PATCH 1/4] Apply layout even if no nbsp is present. The fix needs to be applied every time there is any kind of newline character at the end of the character range. --- Aztec/Classes/TextKit/LayoutManager.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Aztec/Classes/TextKit/LayoutManager.swift b/Aztec/Classes/TextKit/LayoutManager.swift index 4e277b255..abddc70c7 100644 --- a/Aztec/Classes/TextKit/LayoutManager.swift +++ b/Aztec/Classes/TextKit/LayoutManager.swift @@ -368,9 +368,8 @@ extension LayoutManager { } let underlinedString = textStorage.attributedSubstring(from: glyphRange).string var updatedGlyphRange = glyphRange - if glyphRange.endLocation == lineGlyphRange.endLocation, - underlinedString.contains(String.init(.nonBreakingSpace)), - underlinedString.hasSuffix(String.init(.paragraphSeparator)) + if glyphRange.endLocation == lineGlyphRange.endLocation, + underlinedString.hasSuffix(String.init(.paragraphSeparator)) || underlinedString.hasSuffix(String.init(.lineSeparator)) || underlinedString.hasSuffix(String.init(.carriageReturn)) || underlinedString.hasSuffix(String.init(.lineFeed)) { updatedGlyphRange = NSRange(location: glyphRange.location, length: glyphRange.length - 1) } From 0a3c161ff02e076be8f0e9fcab599f4d6c41e932 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 26 May 2020 13:47:55 +0100 Subject: [PATCH 2/4] Update sample text --- Example/Example/SampleContent/underline.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Example/Example/SampleContent/underline.html b/Example/Example/SampleContent/underline.html index 86fc4e322..fc73045a6 100644 --- a/Example/Example/SampleContent/underline.html +++ b/Example/Example/SampleContent/underline.html @@ -1,4 +1,5 @@ -

Hello world

+

No NBSP

+

With NBSP

Alternative underline text

Before link Link to WordPress

Before link Link to Jetpack After link

From a9e6c28eb60b751e29352ba805c56f7a72328d79 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 26 May 2020 13:48:06 +0100 Subject: [PATCH 3/4] Bump release number --- CHANGELOG.md | 4 ++++ WordPress-Aztec-iOS.podspec | 2 +- WordPress-Editor-iOS.podspec | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 635240b3a..cea160fd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +1.19.2 +------- +* Fix drawing of underlines when they include newlines. + 1.19.1 ------- * Fix a bug where collapse of whitespaces was happening for empty HTML nodes. diff --git a/WordPress-Aztec-iOS.podspec b/WordPress-Aztec-iOS.podspec index ffafac692..083f661c3 100644 --- a/WordPress-Aztec-iOS.podspec +++ b/WordPress-Aztec-iOS.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'WordPress-Aztec-iOS' - s.version = '1.19.1' + s.version = '1.19.2' s.summary = 'The native HTML Editor.' # This description is used to generate tags and improve search results. diff --git a/WordPress-Editor-iOS.podspec b/WordPress-Editor-iOS.podspec index cdbf801bc..8971b3f46 100644 --- a/WordPress-Editor-iOS.podspec +++ b/WordPress-Editor-iOS.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'WordPress-Editor-iOS' - s.version = '1.19.1' + s.version = '1.19.2' s.summary = 'The WordPress HTML Editor.' # This description is used to generate tags and improve search results. From cfa0fc139931a0d800ce98f66e5551810693297a Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 26 May 2020 15:49:00 +0100 Subject: [PATCH 4/4] Remove extra spaces. --- Aztec/Classes/TextKit/LayoutManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Aztec/Classes/TextKit/LayoutManager.swift b/Aztec/Classes/TextKit/LayoutManager.swift index abddc70c7..772aa7d23 100644 --- a/Aztec/Classes/TextKit/LayoutManager.swift +++ b/Aztec/Classes/TextKit/LayoutManager.swift @@ -368,7 +368,7 @@ extension LayoutManager { } let underlinedString = textStorage.attributedSubstring(from: glyphRange).string var updatedGlyphRange = glyphRange - if glyphRange.endLocation == lineGlyphRange.endLocation, + if glyphRange.endLocation == lineGlyphRange.endLocation, underlinedString.hasSuffix(String.init(.paragraphSeparator)) || underlinedString.hasSuffix(String.init(.lineSeparator)) || underlinedString.hasSuffix(String.init(.carriageReturn)) || underlinedString.hasSuffix(String.init(.lineFeed)) { updatedGlyphRange = NSRange(location: glyphRange.location, length: glyphRange.length - 1)