react-native-advanced-text 0.1.41 → 0.1.42

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.
@@ -259,8 +259,6 @@ class AdvancedTextView : TextView {
259
259
  private fun drawHighlightedWordBackgrounds(canvas: Canvas) {
260
260
  val currentLayout = layout ?: return
261
261
  val density = resources.displayMetrics.density
262
- val horizontalPadding = 6f * density
263
- val verticalPadding = 2f * density
264
262
  val originalColor = paint.color
265
263
 
266
264
  highlightedWords.forEach { highlightedWord ->
@@ -286,10 +284,10 @@ class AdvancedTextView : TextView {
286
284
  val top = currentLayout.getLineTop(line).toFloat()
287
285
  val bottom = currentLayout.getLineBottom(line).toFloat()
288
286
  val rect = RectF(
289
- totalPaddingLeft + left - horizontalPadding,
290
- totalPaddingTop + top + verticalPadding,
291
- totalPaddingLeft + right + horizontalPadding,
292
- totalPaddingTop + bottom - verticalPadding
287
+ totalPaddingLeft + left,
288
+ totalPaddingTop + top,
289
+ totalPaddingLeft + right,
290
+ totalPaddingTop + bottom
293
291
  )
294
292
  val radius = highlightedWord.borderRadius * density
295
293
  canvas.drawRoundRect(rect, radius, radius, paint)
@@ -301,7 +299,7 @@ class AdvancedTextView : TextView {
301
299
  val wordPos = wordPositions.find { it.index == indicatorWordIndex }
302
300
  if (wordPos != null) {
303
301
  val start = wordPos.start
304
- val end = wordPos.extendedEnd.coerceAtMost(currentText.length)
302
+ val end = wordPos.end.coerceAtMost(currentText.length)
305
303
 
306
304
  if (start < end) {
307
305
  val startLine = currentLayout.getLineForOffset(start)
@@ -320,10 +318,10 @@ class AdvancedTextView : TextView {
320
318
  val top = currentLayout.getLineTop(line).toFloat()
321
319
  val bottom = currentLayout.getLineBottom(line).toFloat()
322
320
  val rect = RectF(
323
- totalPaddingLeft + left - horizontalPadding,
324
- totalPaddingTop + top + verticalPadding,
325
- totalPaddingLeft + right + horizontalPadding,
326
- totalPaddingTop + bottom - verticalPadding
321
+ totalPaddingLeft + left,
322
+ totalPaddingTop + top,
323
+ totalPaddingLeft + right,
324
+ totalPaddingTop + bottom
327
325
  )
328
326
  canvas.drawRoundRect(rect, 0f, 0f, paint)
329
327
  }
@@ -513,7 +513,6 @@ using namespace facebook::react;
513
513
  }];
514
514
  }
515
515
 
516
- // Draw indicator for indicatorWordIndex
517
516
  if (_indicatorWordIndex >= 0 && _indicatorColor) {
518
517
  for (NSDictionary *wordInfo in _wordRanges) {
519
518
  NSNumber *index = wordInfo[@"index"];
@@ -534,7 +533,8 @@ using namespace facebook::react;
534
533
  withinSelectedGlyphRange:NSMakeRange(NSNotFound, 0)
535
534
  inTextContainer:textContainer
536
535
  usingBlock:^(CGRect enclosingRect, BOOL *stop) {
537
- CGRect adjustedRect = CGRectInset(enclosingRect, -6.0, -2.0);
536
+ // Changed lines here to remove padding and align exactly to glyph rect
537
+ CGRect adjustedRect = enclosingRect;
538
538
  adjustedRect.origin.x += textView.textContainerInset.left;
539
539
  adjustedRect.origin.y += textView.textContainerInset.top;
540
540
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-advanced-text",
3
- "version": "0.1.41",
3
+ "version": "0.1.42",
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",