react-native-enriched-markdown 0.7.0-nightly-20260701-343fabd47 → 0.7.0

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.
@@ -18,6 +18,7 @@ import com.swmansion.enriched.markdown.utils.text.view.applySelectableState
18
18
  import com.swmansion.enriched.markdown.utils.text.view.cancelJSTouchForCheckboxTap
19
19
  import com.swmansion.enriched.markdown.utils.text.view.cancelJSTouchForLinkTap
20
20
  import com.swmansion.enriched.markdown.utils.text.view.createSelectionActionModeCallback
21
+ import com.swmansion.enriched.markdown.utils.text.view.reallowParentInterceptIfLinkReleased
21
22
  import com.swmansion.enriched.markdown.utils.text.view.setupAsMarkdownTextView
22
23
  import com.swmansion.enriched.markdown.views.BlockSegmentView
23
24
 
@@ -109,8 +110,9 @@ class EnrichedMarkdownInternalText
109
110
  return true
110
111
  }
111
112
  val result = super.onTouchEvent(event)
112
- if (event.action == MotionEvent.ACTION_DOWN) {
113
- cancelJSTouchForLinkTap(event)
113
+ when (event.action) {
114
+ MotionEvent.ACTION_DOWN -> cancelJSTouchForLinkTap(event)
115
+ else -> reallowParentInterceptIfLinkReleased()
114
116
  }
115
117
  return result
116
118
  }
@@ -32,6 +32,7 @@ import com.swmansion.enriched.markdown.utils.text.view.cancelJSTouchForLinkTap
32
32
  import com.swmansion.enriched.markdown.utils.text.view.createSelectionActionModeCallback
33
33
  import com.swmansion.enriched.markdown.utils.text.view.emitLinkLongPressEvent
34
34
  import com.swmansion.enriched.markdown.utils.text.view.emitLinkPressEvent
35
+ import com.swmansion.enriched.markdown.utils.text.view.reallowParentInterceptIfLinkReleased
35
36
  import com.swmansion.enriched.markdown.utils.text.view.setupAsMarkdownTextView
36
37
  import java.util.concurrent.Executors
37
38
 
@@ -356,8 +357,9 @@ class EnrichedMarkdownText
356
357
  return true
357
358
  }
358
359
  val result = super.onTouchEvent(event)
359
- if (event.action == MotionEvent.ACTION_DOWN) {
360
- cancelJSTouchForLinkTap(event)
360
+ when (event.action) {
361
+ MotionEvent.ACTION_DOWN -> cancelJSTouchForLinkTap(event)
362
+ else -> reallowParentInterceptIfLinkReleased()
361
363
  }
362
364
  return result
363
365
  }
@@ -26,18 +26,40 @@ fun View.emitLinkLongPressEvent(url: String) {
26
26
  /**
27
27
  * Cancels the JS touch for an active link tap, preventing parent
28
28
  * Pressable/TouchableOpacity from firing onPress for the same tap.
29
+ *
30
+ * Also requests that parent ViewGroups do not intercept subsequent touch
31
+ * events in this gesture. This is necessary for react-native-gesture-handler's
32
+ * Pressable, which intercepts at the native ViewGroup level and would otherwise
33
+ * steal the gesture before ACTION_UP reaches the TextView.
29
34
  */
30
35
  fun TextView.cancelJSTouchForLinkTap(event: MotionEvent) {
31
36
  val currentMovementMethod = movementMethod
32
37
  if (currentMovementMethod is LinkLongPressMovementMethod && currentMovementMethod.isLinkTouchActive) {
38
+ parent?.requestDisallowInterceptTouchEvent(true)
33
39
  NativeGestureUtil.notifyNativeGestureStarted(this, event)
34
40
  }
35
41
  }
36
42
 
43
+ /**
44
+ * Re-allows parent ViewGroups to intercept touch events once the link
45
+ * touch is no longer active (slop exceeded, gesture ended, or cancelled).
46
+ * This restores normal scrolling behavior for parent ScrollView/RecyclerView.
47
+ *
48
+ * Must be called after [LinkLongPressMovementMethod.onTouchEvent] has
49
+ * processed the event, since that is where [isLinkTouchActive] is updated.
50
+ */
51
+ fun TextView.reallowParentInterceptIfLinkReleased() {
52
+ val currentMovementMethod = movementMethod
53
+ if (currentMovementMethod is LinkLongPressMovementMethod && !currentMovementMethod.isLinkTouchActive) {
54
+ parent?.requestDisallowInterceptTouchEvent(false)
55
+ }
56
+ }
57
+
37
58
  /**
38
59
  * Cancels the JS touch unconditionally, preventing parent
39
60
  * Pressable/TouchableOpacity from firing onPress for the same gesture.
40
61
  */
41
62
  fun View.cancelJSTouchForCheckboxTap(event: MotionEvent) {
63
+ parent?.requestDisallowInterceptTouchEvent(true)
42
64
  NativeGestureUtil.notifyNativeGestureStarted(this, event)
43
65
  }
@@ -15,6 +15,7 @@ import android.text.TextPaint
15
15
  import android.text.style.AlignmentSpan
16
16
  import android.text.style.MetricAffectingSpan
17
17
  import android.view.Gravity
18
+ import android.view.MotionEvent
18
19
  import android.view.View
19
20
  import android.widget.FrameLayout
20
21
  import android.widget.HorizontalScrollView
@@ -30,6 +31,8 @@ import com.swmansion.enriched.markdown.utils.common.serialization.MarkdownASTSer
30
31
  import com.swmansion.enriched.markdown.utils.text.conversion.HTMLGenerator
31
32
  import com.swmansion.enriched.markdown.utils.text.extensions.replaceMathSpansWithPlaceholders
32
33
  import com.swmansion.enriched.markdown.utils.text.view.LinkLongPressMovementMethod
34
+ import com.swmansion.enriched.markdown.utils.text.view.cancelJSTouchForLinkTap
35
+ import com.swmansion.enriched.markdown.utils.text.view.reallowParentInterceptIfLinkReleased
33
36
  import com.swmansion.enriched.markdown.views.ContextMenuPopup
34
37
  import kotlin.math.ceil
35
38
  import kotlin.math.max
@@ -547,6 +550,15 @@ class TableContainerView(
547
550
  textDirection = View.TEXT_DIRECTION_LOCALE
548
551
  importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
549
552
  }
553
+
554
+ override fun onTouchEvent(event: MotionEvent): Boolean {
555
+ val result = super.onTouchEvent(event)
556
+ when (event.action) {
557
+ MotionEvent.ACTION_DOWN -> cancelJSTouchForLinkTap(event)
558
+ else -> reallowParentInterceptIfLinkReleased()
559
+ }
560
+ return result
561
+ }
550
562
  }
551
563
 
552
564
  private data class TableCellData(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-enriched-markdown",
3
- "version": "0.7.0-nightly-20260701-343fabd47",
3
+ "version": "0.7.0",
4
4
  "description": "Markdown Text component for React Native",
5
5
  "main": "./lib/module/index",
6
6
  "module": "./lib/module/index",