Skip to content

Commit e0a9135

Browse files
authored
fix: android link detection (#40)
* fix: android link detection * chore: simplify
1 parent 11b8c1d commit e0a9135

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

android/src/main/java/com/swmansion/reactnativerichtexteditor/utils/EditorSelection.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ class EditorSelection(private val editorView: ReactNativeRichTextEditorView) {
158158
val (start, end) = getInlineSelection()
159159
val spannable = editorView.text as Spannable
160160
val spans = spannable.getSpans(start, end, type)
161+
val isLinkType = type == EditorLinkSpan::class.java
161162

162-
if (spans.isEmpty()) {
163+
if (isLinkType && spans.isEmpty()) {
163164
emitLinkDetectedEvent(spannable, null, start, end)
164165
return null
165166
}
@@ -169,7 +170,7 @@ class EditorSelection(private val editorView: ReactNativeRichTextEditorView) {
169170
val spanEnd = spannable.getSpanEnd(span)
170171

171172
if (start >= spanStart && end <= spanEnd) {
172-
if (span is EditorLinkSpan) {
173+
if (isLinkType && span is EditorLinkSpan) {
173174
emitLinkDetectedEvent(spannable, span, spanStart, spanEnd)
174175
}
175176

0 commit comments

Comments
 (0)