react-native-advanced-text 0.1.14 → 0.1.15

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,9 +8,9 @@ import android.text.TextPaint
8
8
  import android.text.method.LinkMovementMethod
9
9
  import android.text.style.ClickableSpan
10
10
  import android.text.style.BackgroundColorSpan
11
- import android.text.style.ForegroundColorSpan
12
11
  import android.util.AttributeSet
13
12
  import android.util.Log
13
+ import android.util.TypedValue
14
14
  import android.view.ActionMode
15
15
  import android.view.Menu
16
16
  import android.view.MenuItem
@@ -32,16 +32,20 @@ class AdvancedTextView : TextView {
32
32
  private var isSelectionEnabled: Boolean = true
33
33
  private var customActionMode: ActionMode? = null
34
34
 
35
+ // Cache for base text color to avoid parsing multiple times
36
+ private var baseTextColor: Int = Color.BLACK
37
+
35
38
  constructor(context: Context?) : super(context) { init() }
36
39
  constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) { init() }
37
40
  constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { init() }
38
41
 
39
- private fun init() {
42
+ private fun init() {
40
43
  Log.d(TAG, "AdvancedTextView initialized")
41
44
 
42
- // Set default text appearance - DON'T set black color here
45
+ // Set default text appearance
43
46
  textSize = 16f
44
47
  setPadding(16, 16, 16, 16)
48
+ baseTextColor = currentTextColor
45
49
 
46
50
  movementMethod = LinkMovementMethod.getInstance()
47
51
  setTextIsSelectable(true)
@@ -63,7 +67,6 @@ class AdvancedTextView : TextView {
63
67
  if (selectionStart >= 0 && selectionEnd >= 0 && selectionStart != selectionEnd) {
64
68
  lastSelectedText = text.subSequence(selectionStart, selectionEnd).toString()
65
69
  Log.d(TAG, "User selected text: '$lastSelectedText'")
66
- Log.d(TAG, "Menu options available: $menuOptions")
67
70
 
68
71
  menuOptions.forEachIndexed { index, option ->
69
72
  menu?.add(0, index, index, option)
@@ -95,25 +98,44 @@ class AdvancedTextView : TextView {
95
98
 
96
99
  fun setAdvancedText(text: String) {
97
100
  Log.d(TAG, "setAdvancedText: $text (length=${text.length})")
98
-
99
- // Set the text first
100
101
  super.setText(text, BufferType.SPANNABLE)
101
-
102
- // Then apply highlights
103
102
  updateTextWithHighlights()
104
-
105
- // Force layout update
106
103
  requestLayout()
107
104
  invalidate()
108
105
  }
109
106
 
107
+ // Performance-optimized: Set base font size at view level
108
+ fun setFontSize(size: Float) {
109
+ Log.d(TAG, "setFontSize: $size")
110
+ // Use SP units for accessibility
111
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, size)
112
+ }
113
+
114
+ // Performance-optimized: Set base color at view level
115
+ fun setTextColorProp(colorString: String?) {
116
+ try {
117
+ val color = if (colorString != null) {
118
+ Color.parseColor(colorString)
119
+ } else {
120
+ Color.BLACK
121
+ }
122
+ Log.d(TAG, "setTextColorProp: $colorString -> $color")
123
+ baseTextColor = color
124
+ setTextColor(color)
125
+ } catch (e: IllegalArgumentException) {
126
+ Log.e(TAG, "Invalid color: $colorString, using black", e)
127
+ baseTextColor = Color.BLACK
128
+ setTextColor(Color.BLACK)
129
+ }
130
+ }
131
+
110
132
  fun setMenuOptions(menuOptions: List<String>) {
111
- Log.d(TAG, "setMenuOptions received from RN: $menuOptions")
133
+ Log.d(TAG, "setMenuOptions received: $menuOptions")
112
134
  this.menuOptions = menuOptions
113
135
  }
114
136
 
115
137
  fun setHighlightedWords(highlightedWords: List<HighlightedWord>) {
116
- Log.d(TAG, "setHighlightedWords received from RN: $highlightedWords")
138
+ Log.d(TAG, "setHighlightedWords received: $highlightedWords")
117
139
  this.highlightedWords = highlightedWords
118
140
  updateTextWithHighlights()
119
141
  }
@@ -127,9 +149,6 @@ class AdvancedTextView : TextView {
127
149
  private fun updateTextWithHighlights() {
128
150
  val textValue = this.text?.toString() ?: ""
129
151
  Log.d(TAG, "updateTextWithHighlights called")
130
- Log.d(TAG, "Current text: $textValue")
131
- Log.d(TAG, "Highlighted words: $highlightedWords")
132
- Log.d(TAG, "Indicator index: $indicatorWordIndex")
133
152
 
134
153
  if (textValue.isEmpty()) {
135
154
  Log.d(TAG, "No text available, skipping")
@@ -137,21 +156,15 @@ class AdvancedTextView : TextView {
137
156
  }
138
157
 
139
158
  val spannableString = SpannableString(textValue)
140
-
141
- // Split words while preserving spaces for accurate indexing
142
159
  val words = textValue.split("\\s+".toRegex()).filter { it.isNotEmpty() }
143
160
 
144
161
  var currentIndex = 0
145
162
  words.forEachIndexed { wordIndex, word ->
146
-
147
- // Find the actual position of the word in the text
148
163
  val wordStart = textValue.indexOf(word, currentIndex)
149
164
  if (wordStart >= 0) {
150
165
  val wordEnd = wordStart + word.length
151
166
 
152
- Log.d(TAG, "Processing word '$word' at position $wordStart-$wordEnd, index $wordIndex")
153
-
154
- // Apply clickable span FIRST (this is important)
167
+ // Apply clickable span
155
168
  spannableString.setSpan(
156
169
  WordClickableSpan(wordIndex, word),
157
170
  wordStart,
@@ -159,15 +172,14 @@ class AdvancedTextView : TextView {
159
172
  Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
160
173
  )
161
174
 
162
- // Then apply background color for highlighted words
175
+ // Apply background highlight
163
176
  highlightedWords.find { it.index == wordIndex }?.let { highlightedWord ->
164
177
  val color = try {
165
178
  Color.parseColor(highlightedWord.highlightColor)
166
179
  } catch (e: IllegalArgumentException) {
167
- Log.e(TAG, "Invalid color: ${highlightedWord.highlightColor}, using yellow")
180
+ Log.e(TAG, "Invalid color: ${highlightedWord.highlightColor}")
168
181
  Color.YELLOW
169
182
  }
170
- Log.d(TAG, "Applying highlight to word '$word' at index $wordIndex with color ${highlightedWord.highlightColor}")
171
183
 
172
184
  spannableString.setSpan(
173
185
  BackgroundColorSpan(color),
@@ -177,10 +189,8 @@ class AdvancedTextView : TextView {
177
189
  )
178
190
  }
179
191
 
180
- // Then apply indicator span
192
+ // Apply indicator span
181
193
  if (wordIndex == indicatorWordIndex) {
182
- Log.d(TAG, "Applying indicator span to word '$word' at index $wordIndex")
183
-
184
194
  spannableString.setSpan(
185
195
  IndicatorSpan(),
186
196
  wordStart,
@@ -193,22 +203,8 @@ class AdvancedTextView : TextView {
193
203
  }
194
204
  }
195
205
 
196
- // Set the spannable text
197
206
  setText(spannableString, BufferType.SPANNABLE)
198
-
199
- // Ensure movement method is still set
200
207
  movementMethod = LinkMovementMethod.getInstance()
201
-
202
- Log.d(TAG, "Text updated with spans, total spans")
203
- }
204
-
205
-
206
-
207
- private fun onMenuItemClick(item: MenuItem, selectedText: String): Boolean {
208
- val menuItemText = menuOptions[item.itemId]
209
- Log.d(TAG, "onMenuItemClick: menuOption='$menuItemText', selectedText='$selectedText'")
210
- sendSelectionEvent(selectedText, menuItemText)
211
- return true
212
208
  }
213
209
 
214
210
  private fun sendSelectionEvent(selectedText: String, eventType: String) {
@@ -229,23 +225,20 @@ class AdvancedTextView : TextView {
229
225
  }
230
226
 
231
227
  private inner class WordClickableSpan(
232
- private val wordIndex: Int,
233
- private val word: String
228
+ private val wordIndex: Int,
229
+ private val word: String
234
230
  ) : ClickableSpan() {
235
231
 
236
232
  override fun onClick(widget: View) {
237
- Log.d(TAG, "WordClickableSpan onClick triggered: '$word' (index=$wordIndex)")
238
-
239
- // Small delay to ensure the click is processed
233
+ Log.d(TAG, "WordClickableSpan onClick: '$word' (index=$wordIndex)")
240
234
  widget.post {
241
235
  sendWordPressEvent(word, wordIndex)
242
236
  }
243
237
  }
244
238
 
245
239
  override fun updateDrawState(ds: TextPaint) {
246
- // Don't call super to avoid default link styling (blue color, underline)
247
- // Keep the original text appearance
248
-
240
+ // Preserve the base text color instead of forcing a color
241
+ ds.color = baseTextColor
249
242
  ds.isUnderlineText = false
250
243
  ds.bgColor = Color.TRANSPARENT
251
244
  }
@@ -253,11 +246,11 @@ class AdvancedTextView : TextView {
253
246
 
254
247
  private inner class IndicatorSpan : ClickableSpan() {
255
248
  override fun onClick(widget: View) {
256
- Log.d(TAG, "IndicatorSpan clicked (shouldn't trigger action)")
249
+ Log.d(TAG, "IndicatorSpan clicked")
257
250
  }
258
251
 
259
252
  override fun updateDrawState(ds: TextPaint) {
260
-
253
+ ds.color = baseTextColor
261
254
  ds.isFakeBoldText = true
262
255
  ds.isUnderlineText = false
263
256
  }
@@ -293,7 +286,7 @@ class AdvancedTextView : TextView {
293
286
 
294
287
  override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
295
288
  super.onLayout(changed, left, top, right, bottom)
296
- Log.d(TAG, "onLayout: changed=$changed, bounds=[$left,$top,$right,$bottom]")
289
+ Log.d(TAG, "onLayout: changed=$changed")
297
290
  }
298
291
  }
299
292
 
@@ -1,5 +1,3 @@
1
- // File: AdvancedTextViewManager.kt
2
- // This should be the ONLY content in this file
3
1
  package com.advancedtext
4
2
 
5
3
  import android.view.ViewGroup
@@ -31,7 +29,6 @@ class AdvancedTextViewManager : SimpleViewManager<AdvancedTextView>(),
31
29
 
32
30
  public override fun createViewInstance(context: ThemedReactContext): AdvancedTextView {
33
31
  val view = AdvancedTextView(context)
34
- // Set default layout params to ensure the view is visible
35
32
  view.layoutParams = ViewGroup.LayoutParams(
36
33
  ViewGroup.LayoutParams.MATCH_PARENT,
37
34
  ViewGroup.LayoutParams.WRAP_CONTENT
@@ -44,6 +41,16 @@ class AdvancedTextViewManager : SimpleViewManager<AdvancedTextView>(),
44
41
  view?.setAdvancedText(text ?: "")
45
42
  }
46
43
 
44
+ @ReactProp(name = "fontSize", defaultFloat = 16f)
45
+ override fun setFontSize(view: AdvancedTextView?, fontSize: Float) {
46
+ view?.setFontSize(fontSize)
47
+ }
48
+
49
+ @ReactProp(name = "color")
50
+ override fun setColor(view: AdvancedTextView?, color: String?) {
51
+ view?.setTextColorProp(color)
52
+ }
53
+
47
54
  @ReactProp(name = "highlightedWords")
48
55
  override fun setHighlightedWords(view: AdvancedTextView?, highlightedWords: ReadableArray?) {
49
56
  val words = mutableListOf<HighlightedWord>()
@@ -81,7 +88,6 @@ class AdvancedTextViewManager : SimpleViewManager<AdvancedTextView>(),
81
88
  view?.setIndicatorWordIndex(index)
82
89
  }
83
90
 
84
- // Add this method to register custom events
85
91
  override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> {
86
92
  return mapOf(
87
93
  "onWordPress" to mapOf("registrationName" to "onWordPress"),
@@ -8,7 +8,9 @@ export const AdvancedText = ({
8
8
  menuOptions,
9
9
  onWordPress,
10
10
  onSelection,
11
- indicatorWordIndex
11
+ indicatorWordIndex,
12
+ fontSize,
13
+ color
12
14
  }) => {
13
15
  return /*#__PURE__*/_jsx(AdvancedTextViewNativeComponent, {
14
16
  text: text,
@@ -16,7 +18,9 @@ export const AdvancedText = ({
16
18
  menuOptions: menuOptions,
17
19
  onWordPress: onWordPress,
18
20
  onSelection: onSelection,
19
- indicatorWordIndex: indicatorWordIndex
21
+ indicatorWordIndex: indicatorWordIndex,
22
+ fontSize: fontSize,
23
+ color: color
20
24
  });
21
25
  };
22
26
  //# sourceMappingURL=AdvancedText.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["AdvancedTextViewNativeComponent","jsx","_jsx","AdvancedText","text","highlightedWords","menuOptions","onWordPress","onSelection","indicatorWordIndex"],"sourceRoot":"..\\..\\src","sources":["AdvancedText.tsx"],"mappings":";;AACA,OAAOA,+BAA+B,MAAM,mCAAmC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAqBhF,OAAO,MAAMC,YAAmC,GAAGA,CAAC;EAClDC,IAAI;EACJC,gBAAgB;EAChBC,WAAW;EACXC,WAAW;EACXC,WAAW;EACXC;AACF,CAAC,KAAK;EACJ,oBACEP,IAAA,CAACF,+BAA+B;IAC9BI,IAAI,EAAEA,IAAK;IACXC,gBAAgB,EAAEA,gBAAiB;IACnCC,WAAW,EAAEA,WAAY;IACzBC,WAAW,EAAEA,WAAY;IACzBC,WAAW,EAAEA,WAAY;IACzBC,kBAAkB,EAAEA;EAAmB,CACxC,CAAC;AAEN,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["AdvancedTextViewNativeComponent","jsx","_jsx","AdvancedText","text","highlightedWords","menuOptions","onWordPress","onSelection","indicatorWordIndex","fontSize","color"],"sourceRoot":"..\\..\\src","sources":["AdvancedText.tsx"],"mappings":";;AACA,OAAOA,+BAA+B,MAAM,mCAAmC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAsBhF,OAAO,MAAMC,YAAmC,GAAGA,CAAC;EAClDC,IAAI;EACJC,gBAAgB;EAChBC,WAAW;EACXC,WAAW;EACXC,WAAW;EACXC,kBAAkB;EAClBC,QAAQ;EACRC;AACF,CAAC,KAAK;EACJ,oBACET,IAAA,CAACF,+BAA+B;IAC9BI,IAAI,EAAEA,IAAK;IACXC,gBAAgB,EAAEA,gBAAiB;IACnCC,WAAW,EAAEA,WAAY;IACzBC,WAAW,EAAEA,WAAY;IACzBC,WAAW,EAAEA,WAAY;IACzBC,kBAAkB,EAAEA,kBAAmB;IACvCC,QAAQ,EAAEA,QAAS;IACnBC,KAAK,EAAEA;EAAM,CACd,CAAC;AAEN,CAAC","ignoreList":[]}
@@ -2,7 +2,7 @@ import { codegenNativeComponent } from 'react-native';
2
2
  import type { ViewProps } from 'react-native';
3
3
  // @ts-ignore
4
4
  // eslint-disable-next-line prettier/prettier
5
- import type { DirectEventHandler, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
5
+ import type { DirectEventHandler, Int32, Float } from 'react-native/Libraries/Types/CodegenTypes';
6
6
 
7
7
  interface HighlightedWord {
8
8
  index: Int32;
@@ -11,10 +11,12 @@ interface HighlightedWord {
11
11
 
12
12
  interface NativeProps extends ViewProps {
13
13
  text: string;
14
+ fontSize?: Float;
15
+ color?: string;
14
16
  highlightedWords?: ReadonlyArray<HighlightedWord>;
15
17
  menuOptions?: ReadonlyArray<string>;
16
- onWordPress?: DirectEventHandler<{ word: string }>;
17
- onSelection?: DirectEventHandler<{ selectedText: string; eventType: string }>;
18
+ onWordPress?: DirectEventHandler<{ word: string; index: Int32 }>;
19
+ onSelection?: DirectEventHandler<{ selectedText: string; event: string }>;
18
20
  indicatorWordIndex?: Int32;
19
21
  }
20
22
 
@@ -6,6 +6,8 @@ interface HighlightedWord {
6
6
  interface NativeProps extends ViewProps {
7
7
  text: string;
8
8
  highlightedWords?: ReadonlyArray<HighlightedWord>;
9
+ fontSize?: number;
10
+ color?: string;
9
11
  menuOptions?: ReadonlyArray<string>;
10
12
  onWordPress?: (event: NativeSyntheticEvent<{
11
13
  word: string;
@@ -1 +1 @@
1
- {"version":3,"file":"AdvancedText.d.ts","sourceRoot":"","sources":["../../../src/AdvancedText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGpE,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,WAAY,SAAQ,SAAS;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAElD,WAAW,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,CACZ,KAAK,EAAE,oBAAoB,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,KACzD,IAAI,CAAC;IACV,WAAW,CAAC,EAAE,CACZ,KAAK,EAAE,oBAAoB,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,KACjE,IAAI,CAAC;IACV,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAkB9C,CAAC"}
1
+ {"version":3,"file":"AdvancedText.d.ts","sourceRoot":"","sources":["../../../src/AdvancedText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGpE,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,WAAY,SAAQ,SAAS;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,CACZ,KAAK,EAAE,oBAAoB,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,KACzD,IAAI,CAAC;IACV,WAAW,CAAC,EAAE,CACZ,KAAK,EAAE,oBAAoB,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,KACjE,IAAI,CAAC;IACV,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAsB9C,CAAC"}
@@ -1,19 +1,22 @@
1
1
  import type { ViewProps } from 'react-native';
2
- import type { DirectEventHandler, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
2
+ import type { DirectEventHandler, Int32, Float } from 'react-native/Libraries/Types/CodegenTypes';
3
3
  interface HighlightedWord {
4
4
  index: Int32;
5
5
  highlightColor: string;
6
6
  }
7
7
  interface NativeProps extends ViewProps {
8
8
  text: string;
9
+ fontSize?: Float;
10
+ color?: string;
9
11
  highlightedWords?: ReadonlyArray<HighlightedWord>;
10
12
  menuOptions?: ReadonlyArray<string>;
11
13
  onWordPress?: DirectEventHandler<{
12
14
  word: string;
15
+ index: Int32;
13
16
  }>;
14
17
  onSelection?: DirectEventHandler<{
15
18
  selectedText: string;
16
- eventType: string;
19
+ event: string;
17
20
  }>;
18
21
  indicatorWordIndex?: Int32;
19
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AdvancedTextViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/AdvancedTextViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AAE3F,UAAU,eAAe;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,WAAY,SAAQ,SAAS;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAClD,WAAW,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,kBAAkB,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,WAAW,CAAC,EAAE,kBAAkB,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9E,kBAAkB,CAAC,EAAE,KAAK,CAAC;CAC5B;;AAED,wBAAuE"}
1
+ {"version":3,"file":"AdvancedTextViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/AdvancedTextViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AAElG,UAAU,eAAe;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,WAAY,SAAQ,SAAS;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAClD,WAAW,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,kBAAkB,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;IACjE,WAAW,CAAC,EAAE,kBAAkB,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1E,kBAAkB,CAAC,EAAE,KAAK,CAAC;CAC5B;;AAED,wBAAuE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-advanced-text",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": " Advanced text component for React Native with custom select options.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -9,7 +9,8 @@ interface HighlightedWord {
9
9
  interface NativeProps extends ViewProps {
10
10
  text: string;
11
11
  highlightedWords?: ReadonlyArray<HighlightedWord>;
12
-
12
+ fontSize?: number;
13
+ color?: string;
13
14
  menuOptions?: ReadonlyArray<string>;
14
15
  onWordPress?: (
15
16
  event: NativeSyntheticEvent<{ word: string; index: string }>
@@ -27,6 +28,8 @@ export const AdvancedText: React.FC<NativeProps> = ({
27
28
  onWordPress,
28
29
  onSelection,
29
30
  indicatorWordIndex,
31
+ fontSize,
32
+ color,
30
33
  }) => {
31
34
  return (
32
35
  <AdvancedTextViewNativeComponent
@@ -36,6 +39,8 @@ export const AdvancedText: React.FC<NativeProps> = ({
36
39
  onWordPress={onWordPress}
37
40
  onSelection={onSelection}
38
41
  indicatorWordIndex={indicatorWordIndex}
42
+ fontSize={fontSize}
43
+ color={color}
39
44
  />
40
45
  );
41
46
  };
@@ -2,7 +2,7 @@ import { codegenNativeComponent } from 'react-native';
2
2
  import type { ViewProps } from 'react-native';
3
3
  // @ts-ignore
4
4
  // eslint-disable-next-line prettier/prettier
5
- import type { DirectEventHandler, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
5
+ import type { DirectEventHandler, Int32, Float } from 'react-native/Libraries/Types/CodegenTypes';
6
6
 
7
7
  interface HighlightedWord {
8
8
  index: Int32;
@@ -11,10 +11,12 @@ interface HighlightedWord {
11
11
 
12
12
  interface NativeProps extends ViewProps {
13
13
  text: string;
14
+ fontSize?: Float;
15
+ color?: string;
14
16
  highlightedWords?: ReadonlyArray<HighlightedWord>;
15
17
  menuOptions?: ReadonlyArray<string>;
16
- onWordPress?: DirectEventHandler<{ word: string }>;
17
- onSelection?: DirectEventHandler<{ selectedText: string; eventType: string }>;
18
+ onWordPress?: DirectEventHandler<{ word: string; index: Int32 }>;
19
+ onSelection?: DirectEventHandler<{ selectedText: string; event: string }>;
18
20
  indicatorWordIndex?: Int32;
19
21
  }
20
22