react-native-advanced-text 0.1.10 → 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.
- package/android/src/main/java/com/advancedtext/AdvancedTextView.kt +114 -74
- package/android/src/main/java/com/advancedtext/AdvancedTextViewManager.kt +18 -0
- package/lib/module/AdvancedText.js +4 -2
- package/lib/module/AdvancedText.js.map +1 -1
- package/lib/module/AdvancedTextViewNativeComponent.ts +2 -0
- package/lib/typescript/src/AdvancedText.d.ts +4 -1
- package/lib/typescript/src/AdvancedText.d.ts.map +1 -1
- package/lib/typescript/src/AdvancedTextViewNativeComponent.d.ts +2 -0
- package/lib/typescript/src/AdvancedTextViewNativeComponent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/AdvancedText.tsx +11 -4
- package/src/AdvancedTextViewNativeComponent.ts +2 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// File: AdvancedTextView.kt
|
|
2
1
|
package com.advancedtext
|
|
3
2
|
|
|
4
3
|
import android.content.Context
|
|
@@ -9,9 +8,11 @@ import android.text.TextPaint
|
|
|
9
8
|
import android.text.method.LinkMovementMethod
|
|
10
9
|
import android.text.style.ClickableSpan
|
|
11
10
|
import android.text.style.BackgroundColorSpan
|
|
11
|
+
import android.text.style.ForegroundColorSpan
|
|
12
12
|
import android.util.AttributeSet
|
|
13
13
|
import android.util.Log
|
|
14
|
-
import android.view.
|
|
14
|
+
import android.view.ActionMode
|
|
15
|
+
import android.view.Menu
|
|
15
16
|
import android.view.MenuItem
|
|
16
17
|
import android.view.View
|
|
17
18
|
import android.widget.TextView
|
|
@@ -20,7 +21,7 @@ import com.facebook.react.bridge.ReactContext
|
|
|
20
21
|
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
21
22
|
import android.text.Selection
|
|
22
23
|
|
|
23
|
-
class AdvancedTextView : TextView
|
|
24
|
+
class AdvancedTextView : TextView {
|
|
24
25
|
|
|
25
26
|
private val TAG = "AdvancedTextView"
|
|
26
27
|
|
|
@@ -29,31 +30,78 @@ class AdvancedTextView : TextView, View.OnCreateContextMenuListener {
|
|
|
29
30
|
private var indicatorWordIndex: Int = -1
|
|
30
31
|
private var lastSelectedText: String = ""
|
|
31
32
|
private var isSelectionEnabled: Boolean = true
|
|
33
|
+
private var customActionMode: ActionMode? = null
|
|
32
34
|
|
|
33
35
|
constructor(context: Context?) : super(context) { init() }
|
|
34
36
|
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) { init() }
|
|
35
37
|
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { init() }
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
private fun init() {
|
|
38
40
|
Log.d(TAG, "AdvancedTextView initialized")
|
|
39
41
|
|
|
40
|
-
// Set default text appearance
|
|
41
|
-
setTextColor(Color.BLACK)
|
|
42
|
+
// Set default text appearance - DON'T set black color here
|
|
42
43
|
textSize = 16f
|
|
43
44
|
setPadding(16, 16, 16, 16)
|
|
44
45
|
|
|
45
46
|
movementMethod = LinkMovementMethod.getInstance()
|
|
46
47
|
setTextIsSelectable(true)
|
|
47
|
-
setOnCreateContextMenuListener(this)
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
customSelectionActionModeCallback = object : ActionMode.Callback {
|
|
50
|
+
override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {
|
|
51
|
+
Log.d(TAG, "onCreateActionMode triggered")
|
|
52
|
+
customActionMode = mode
|
|
53
|
+
return true
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
override fun onPrepareActionMode(mode: ActionMode?, menu: Menu?): Boolean {
|
|
57
|
+
Log.d(TAG, "onPrepareActionMode triggered")
|
|
58
|
+
menu?.clear()
|
|
59
|
+
|
|
60
|
+
val selectionStart = selectionStart
|
|
61
|
+
val selectionEnd = selectionEnd
|
|
62
|
+
|
|
63
|
+
if (selectionStart >= 0 && selectionEnd >= 0 && selectionStart != selectionEnd) {
|
|
64
|
+
lastSelectedText = text.subSequence(selectionStart, selectionEnd).toString()
|
|
65
|
+
Log.d(TAG, "User selected text: '$lastSelectedText'")
|
|
66
|
+
Log.d(TAG, "Menu options available: $menuOptions")
|
|
67
|
+
|
|
68
|
+
menuOptions.forEachIndexed { index, option ->
|
|
69
|
+
menu?.add(0, index, index, option)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
sendSelectionEvent(lastSelectedText, "selection")
|
|
73
|
+
return true
|
|
74
|
+
}
|
|
75
|
+
return false
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean {
|
|
79
|
+
item?.let {
|
|
80
|
+
val menuItemText = it.title.toString()
|
|
81
|
+
Log.d(TAG, "Menu item clicked: $menuItemText")
|
|
82
|
+
sendSelectionEvent(lastSelectedText, menuItemText)
|
|
83
|
+
mode?.finish()
|
|
84
|
+
return true
|
|
85
|
+
}
|
|
86
|
+
return false
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
override fun onDestroyActionMode(mode: ActionMode?) {
|
|
90
|
+
Log.d(TAG, "onDestroyActionMode")
|
|
91
|
+
customActionMode = null
|
|
92
|
+
}
|
|
93
|
+
}
|
|
51
94
|
}
|
|
52
95
|
|
|
53
96
|
fun setAdvancedText(text: String) {
|
|
54
97
|
Log.d(TAG, "setAdvancedText: $text (length=${text.length})")
|
|
55
|
-
|
|
98
|
+
|
|
99
|
+
// Set the text first
|
|
100
|
+
super.setText(text, BufferType.SPANNABLE)
|
|
101
|
+
|
|
102
|
+
// Then apply highlights
|
|
56
103
|
updateTextWithHighlights()
|
|
104
|
+
|
|
57
105
|
// Force layout update
|
|
58
106
|
requestLayout()
|
|
59
107
|
invalidate()
|
|
@@ -89,86 +137,72 @@ class AdvancedTextView : TextView, View.OnCreateContextMenuListener {
|
|
|
89
137
|
}
|
|
90
138
|
|
|
91
139
|
val spannableString = SpannableString(textValue)
|
|
92
|
-
|
|
140
|
+
|
|
141
|
+
// Split words while preserving spaces for accurate indexing
|
|
142
|
+
val words = textValue.split("\\s+".toRegex()).filter { it.isNotEmpty() }
|
|
93
143
|
|
|
94
144
|
var currentIndex = 0
|
|
95
145
|
words.forEachIndexed { wordIndex, word ->
|
|
96
146
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
147
|
+
// Find the actual position of the word in the text
|
|
148
|
+
val wordStart = textValue.indexOf(word, currentIndex)
|
|
149
|
+
if (wordStart >= 0) {
|
|
150
|
+
val wordEnd = wordStart + word.length
|
|
151
|
+
|
|
152
|
+
Log.d(TAG, "Processing word '$word' at position $wordStart-$wordEnd, index $wordIndex")
|
|
153
|
+
|
|
154
|
+
// Apply clickable span FIRST (this is important)
|
|
155
|
+
spannableString.setSpan(
|
|
156
|
+
WordClickableSpan(wordIndex, word),
|
|
157
|
+
wordStart,
|
|
158
|
+
wordEnd,
|
|
159
|
+
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
// Then apply background color for highlighted words
|
|
163
|
+
highlightedWords.find { it.index == wordIndex }?.let { highlightedWord ->
|
|
164
|
+
val color = try {
|
|
165
|
+
Color.parseColor(highlightedWord.highlightColor)
|
|
166
|
+
} catch (e: IllegalArgumentException) {
|
|
167
|
+
Log.e(TAG, "Invalid color: ${highlightedWord.highlightColor}, using yellow")
|
|
168
|
+
Color.YELLOW
|
|
117
169
|
}
|
|
170
|
+
Log.d(TAG, "Applying highlight to word '$word' at index $wordIndex with color ${highlightedWord.highlightColor}")
|
|
118
171
|
|
|
119
|
-
|
|
120
|
-
|
|
172
|
+
spannableString.setSpan(
|
|
173
|
+
BackgroundColorSpan(color),
|
|
174
|
+
wordStart,
|
|
175
|
+
wordEnd,
|
|
176
|
+
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
177
|
+
)
|
|
178
|
+
}
|
|
121
179
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
wordEnd,
|
|
126
|
-
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
127
|
-
)
|
|
128
|
-
}
|
|
180
|
+
// Then apply indicator span
|
|
181
|
+
if (wordIndex == indicatorWordIndex) {
|
|
182
|
+
Log.d(TAG, "Applying indicator span to word '$word' at index $wordIndex")
|
|
129
183
|
|
|
130
|
-
// clickable span
|
|
131
184
|
spannableString.setSpan(
|
|
132
|
-
|
|
185
|
+
IndicatorSpan(),
|
|
133
186
|
wordStart,
|
|
134
187
|
wordEnd,
|
|
135
188
|
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
136
189
|
)
|
|
137
|
-
|
|
138
|
-
currentIndex = wordEnd
|
|
139
190
|
}
|
|
191
|
+
|
|
192
|
+
currentIndex = wordEnd
|
|
140
193
|
}
|
|
141
194
|
}
|
|
142
195
|
|
|
196
|
+
// Set the spannable text
|
|
143
197
|
setText(spannableString, BufferType.SPANNABLE)
|
|
144
|
-
Log.d(TAG, "Text updated with spans")
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
override fun onCreateContextMenu(menu: ContextMenu?, v: View?, menuInfo: ContextMenu.ContextMenuInfo?) {
|
|
148
|
-
val selectionStart = selectionStart
|
|
149
|
-
val selectionEnd = selectionEnd
|
|
150
|
-
|
|
151
|
-
Log.d(TAG, "onCreateContextMenu triggered. selectionStart=$selectionStart selectionEnd=$selectionEnd")
|
|
152
198
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
Log.d(TAG, "User selected text: '$lastSelectedText'")
|
|
157
|
-
Log.d(TAG, "Menu options available: $menuOptions")
|
|
199
|
+
// Ensure movement method is still set
|
|
200
|
+
movementMethod = LinkMovementMethod.getInstance()
|
|
158
201
|
|
|
159
|
-
|
|
202
|
+
Log.d(TAG, "Text updated with spans, total spans")
|
|
203
|
+
}
|
|
160
204
|
|
|
161
|
-
menuOptions.forEachIndexed { index, option ->
|
|
162
|
-
menu?.add(0, index, index, option)?.setOnMenuItemClickListener {
|
|
163
|
-
Log.d(TAG, "Menu item clicked: $option")
|
|
164
|
-
onMenuItemClick(it, lastSelectedText)
|
|
165
|
-
true
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
205
|
|
|
169
|
-
sendSelectionEvent(lastSelectedText, "selection")
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
206
|
|
|
173
207
|
private fun onMenuItemClick(item: MenuItem, selectedText: String): Boolean {
|
|
174
208
|
val menuItemText = menuOptions[item.itemId]
|
|
@@ -195,19 +229,25 @@ class AdvancedTextView : TextView, View.OnCreateContextMenuListener {
|
|
|
195
229
|
}
|
|
196
230
|
|
|
197
231
|
private inner class WordClickableSpan(
|
|
198
|
-
|
|
199
|
-
|
|
232
|
+
private val wordIndex: Int,
|
|
233
|
+
private val word: String
|
|
200
234
|
) : ClickableSpan() {
|
|
201
235
|
|
|
202
236
|
override fun onClick(widget: View) {
|
|
203
|
-
Log.d(TAG, "
|
|
204
|
-
|
|
237
|
+
Log.d(TAG, "WordClickableSpan onClick triggered: '$word' (index=$wordIndex)")
|
|
238
|
+
|
|
239
|
+
// Small delay to ensure the click is processed
|
|
240
|
+
widget.post {
|
|
241
|
+
sendWordPressEvent(word, wordIndex)
|
|
242
|
+
}
|
|
205
243
|
}
|
|
206
244
|
|
|
207
245
|
override fun updateDrawState(ds: TextPaint) {
|
|
208
|
-
super
|
|
246
|
+
// Don't call super to avoid default link styling (blue color, underline)
|
|
247
|
+
// Keep the original text appearance
|
|
209
248
|
ds.color = currentTextColor
|
|
210
249
|
ds.isUnderlineText = false
|
|
250
|
+
ds.bgColor = Color.TRANSPARENT
|
|
211
251
|
}
|
|
212
252
|
}
|
|
213
253
|
|
|
@@ -217,7 +257,7 @@ class AdvancedTextView : TextView, View.OnCreateContextMenuListener {
|
|
|
217
257
|
}
|
|
218
258
|
|
|
219
259
|
override fun updateDrawState(ds: TextPaint) {
|
|
220
|
-
|
|
260
|
+
|
|
221
261
|
ds.isFakeBoldText = true
|
|
222
262
|
ds.isUnderlineText = false
|
|
223
263
|
}
|
|
@@ -81,6 +81,23 @@ class AdvancedTextViewManager : SimpleViewManager<AdvancedTextView>(),
|
|
|
81
81
|
view?.setIndicatorWordIndex(index)
|
|
82
82
|
}
|
|
83
83
|
|
|
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
|
+
|
|
84
101
|
// Add this method to register custom events
|
|
85
102
|
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> {
|
|
86
103
|
return mapOf(
|
|
@@ -89,6 +106,7 @@ class AdvancedTextViewManager : SimpleViewManager<AdvancedTextView>(),
|
|
|
89
106
|
)
|
|
90
107
|
}
|
|
91
108
|
|
|
109
|
+
|
|
92
110
|
companion object {
|
|
93
111
|
const val NAME = "AdvancedTextView"
|
|
94
112
|
}
|
|
@@ -9,7 +9,8 @@ export const AdvancedText = ({
|
|
|
9
9
|
onWordPress,
|
|
10
10
|
onSelection,
|
|
11
11
|
indicatorWordIndex,
|
|
12
|
-
|
|
12
|
+
color,
|
|
13
|
+
fontSize
|
|
13
14
|
}) => {
|
|
14
15
|
return /*#__PURE__*/_jsx(AdvancedTextViewNativeComponent, {
|
|
15
16
|
text: text,
|
|
@@ -18,7 +19,8 @@ export const AdvancedText = ({
|
|
|
18
19
|
onWordPress: onWordPress,
|
|
19
20
|
onSelection: onSelection,
|
|
20
21
|
indicatorWordIndex: indicatorWordIndex,
|
|
21
|
-
|
|
22
|
+
color: color,
|
|
23
|
+
fontSize: fontSize
|
|
22
24
|
});
|
|
23
25
|
};
|
|
24
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","color","fontSize"],"sourceRoot":"..\\..\\src","sources":["AdvancedText.tsx"],"mappings":";;AACA,OAAOA,+BAA+B,MAAM,mCAAmC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAuBhF,OAAO,MAAMC,YAAmC,GAAGA,CAAC;EAClDC,IAAI;EACJC,gBAAgB;EAChBC,WAAW;EACXC,WAAW;EACXC,WAAW;EACXC,kBAAkB;EAClBC,KAAK;EACLC;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,KAAK,EAAEA,KAAM;IACbC,QAAQ,EAAEA;EAAS,CACpB,CAAC;AAEN,CAAC","ignoreList":[]}
|
|
@@ -11,6 +11,8 @@ interface HighlightedWord {
|
|
|
11
11
|
|
|
12
12
|
interface NativeProps extends ViewProps {
|
|
13
13
|
text: string;
|
|
14
|
+
color: string;
|
|
15
|
+
fontSize: Int32;
|
|
14
16
|
highlightedWords?: ReadonlyArray<HighlightedWord>;
|
|
15
17
|
menuOptions?: ReadonlyArray<string>;
|
|
16
18
|
onWordPress?: DirectEventHandler<{ word: string }>;
|
|
@@ -6,13 +6,16 @@ interface HighlightedWord {
|
|
|
6
6
|
interface NativeProps extends ViewProps {
|
|
7
7
|
text: string;
|
|
8
8
|
highlightedWords?: ReadonlyArray<HighlightedWord>;
|
|
9
|
+
color: string;
|
|
10
|
+
fontSize: number;
|
|
9
11
|
menuOptions?: ReadonlyArray<string>;
|
|
10
12
|
onWordPress?: (event: NativeSyntheticEvent<{
|
|
11
13
|
word: string;
|
|
14
|
+
index: string;
|
|
12
15
|
}>) => void;
|
|
13
16
|
onSelection?: (event: NativeSyntheticEvent<{
|
|
14
17
|
selectedText: string;
|
|
15
|
-
|
|
18
|
+
event: string;
|
|
16
19
|
}>) => void;
|
|
17
20
|
indicatorWordIndex?: number;
|
|
18
21
|
}
|
|
@@ -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,WAAW,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,
|
|
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,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IAEjB,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 +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,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,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC;IAChB,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"}
|
package/package.json
CHANGED
package/src/AdvancedText.tsx
CHANGED
|
@@ -9,10 +9,15 @@ interface HighlightedWord {
|
|
|
9
9
|
interface NativeProps extends ViewProps {
|
|
10
10
|
text: string;
|
|
11
11
|
highlightedWords?: ReadonlyArray<HighlightedWord>;
|
|
12
|
+
color: string;
|
|
13
|
+
fontSize: number;
|
|
14
|
+
|
|
12
15
|
menuOptions?: ReadonlyArray<string>;
|
|
13
|
-
onWordPress?: (
|
|
16
|
+
onWordPress?: (
|
|
17
|
+
event: NativeSyntheticEvent<{ word: string; index: string }>
|
|
18
|
+
) => void;
|
|
14
19
|
onSelection?: (
|
|
15
|
-
event: NativeSyntheticEvent<{ selectedText: string;
|
|
20
|
+
event: NativeSyntheticEvent<{ selectedText: string; event: string }>
|
|
16
21
|
) => void;
|
|
17
22
|
indicatorWordIndex?: number;
|
|
18
23
|
}
|
|
@@ -24,7 +29,8 @@ export const AdvancedText: React.FC<NativeProps> = ({
|
|
|
24
29
|
onWordPress,
|
|
25
30
|
onSelection,
|
|
26
31
|
indicatorWordIndex,
|
|
27
|
-
|
|
32
|
+
color,
|
|
33
|
+
fontSize,
|
|
28
34
|
}) => {
|
|
29
35
|
return (
|
|
30
36
|
<AdvancedTextViewNativeComponent
|
|
@@ -34,7 +40,8 @@ export const AdvancedText: React.FC<NativeProps> = ({
|
|
|
34
40
|
onWordPress={onWordPress}
|
|
35
41
|
onSelection={onSelection}
|
|
36
42
|
indicatorWordIndex={indicatorWordIndex}
|
|
37
|
-
{
|
|
43
|
+
color={color}
|
|
44
|
+
fontSize={fontSize}
|
|
38
45
|
/>
|
|
39
46
|
);
|
|
40
47
|
};
|
|
@@ -11,6 +11,8 @@ interface HighlightedWord {
|
|
|
11
11
|
|
|
12
12
|
interface NativeProps extends ViewProps {
|
|
13
13
|
text: string;
|
|
14
|
+
color: string;
|
|
15
|
+
fontSize: Int32;
|
|
14
16
|
highlightedWords?: ReadonlyArray<HighlightedWord>;
|
|
15
17
|
menuOptions?: ReadonlyArray<string>;
|
|
16
18
|
onWordPress?: DirectEventHandler<{ word: string }>;
|