react-native-typerich 0.1.12 → 0.1.13

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.
@@ -45,7 +45,6 @@ class TypeRichTextInputView : AppCompatEditText {
45
45
  lateinit var layoutManager: TypeRichTextInputViewLayoutManager
46
46
 
47
47
  var isDuringTransaction: Boolean = false
48
- var isRemovingMany: Boolean = false
49
48
  var scrollEnabled: Boolean = true
50
49
 
51
50
  var experimentalSynchronousEvents: Boolean = false
@@ -60,10 +59,11 @@ class TypeRichTextInputView : AppCompatEditText {
60
59
  private var fontWeight: Int = ReactConstants.UNSET
61
60
  private var defaultValue: CharSequence? = null
62
61
  private var defaultValueDirty: Boolean = false
63
- private var keyboardAppearance: String = "default"
62
+ // private var keyboardAppearance: String = "default" // used in ios only
64
63
  private var inputMethodManager: InputMethodManager? = null
65
64
  private var lineHeightPx: Int? = null
66
65
  private var isSettingTextFromJS = false
66
+ private var isInitialized = false
67
67
 
68
68
 
69
69
  constructor(context: Context) : super(context) {
@@ -106,8 +106,14 @@ class TypeRichTextInputView : AppCompatEditText {
106
106
  override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { if (isSettingTextFromJS) return}
107
107
 
108
108
  override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
109
- if (!isDuringTransaction) {
110
- if (isSettingTextFromJS) return
109
+ if (isSettingTextFromJS) return
110
+
111
+ if (!isInitialized) {
112
+ layoutManager.invalidateLayout()
113
+ return
114
+ }
115
+
116
+ if (!isDuringTransaction ) {
111
117
 
112
118
  val reactContext = context as ReactContext
113
119
  val surfaceId = UIManagerHelper.getSurfaceId(reactContext)
@@ -295,6 +301,7 @@ class TypeRichTextInputView : AppCompatEditText {
295
301
 
296
302
  override fun onSelectionChanged(selStart: Int, selEnd: Int) {
297
303
  super.onSelectionChanged(selStart, selEnd)
304
+ if (isDuringTransaction) return
298
305
 
299
306
  val reactContext = context as? ReactContext ?: return
300
307
  val dispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, id)
@@ -546,6 +553,8 @@ class TypeRichTextInputView : AppCompatEditText {
546
553
  updateTypeface()
547
554
  updateDefaultValue()
548
555
  applyLineHeight()
556
+
557
+ isInitialized = true
549
558
  }
550
559
 
551
560
  fun setDefaultValue(value: CharSequence?) {
@@ -556,7 +565,7 @@ class TypeRichTextInputView : AppCompatEditText {
556
565
  private fun updateDefaultValue() {
557
566
  if (!defaultValueDirty) return
558
567
  defaultValueDirty = false
559
- setText(defaultValue?.toString() ?: "")
568
+ setValue(defaultValue)
560
569
  }
561
570
 
562
571
  private fun updateTypeface() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-typerich",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Textinput replacement",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",