react-native-advanced-text 0.1.13 → 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.
- package/android/src/main/java/com/advancedtext/AdvancedTextView.kt +46 -53
- package/android/src/main/java/com/advancedtext/AdvancedTextViewManager.kt +10 -22
- package/lib/module/AdvancedText.js +4 -4
- package/lib/module/AdvancedText.js.map +1 -1
- package/lib/module/AdvancedTextViewNativeComponent.ts +5 -5
- package/lib/typescript/src/AdvancedText.d.ts +2 -2
- package/lib/typescript/src/AdvancedText.d.ts.map +1 -1
- package/lib/typescript/src/AdvancedTextViewNativeComponent.d.ts +5 -4
- package/lib/typescript/src/AdvancedTextViewNativeComponent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/AdvancedText.tsx +4 -5
- package/src/AdvancedTextViewNativeComponent.ts +5 -5
|
@@ -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
|
-
|
|
42
|
+
private fun init() {
|
|
40
43
|
Log.d(TAG, "AdvancedTextView initialized")
|
|
41
44
|
|
|
42
|
-
// Set default text appearance
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
//
|
|
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}
|
|
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
|
-
//
|
|
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
|
-
|
|
233
|
-
|
|
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
|
|
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
|
-
//
|
|
247
|
-
|
|
248
|
-
ds.color = currentTextColor
|
|
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
|
|
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
|
|
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,24 +88,6 @@ class AdvancedTextViewManager : SimpleViewManager<AdvancedTextView>(),
|
|
|
81
88
|
view?.setIndicatorWordIndex(index)
|
|
82
89
|
}
|
|
83
90
|
|
|
84
|
-
@ReactProp(name = "color")
|
|
85
|
-
fun setColor(view: AdvancedTextView?, color: String?) {
|
|
86
|
-
color?.let {
|
|
87
|
-
try {
|
|
88
|
-
view?.setTextColor(android.graphics.Color.parseColor(it))
|
|
89
|
-
} catch (e: IllegalArgumentException) {
|
|
90
|
-
// fallback to default color if parsing fails
|
|
91
|
-
view?.setTextColor(android.graphics.Color.BLACK)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@ReactProp(name = "fontSize")
|
|
97
|
-
fun setFontSize(view: AdvancedTextView?, fontSize: Int) {
|
|
98
|
-
view?.setTextSize(fontSize.toFloat())
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Add this method to register custom events
|
|
102
91
|
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> {
|
|
103
92
|
return mapOf(
|
|
104
93
|
"onWordPress" to mapOf("registrationName" to "onWordPress"),
|
|
@@ -106,7 +95,6 @@ class AdvancedTextViewManager : SimpleViewManager<AdvancedTextView>(),
|
|
|
106
95
|
)
|
|
107
96
|
}
|
|
108
97
|
|
|
109
|
-
|
|
110
98
|
companion object {
|
|
111
99
|
const val NAME = "AdvancedTextView"
|
|
112
100
|
}
|
|
@@ -9,8 +9,8 @@ export const AdvancedText = ({
|
|
|
9
9
|
onWordPress,
|
|
10
10
|
onSelection,
|
|
11
11
|
indicatorWordIndex,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
fontSize,
|
|
13
|
+
color
|
|
14
14
|
}) => {
|
|
15
15
|
return /*#__PURE__*/_jsx(AdvancedTextViewNativeComponent, {
|
|
16
16
|
text: text,
|
|
@@ -19,8 +19,8 @@ export const AdvancedText = ({
|
|
|
19
19
|
onWordPress: onWordPress,
|
|
20
20
|
onSelection: onSelection,
|
|
21
21
|
indicatorWordIndex: indicatorWordIndex,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
fontSize: fontSize,
|
|
23
|
+
color: color
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
//# sourceMappingURL=AdvancedText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AdvancedTextViewNativeComponent","jsx","_jsx","AdvancedText","text","highlightedWords","menuOptions","onWordPress","onSelection","indicatorWordIndex","
|
|
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,12 +11,12 @@ interface HighlightedWord {
|
|
|
11
11
|
|
|
12
12
|
interface NativeProps extends ViewProps {
|
|
13
13
|
text: string;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
fontSize?: Float;
|
|
15
|
+
color?: string;
|
|
16
16
|
highlightedWords?: ReadonlyArray<HighlightedWord>;
|
|
17
17
|
menuOptions?: ReadonlyArray<string>;
|
|
18
|
-
onWordPress?: DirectEventHandler<{ word: string }>;
|
|
19
|
-
onSelection?: DirectEventHandler<{ selectedText: string;
|
|
18
|
+
onWordPress?: DirectEventHandler<{ word: string; index: Int32 }>;
|
|
19
|
+
onSelection?: DirectEventHandler<{ selectedText: string; event: string }>;
|
|
20
20
|
indicatorWordIndex?: Int32;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -6,8 +6,8 @@ interface HighlightedWord {
|
|
|
6
6
|
interface NativeProps extends ViewProps {
|
|
7
7
|
text: string;
|
|
8
8
|
highlightedWords?: ReadonlyArray<HighlightedWord>;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
fontSize?: number;
|
|
10
|
+
color?: string;
|
|
11
11
|
menuOptions?: ReadonlyArray<string>;
|
|
12
12
|
onWordPress?: (event: NativeSyntheticEvent<{
|
|
13
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;IAClD,
|
|
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,21 +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
|
-
|
|
10
|
-
|
|
9
|
+
fontSize?: Float;
|
|
10
|
+
color?: string;
|
|
11
11
|
highlightedWords?: ReadonlyArray<HighlightedWord>;
|
|
12
12
|
menuOptions?: ReadonlyArray<string>;
|
|
13
13
|
onWordPress?: DirectEventHandler<{
|
|
14
14
|
word: string;
|
|
15
|
+
index: Int32;
|
|
15
16
|
}>;
|
|
16
17
|
onSelection?: DirectEventHandler<{
|
|
17
18
|
selectedText: string;
|
|
18
|
-
|
|
19
|
+
event: string;
|
|
19
20
|
}>;
|
|
20
21
|
indicatorWordIndex?: Int32;
|
|
21
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;
|
|
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
package/src/AdvancedText.tsx
CHANGED
|
@@ -9,9 +9,8 @@ interface HighlightedWord {
|
|
|
9
9
|
interface NativeProps extends ViewProps {
|
|
10
10
|
text: string;
|
|
11
11
|
highlightedWords?: ReadonlyArray<HighlightedWord>;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
fontSize?: number;
|
|
13
|
+
color?: string;
|
|
15
14
|
menuOptions?: ReadonlyArray<string>;
|
|
16
15
|
onWordPress?: (
|
|
17
16
|
event: NativeSyntheticEvent<{ word: string; index: string }>
|
|
@@ -29,8 +28,8 @@ export const AdvancedText: React.FC<NativeProps> = ({
|
|
|
29
28
|
onWordPress,
|
|
30
29
|
onSelection,
|
|
31
30
|
indicatorWordIndex,
|
|
32
|
-
color,
|
|
33
31
|
fontSize,
|
|
32
|
+
color,
|
|
34
33
|
}) => {
|
|
35
34
|
return (
|
|
36
35
|
<AdvancedTextViewNativeComponent
|
|
@@ -40,8 +39,8 @@ export const AdvancedText: React.FC<NativeProps> = ({
|
|
|
40
39
|
onWordPress={onWordPress}
|
|
41
40
|
onSelection={onSelection}
|
|
42
41
|
indicatorWordIndex={indicatorWordIndex}
|
|
43
|
-
color={color}
|
|
44
42
|
fontSize={fontSize}
|
|
43
|
+
color={color}
|
|
45
44
|
/>
|
|
46
45
|
);
|
|
47
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,12 +11,12 @@ interface HighlightedWord {
|
|
|
11
11
|
|
|
12
12
|
interface NativeProps extends ViewProps {
|
|
13
13
|
text: string;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
fontSize?: Float;
|
|
15
|
+
color?: string;
|
|
16
16
|
highlightedWords?: ReadonlyArray<HighlightedWord>;
|
|
17
17
|
menuOptions?: ReadonlyArray<string>;
|
|
18
|
-
onWordPress?: DirectEventHandler<{ word: string }>;
|
|
19
|
-
onSelection?: DirectEventHandler<{ selectedText: string;
|
|
18
|
+
onWordPress?: DirectEventHandler<{ word: string; index: Int32 }>;
|
|
19
|
+
onSelection?: DirectEventHandler<{ selectedText: string; event: string }>;
|
|
20
20
|
indicatorWordIndex?: Int32;
|
|
21
21
|
}
|
|
22
22
|
|