@apollohg/react-native-prose-editor 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/ios/EditorCore.xcframework/ios-arm64/libeditor_core.a +0 -0
- package/ios/EditorCore.xcframework/ios-arm64_x86_64-simulator/libeditor_core.a +0 -0
- package/ios/RichTextEditorView.swift +31 -0
- package/package.json +1 -1
- package/rust/android/arm64-v8a/libeditor_core.so +0 -0
- package/rust/android/armeabi-v7a/libeditor_core.so +0 -0
- package/rust/android/x86_64/libeditor_core.so +0 -0
package/README.md
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -1153,6 +1153,15 @@ final class EditorTextView: UITextView, UITextViewDelegate, UIGestureRecognizerD
|
|
|
1153
1153
|
}
|
|
1154
1154
|
}
|
|
1155
1155
|
|
|
1156
|
+
override func becomeFirstResponder() -> Bool {
|
|
1157
|
+
let didBecomeFirstResponder = super.becomeFirstResponder()
|
|
1158
|
+
if didBecomeFirstResponder {
|
|
1159
|
+
_ = normalizeSelectionForEmptyBlockAutocapitalizationIfNeeded()
|
|
1160
|
+
refreshTypingAttributesForSelection()
|
|
1161
|
+
}
|
|
1162
|
+
return didBecomeFirstResponder
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1156
1165
|
private func isRenderedContentEmpty() -> Bool {
|
|
1157
1166
|
let renderedText = textStorage.string
|
|
1158
1167
|
guard !renderedText.isEmpty else { return true }
|
|
@@ -1169,6 +1178,23 @@ final class EditorTextView: UITextView, UITextViewDelegate, UIGestureRecognizerD
|
|
|
1169
1178
|
return true
|
|
1170
1179
|
}
|
|
1171
1180
|
|
|
1181
|
+
@discardableResult
|
|
1182
|
+
private func normalizeSelectionForEmptyBlockAutocapitalizationIfNeeded() -> Bool {
|
|
1183
|
+
guard textStorage.length == 1 else { return false }
|
|
1184
|
+
guard textStorage.string.unicodeScalars.elementsEqual([Self.emptyBlockPlaceholderScalar]) else {
|
|
1185
|
+
return false
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
let currentRange = selectedRange
|
|
1189
|
+
guard currentRange.location != NSNotFound, currentRange.length == 0 else { return false }
|
|
1190
|
+
guard currentRange.location == textStorage.length else { return false }
|
|
1191
|
+
|
|
1192
|
+
let adjustedRange = NSRange(location: 0, length: 0)
|
|
1193
|
+
guard currentRange != adjustedRange else { return false }
|
|
1194
|
+
selectedRange = adjustedRange
|
|
1195
|
+
return true
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1172
1198
|
private func refreshPlaceholderVisibility() {
|
|
1173
1199
|
placeholderLabel.isHidden = placeholder.isEmpty || !isRenderedContentEmpty()
|
|
1174
1200
|
}
|
|
@@ -1947,6 +1973,9 @@ final class EditorTextView: UITextView, UITextViewDelegate, UIGestureRecognizerD
|
|
|
1947
1973
|
func textViewDidChangeSelection(_ textView: UITextView) {
|
|
1948
1974
|
guard textView === self else { return }
|
|
1949
1975
|
guard !isApplyingRustState else { return }
|
|
1976
|
+
if normalizeSelectionForEmptyBlockAutocapitalizationIfNeeded() {
|
|
1977
|
+
return
|
|
1978
|
+
}
|
|
1950
1979
|
refreshNativeSelectionChromeVisibility()
|
|
1951
1980
|
onSelectionOrContentMayChange?()
|
|
1952
1981
|
scheduleSelectionSync()
|
|
@@ -2099,7 +2128,9 @@ final class EditorTextView: UITextView, UITextViewDelegate, UIGestureRecognizerD
|
|
|
2099
2128
|
}
|
|
2100
2129
|
|
|
2101
2130
|
func refreshSelectionVisualState() {
|
|
2131
|
+
_ = normalizeSelectionForEmptyBlockAutocapitalizationIfNeeded()
|
|
2102
2132
|
refreshNativeSelectionChromeVisibility()
|
|
2133
|
+
refreshTypingAttributesForSelection()
|
|
2103
2134
|
onSelectionOrContentMayChange?()
|
|
2104
2135
|
}
|
|
2105
2136
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollohg/react-native-prose-editor",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Native rich text editor with Rust core for React Native",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/apollohg/react-native-prose-editor",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|