@apollohg/react-native-prose-editor 0.5.19 → 0.5.21

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.
@@ -8,32 +8,32 @@
8
8
  <key>BinaryPath</key>
9
9
  <string>libeditor_core.a</string>
10
10
  <key>LibraryIdentifier</key>
11
- <string>ios-arm64_x86_64-simulator</string>
11
+ <string>ios-arm64</string>
12
12
  <key>LibraryPath</key>
13
13
  <string>libeditor_core.a</string>
14
14
  <key>SupportedArchitectures</key>
15
15
  <array>
16
16
  <string>arm64</string>
17
- <string>x86_64</string>
18
17
  </array>
19
18
  <key>SupportedPlatform</key>
20
19
  <string>ios</string>
21
- <key>SupportedPlatformVariant</key>
22
- <string>simulator</string>
23
20
  </dict>
24
21
  <dict>
25
22
  <key>BinaryPath</key>
26
23
  <string>libeditor_core.a</string>
27
24
  <key>LibraryIdentifier</key>
28
- <string>ios-arm64</string>
25
+ <string>ios-arm64_x86_64-simulator</string>
29
26
  <key>LibraryPath</key>
30
27
  <string>libeditor_core.a</string>
31
28
  <key>SupportedArchitectures</key>
32
29
  <array>
33
30
  <string>arm64</string>
31
+ <string>x86_64</string>
34
32
  </array>
35
33
  <key>SupportedPlatform</key>
36
34
  <string>ios</string>
35
+ <key>SupportedPlatformVariant</key>
36
+ <string>simulator</string>
37
37
  </dict>
38
38
  </array>
39
39
  <key>CFBundlePackageType</key>
@@ -2566,6 +2566,7 @@ class NativeEditorExpoView: ExpoView, EditorTextViewDelegate, UIGestureRecognize
2566
2566
  }
2567
2567
 
2568
2568
  func blur() {
2569
+ clearRecentToolbarTouch()
2569
2570
  richTextView.textView.resignFirstResponder()
2570
2571
  }
2571
2572
 
@@ -2603,7 +2604,7 @@ class NativeEditorExpoView: ExpoView, EditorTextViewDelegate, UIGestureRecognize
2603
2604
  }
2604
2605
 
2605
2606
  @objc private func textViewDidEndEditing(_ notification: Notification) {
2606
- if shouldPreserveFocusAfterToolbarTouch() {
2607
+ if consumeToolbarFocusPreservationForBlur() {
2607
2608
  DispatchQueue.main.async { [weak self] in
2608
2609
  _ = self?.richTextView.textView.becomeFirstResponder()
2609
2610
  }
@@ -2624,6 +2625,7 @@ class NativeEditorExpoView: ExpoView, EditorTextViewDelegate, UIGestureRecognize
2624
2625
  guard shouldHandleOutsideTap(locationInWindow: locationInWindow, touchedView: nil) else {
2625
2626
  return
2626
2627
  }
2628
+ clearRecentToolbarTouch()
2627
2629
  blur()
2628
2630
  }
2629
2631
 
@@ -2648,13 +2650,26 @@ class NativeEditorExpoView: ExpoView, EditorTextViewDelegate, UIGestureRecognize
2648
2650
  guard gestureRecognizer === outsideTapGestureRecognizer else { return true }
2649
2651
  guard let tapWindow = gestureWindow ?? window else { return true }
2650
2652
  let locationInWindow = touch.location(in: tapWindow)
2653
+ return prepareOutsideTapForFocusHandling(
2654
+ locationInWindow: locationInWindow,
2655
+ touchedView: touch.view
2656
+ )
2657
+ }
2658
+
2659
+ private func prepareOutsideTapForFocusHandling(
2660
+ locationInWindow: CGPoint,
2661
+ touchedView: UIView?
2662
+ ) -> Bool {
2651
2663
  if isLocationInStandaloneToolbarFrame(locationInWindow) {
2652
2664
  markRecentToolbarTouch()
2653
2665
  }
2654
2666
  let result = shouldHandleOutsideTap(
2655
2667
  locationInWindow: locationInWindow,
2656
- touchedView: touch.view
2668
+ touchedView: touchedView
2657
2669
  )
2670
+ if result {
2671
+ clearRecentToolbarTouch()
2672
+ }
2658
2673
  return result
2659
2674
  }
2660
2675
 
@@ -2662,10 +2677,20 @@ class NativeEditorExpoView: ExpoView, EditorTextViewDelegate, UIGestureRecognize
2662
2677
  lastToolbarTouchUptime = ProcessInfo.processInfo.systemUptime
2663
2678
  }
