@@ -15,6 +15,8 @@ import java.io.File
1515
1616class ParametrizedStyles (private val editorView : ReactNativeRichTextEditorView ) {
1717 private var mentionStart: Int? = null
18+ private var isSettingLinkSpan = false
19+
1820 var mentionIndicators: Array <String > = emptyArray<String >()
1921
2022 fun <T >removeSpansForRange (spannable : Spannable , start : Int , end : Int , clazz : Class <T >): Boolean {
@@ -32,6 +34,8 @@ class ParametrizedStyles(private val editorView: ReactNativeRichTextEditorView)
3234 }
3335
3436 fun setLinkSpan (start : Int , end : Int , text : String , url : String ) {
37+ isSettingLinkSpan = true
38+
3539 val spannable = editorView.text as SpannableStringBuilder
3640 val spans = spannable.getSpans(start, end, EditorLinkSpan ::class .java)
3741 for (span in spans) {
@@ -50,6 +54,7 @@ class ParametrizedStyles(private val editorView: ReactNativeRichTextEditorView)
5054 spannable.setSpan(span, safeStart, safeEnd, Spanned .SPAN_EXCLUSIVE_EXCLUSIVE )
5155
5256 editorView.selection?.validateStyles()
57+ isSettingLinkSpan = false
5358 }
5459
5560 fun afterTextChanged (s : Editable , endCursorPosition : Int ) {
@@ -100,6 +105,8 @@ class ParametrizedStyles(private val editorView: ReactNativeRichTextEditorView)
100105 }
101106
102107 private fun afterTextChangedLinks (result : Triple <String , Int , Int >) {
108+ // Do not detect link if it's applied manually
109+ if (isSettingLinkSpan) return
103110 val spannable = editorView.text as Spannable
104111 val (word, start, end) = result
105112
0 commit comments