@apollohg/react-native-prose-editor 0.5.19 → 0.5.20
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/android/src/main/java/com/apollohg/editor/EditorEditText.kt +21 -1
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +4 -1
- package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +10 -2
- 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/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
|
@@ -3779,8 +3779,13 @@ class EditorEditText @JvmOverloads constructor(
|
|
|
3779
3779
|
*
|
|
3780
3780
|
* @param updateJSON The JSON string from editor_insert_text, etc.
|
|
3781
3781
|
*/
|
|
3782
|
-
fun applyUpdateJSON(
|
|
3782
|
+
fun applyUpdateJSON(
|
|
3783
|
+
updateJSON: String,
|
|
3784
|
+
notifyListener: Boolean = true,
|
|
3785
|
+
refreshInputConnectionForExternalUpdate: Boolean = false
|
|
3786
|
+
) {
|
|
3783
3787
|
val totalStartedAt = System.nanoTime()
|
|
3788
|
+
val previousVisibleText = text?.toString().orEmpty()
|
|
3784
3789
|
val parseStartedAt = totalStartedAt
|
|
3785
3790
|
val update = try {
|
|
3786
3791
|
org.json.JSONObject(updateJSON)
|
|
@@ -3891,6 +3896,10 @@ class EditorEditText @JvmOverloads constructor(
|
|
|
3891
3896
|
} else {
|
|
3892
3897
|
preserveScrollPosition(previousScrollX, previousScrollY)
|
|
3893
3898
|
}
|
|
3899
|
+
refreshInputConnectionAfterExternalTextReplacementIfNeeded(
|
|
3900
|
+
enabled = refreshInputConnectionForExternalUpdate,
|
|
3901
|
+
previousVisibleText = previousVisibleText
|
|
3902
|
+
)
|
|
3894
3903
|
val postApplyNanos = System.nanoTime() - postApplyStartedAt
|
|
3895
3904
|
|
|
3896
3905
|
val totalNanos = System.nanoTime() - totalStartedAt
|
|
@@ -3916,6 +3925,17 @@ class EditorEditText @JvmOverloads constructor(
|
|
|
3916
3925
|
}
|
|
3917
3926
|
}
|
|
3918
3927
|
|
|
3928
|
+
private fun refreshInputConnectionAfterExternalTextReplacementIfNeeded(
|
|
3929
|
+
enabled: Boolean,
|
|
3930
|
+
previousVisibleText: String
|
|
3931
|
+
) {
|
|
3932
|
+
if (!enabled || !hasFocus()) return
|
|
3933
|
+
val currentVisibleText = text?.toString().orEmpty()
|
|
3934
|
+
if (currentVisibleText == previousVisibleText) return
|
|
3935
|
+
retireInputConnectionForEditor()
|
|
3936
|
+
restartInputForEditor("externalUpdate")
|
|
3937
|
+
}
|
|
3938
|
+
|
|
3919
3939
|
/**
|
|
3920
3940
|
* Apply a render JSON string (just render elements, no update wrapper).
|
|
3921
3941
|
*
|
|
@@ -1744,7 +1744,10 @@ class NativeEditorExpoView(
|
|
|
1744
1744
|
}
|
|
1745
1745
|
isApplyingJSUpdate = true
|
|
1746
1746
|
return try {
|
|
1747
|
-
richTextView.editorEditText.applyUpdateJSON(
|
|
1747
|
+
richTextView.editorEditText.applyUpdateJSON(
|
|
1748
|
+
updateJson,
|
|
1749
|
+
refreshInputConnectionForExternalUpdate = true
|
|
1750
|
+
)
|
|
1748
1751
|
clearPendingEditorUpdateDispatchQueue("jsUpdate")
|
|
1749
1752
|
true
|
|
1750
1753
|
} catch (error: Throwable) {
|
|
@@ -209,13 +209,21 @@ class RichTextEditorView @JvmOverloads constructor(
|
|
|
209
209
|
fun setContent(html: String) {
|
|
210
210
|
if (editorId == 0L) return
|
|
211
211
|
editorSetHtml(editorId.toULong(), html)
|
|
212
|
-
editorEditText.applyUpdateJSON(
|
|
212
|
+
editorEditText.applyUpdateJSON(
|
|
213
|
+
editorGetCurrentState(editorId.toULong()),
|
|
214
|
+
notifyListener = false,
|
|
215
|
+
refreshInputConnectionForExternalUpdate = true
|
|
216
|
+
)
|
|
213
217
|
}
|
|
214
218
|
|
|
215
219
|
fun setContent(json: org.json.JSONObject) {
|
|
216
220
|
if (editorId == 0L) return
|
|
217
221
|
editorSetJson(editorId.toULong(), json.toString())
|
|
218
|
-
editorEditText.applyUpdateJSON(
|
|
222
|
+
editorEditText.applyUpdateJSON(
|
|
223
|
+
editorGetCurrentState(editorId.toULong()),
|
|
224
|
+
notifyListener = false,
|
|
225
|
+
refreshInputConnectionForExternalUpdate = true
|
|
226
|
+
)
|
|
219
227
|
}
|
|
220
228
|
|
|
221
229
|
internal fun rebindEditorIfNeeded(notifyListener: Boolean = true) {
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollohg/react-native-prose-editor",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.20",
|
|
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
|