From 2d5c0347746599db2887d7c1780e264440b9cf2a Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 17 Mar 2020 15:59:18 +0100 Subject: [PATCH] Prepare release 1.17.0 (#1272) Fix drawing of underlines when they have a nbsp and span to the end of a line. --- Aztec/Classes/TextKit/LayoutManager.swift | 14 +++++++++++++- CHANGELOG.md | 4 ++++ Example/AztecExample.xcodeproj/project.pbxproj | 4 ++++ Example/Example/SampleContent/content.html | 2 +- Example/Example/SampleContent/underline.html | 4 ++++ Example/Example/ViewController.swift | 1 + WordPress-Aztec-iOS.podspec | 2 +- WordPress-Editor-iOS.podspec | 2 +- 8 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 Example/Example/SampleContent/underline.html diff --git a/Aztec/Classes/TextKit/LayoutManager.swift b/Aztec/Classes/TextKit/LayoutManager.swift index 5ffdca08a..d0c5c04dd 100644 --- a/Aztec/Classes/TextKit/LayoutManager.swift +++ b/Aztec/Classes/TextKit/LayoutManager.swift @@ -201,7 +201,6 @@ private extension LayoutManager { } } - // MARK: - Lists Helpers // private extension LayoutManager { @@ -360,3 +359,16 @@ private extension LayoutManager { } } } + +extension LayoutManager { + + override func underlineGlyphRange(_ glyphRange: NSRange, underlineType underlineVal: NSUnderlineStyle, lineFragmentRect lineRect: CGRect, lineFragmentGlyphRange lineGlyphRange: NSRange, containerOrigin: CGPoint) { + + var updatedGlyphRange = glyphRange + if glyphRange.endLocation == lineGlyphRange.endLocation { + updatedGlyphRange = NSRange(location: glyphRange.location, length: glyphRange.length - 1) + } + drawUnderline(forGlyphRange: updatedGlyphRange, underlineType: underlineVal, baselineOffset: 0, lineFragmentRect: lineRect, lineFragmentGlyphRange: lineGlyphRange, containerOrigin: containerOrigin) + } +} + diff --git a/CHANGELOG.md b/CHANGELOG.md index 2547e7ef1..9ce9c9307 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +1.17.0 +----- + * Fix drawing of underlines when they have a nbsp and span to the end of a line + 1.16.0 ----- * Improve display of ordered lists with large bullet numbers diff --git a/Example/AztecExample.xcodeproj/project.pbxproj b/Example/AztecExample.xcodeproj/project.pbxproj index b4e81ccd2..a76700b52 100644 --- a/Example/AztecExample.xcodeproj/project.pbxproj +++ b/Example/AztecExample.xcodeproj/project.pbxproj @@ -39,6 +39,7 @@ F1D3610B20929F0200B4E7A5 /* WordPressEditor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F1D3610420929E6D00B4E7A5 /* WordPressEditor.framework */; }; FF149F4A20E3C49A0070FECB /* imagesOverlays.html in Resources */ = {isa = PBXBuildFile; fileRef = FF149F4920E3C49A0070FECB /* imagesOverlays.html */; }; FF1FD05C20932EDE00186384 /* gutenberg.html in Resources */ = {isa = PBXBuildFile; fileRef = FF1FD05B20932EDE00186384 /* gutenberg.html */; }; + FF1FEC7E2406E071006221AA /* underline.html in Resources */ = {isa = PBXBuildFile; fileRef = FF1FEC7D2406E071006221AA /* underline.html */; }; FF5CDACD239E78B200CF235B /* failedMedia.html in Resources */ = {isa = PBXBuildFile; fileRef = FF5CDACC239E78B200CF235B /* failedMedia.html */; }; FF629DC9223BC418004C4106 /* videoShortcodes.html in Resources */ = {isa = PBXBuildFile; fileRef = FF629DC8223BC418004C4106 /* videoShortcodes.html */; }; FF9AF5481DB0E4E200C42ED3 /* AttachmentDetailsViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FF9AF5471DB0E4E200C42ED3 /* AttachmentDetailsViewController.storyboard */; }; @@ -160,6 +161,7 @@ F1D360FC20929E6D00B4E7A5 /* WordPressEditor.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = WordPressEditor.xcodeproj; path = ../WordPressEditor/WordPressEditor.xcodeproj; sourceTree = ""; }; FF149F4920E3C49A0070FECB /* imagesOverlays.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = imagesOverlays.html; sourceTree = ""; }; FF1FD05B20932EDE00186384 /* gutenberg.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = gutenberg.html; sourceTree = ""; }; + FF1FEC7D2406E071006221AA /* underline.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = underline.html; sourceTree = ""; }; FF5CDACC239E78B200CF235B /* failedMedia.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = failedMedia.html; sourceTree = ""; }; FF629DC8223BC418004C4106 /* videoShortcodes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = videoShortcodes.html; sourceTree = ""; }; FF9AF5471DB0E4E200C42ED3 /* AttachmentDetailsViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = AttachmentDetailsViewController.storyboard; sourceTree = ""; }; @@ -214,6 +216,7 @@ FF629DC8223BC418004C4106 /* videoShortcodes.html */, FF5CDACC239E78B200CF235B /* failedMedia.html */, FFC6772123D07E3E00B76815 /* bigLists.html */, + FF1FEC7D2406E071006221AA /* underline.html */, ); path = SampleContent; sourceTree = ""; @@ -465,6 +468,7 @@ 59280F2B1D47CAF40083FB59 /* SampleText.rtf in Resources */, 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, FF149F4A20E3C49A0070FECB /* imagesOverlays.html in Resources */, + FF1FEC7E2406E071006221AA /* underline.html in Resources */, FFC41BDE20DBC7BA004DFB4D /* video.html in Resources */, FF9AF5481DB0E4E200C42ED3 /* AttachmentDetailsViewController.storyboard in Resources */, ); diff --git a/Example/Example/SampleContent/content.html b/Example/Example/SampleContent/content.html index a6a54eb1e..2da6a99ed 100644 --- a/Example/Example/SampleContent/content.html +++ b/Example/Example/SampleContent/content.html @@ -13,7 +13,7 @@

Character Styles

Underline: Underlined text
Strikethrough: Strikethrough
Colors: Royal Blue by name Red by hex

-Undeline with CSS: Alternative underline text
+Underline with CSS: Alternative underline text
Links: I'm a link!
Open in new window link!
Code: print("Hello world") diff --git a/Example/Example/SampleContent/underline.html b/Example/Example/SampleContent/underline.html new file mode 100644 index 000000000..9bf5bd168 --- /dev/null +++ b/Example/Example/SampleContent/underline.html @@ -0,0 +1,4 @@ +

Hello world

+

Alternative underline text

+

Before link Link to WordPress

+

Before link Link to Jetpack After link

diff --git a/Example/Example/ViewController.swift b/Example/Example/ViewController.swift index 7ccafeb8d..e57963bee 100644 --- a/Example/Example/ViewController.swift +++ b/Example/Example/ViewController.swift @@ -21,6 +21,7 @@ class ViewController: UITableViewController DemoRow(title: "Video Demo", action: { self.showEditorDemo(filename: "video", wordPressMode: false) }), DemoRow(title: "Failed Media", action: { self.showEditorDemo(filename: "failedMedia") }), DemoRow(title: "Big Lists", action: { self.showEditorDemo(filename: "bigLists") }), + DemoRow(title: "Underline NBSP", action: { self.showEditorDemo(filename: "underline")}), DemoRow(title: "Empty Demo", action: { self.showEditorDemo() }) ] ), diff --git a/WordPress-Aztec-iOS.podspec b/WordPress-Aztec-iOS.podspec index e991ddd83..c23b3be52 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.16.0' + s.version = '1.17.0' 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 c1f383a7d..3ceb23e44 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.16.0' + s.version = '1.17.0' s.summary = 'The WordPress HTML Editor.' # This description is used to generate tags and improve search results.