From deaae63cf7c7e7236c8584c9ac14413500491769 Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Wed, 6 Nov 2019 17:09:20 +0100 Subject: [PATCH 1/3] Prevents selection after ZWSP character --- .../ios/RNTAztecView/RCTAztecView.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift b/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift index 09e63852deed65..a6466fa1025e10 100644 --- a/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift +++ b/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift @@ -603,6 +603,15 @@ class RCTAztecView: Aztec.TextView { let caretData = packCaretDataForRN() onSelectionChange(caretData) } + + // MARK: - Selection + private func correctSelectionAfterZWSP() { + guard selectedTextRange?.start == endOfDocument, + text == String(.zeroWidthSpace) else { + return + } + selectedTextRange = self.textRange(from: beginningOfDocument, to: beginningOfDocument) + } } // MARK: UITextView Delegate Methods @@ -613,9 +622,14 @@ extension RCTAztecView: UITextViewDelegate { return } + correctSelectionAfterZWSP() propagateSelectionChanges() } + func textViewDidBeginEditing(_ textView: UITextView) { + correctSelectionAfterZWSP() + } + func textViewDidChange(_ textView: UITextView) { guard isInsertingDictationResult == false else { return From f6a1488f9df797ec43f5a1424561f8ee539cef17 Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Wed, 6 Nov 2019 17:19:15 +0100 Subject: [PATCH 2/3] Add item to release notes --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 7351b001cccc0f..583b2e6b04fe44 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,6 +1,7 @@ 1.17.0 ------ * Use existing links in the clipboard to prefill url field when inserting new link. +* [iOS] Fix issue where the keyboard would not capitalize sentences correctly on some cases. 1.16.0 ------ From cc4303d9b382c372d788a05306dcb7c4ee981a9f Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Fri, 8 Nov 2019 12:24:31 +0100 Subject: [PATCH 3/3] Use characterToReplaceLastEmptyLine instead of harcoding to ZWSP --- react-native-aztec/ios/RNTAztecView/RCTAztecView.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift b/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift index a6466fa1025e10..77a6627cf8bb8e 100644 --- a/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift +++ b/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift @@ -605,9 +605,10 @@ class RCTAztecView: Aztec.TextView { } // MARK: - Selection - private func correctSelectionAfterZWSP() { + private func correctSelectionAfterLastEmptyLine() { guard selectedTextRange?.start == endOfDocument, - text == String(.zeroWidthSpace) else { + let characterToReplaceLastEmptyLine = storage.htmlConverter.characterToReplaceLastEmptyLine, + text == String(characterToReplaceLastEmptyLine) else { return } selectedTextRange = self.textRange(from: beginningOfDocument, to: beginningOfDocument) @@ -622,12 +623,12 @@ extension RCTAztecView: UITextViewDelegate { return } - correctSelectionAfterZWSP() + correctSelectionAfterLastEmptyLine() propagateSelectionChanges() } func textViewDidBeginEditing(_ textView: UITextView) { - correctSelectionAfterZWSP() + correctSelectionAfterLastEmptyLine() } func textViewDidChange(_ textView: UITextView) {