2664
2679
 
2680
+ private func clearRecentToolbarTouch() {
2681
+ lastToolbarTouchUptime = -Double.infinity
2682
+ }
2683
+
2665
2684
  private func shouldPreserveFocusAfterToolbarTouch() -> Bool {
2666
2685
  ProcessInfo.processInfo.systemUptime - lastToolbarTouchUptime <= 0.75
2667
2686
  }
2668
2687
 
2688
+ private func consumeToolbarFocusPreservationForBlur() -> Bool {
2689
+ guard shouldPreserveFocusAfterToolbarTouch() else { return false }
2690
+ clearRecentToolbarTouch()
2691
+ return true
2692
+ }
2693
+
2669
2694
  private func isLocationInStandaloneToolbarFrame(_ locationInWindow: CGPoint) -> Bool {
2670
2695
  toolbarFramesInWindow.contains(where: { $0.contains(locationInWindow) })
2671
2696
  }
@@ -3317,6 +3342,28 @@ class NativeEditorExpoView: ExpoView, EditorTextViewDelegate, UIGestureRecognize
3317
3342
  richTextView.textView.inputAccessoryView === accessoryPlaceholder
3318
3343
  }
3319
3344
 
3345
+ func markRecentToolbarTouchForTesting() {
3346
+ markRecentToolbarTouch()
3347
+ }
3348
+
3349
+ func shouldPreserveFocusAfterToolbarTouchForTesting() -> Bool {
3350
+ shouldPreserveFocusAfterToolbarTouch()
3351
+ }
3352
+
3353
+ func consumeToolbarFocusPreservationForTesting() -> Bool {
3354
+ consumeToolbarFocusPreservationForBlur()
3355
+ }
3356
+
3357
+ func prepareOutsideTapForFocusHandlingForTesting(
3358
+ locationInWindow: CGPoint,
3359
+ touchedView: UIView? = nil
3360
+ ) -> Bool {
3361
+ prepareOutsideTapForFocusHandling(
3362
+ locationInWindow: locationInWindow,
3363
+ touchedView: touchedView
3364
+ )
3365
+ }
3366
+
3320
3367
  private func updateAccessoryToolbarVisibility() {
3321
3368
  guard prepareForInputAccessoryMutationOrRetry(.updateAccessoryToolbarVisibility) else { return }
3322
3369
  refreshSystemAssistantToolbarIfNeeded()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollohg/react-native-prose-editor",
3
- "version": "0.5.19",
3
+ "version": "0.5.21",
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",
@@ -20,7 +20,9 @@
20
20
  "types": "./dist/index.d.ts",
21
21
  "react-native": "./dist/index.js",
22
22
  "default": "./dist/index.js"
23
- }
23
+ },
24
+ "./app.plugin": "./app.plugin.js",
25
+ "./app.plugin.js": "./app.plugin.js"
24
26
  },
25
27
  "private": false,
26
28
  "publishConfig": {
@@ -74,6 +76,7 @@
74
76
  "files": [
75
77
  "README.md",
76
78
  "LICENSE",
79
+ "app.plugin.js",
77
80
  "dist",
78
81
  "android/build.gradle",
79
82
  "android/consumer-rules.pro",