@apollohg/react-native-prose-editor 0.1.0 → 0.1.1

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.
@@ -4,7 +4,7 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'com.apollohg'
7
- version = '0.1.0'
7
+ version = '0.1.1'
8
8
 
9
9
  android {
10
10
  namespace "com.apollohg.editor"
@@ -13,7 +13,7 @@ android {
13
13
  }
14
14
  defaultConfig {
15
15
  versionCode 1
16
- versionName '0.1.0'
16
+ versionName '0.1.1'
17
17
  }
18
18
 
19
19
  // Include prebuilt Rust .so files from the package's rust/android/ directory
@@ -140,6 +140,7 @@ final class EditorTextView: UITextView, UITextViewDelegate {
140
140
  /// and replaying a user input operation through Rust, including the
141
141
  /// trailing UIKit text-storage callbacks that arrive on the next run loop.
142
142
  private var interceptedInputDepth = 0
143
+ private var reconciliationWorkScheduled = false
143
144
 
144
145
  /// Coalesces selection sync until UIKit has finished resolving the
145
146
  /// current tap/drag gesture's final caret position.
@@ -1383,10 +1384,27 @@ extension EditorTextView: NSTextStorageDelegate {
1383
1384
  """
1384
1385
  )
1385
1386
 
1386
- // Reconcile by pulling the current editor state without rebuilding
1387
- // the Rust backend or clearing history.
1388
- let stateJSON = editorGetCurrentState(id: editorId)
1389
- applyUpdateJSON(stateJSON)
1387
+ scheduleReconciliationFromRust()
1388
+ }
1389
+
1390
+ private func scheduleReconciliationFromRust() {
1391
+ guard !reconciliationWorkScheduled else { return }
1392
+ reconciliationWorkScheduled = true
1393
+
1394
+ DispatchQueue.main.async { [weak self] in
1395
+ guard let self else { return }
1396
+ self.reconciliationWorkScheduled = false
1397
+
1398
+ guard !self.isApplyingRustState, !self.isInterceptingInput else { return }
1399
+ guard self.editorId != 0 else { return }
1400
+ guard self.textStorage.string != self.lastAuthorizedText else { return }
1401
+
1402
+ // Reconcile by pulling the current editor state without rebuilding
1403
+ // the Rust backend or clearing history. This must run after the
1404
+ // current NSTextStorage edit transaction has finished.
1405
+ let stateJSON = editorGetCurrentState(id: self.editorId)
1406
+ self.applyUpdateJSON(stateJSON)
1407
+ }
1390
1408
  }
1391
1409
  }
1392
1410
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollohg/react-native-prose-editor",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
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",