@@ -7,7 +7,6 @@ import android.view.inputmethod.InputConnection
77import android.view.inputmethod.InputConnectionWrapper
88import com.facebook.react.bridge.ReactContext
99import com.facebook.react.uimanager.UIManagerHelper
10- import com.swmansion.enriched.common.spans.interfaces.EnrichedInlineSpan
1110import com.swmansion.enriched.textinput.events.OnInputKeyPressEvent
1211import com.swmansion.enriched.textinput.spans.EnrichedSpans
1312
@@ -109,14 +108,8 @@ class EnrichedTextInputConnectionWrapper(
109108 composingStart : Int ,
110109 composingEnd : Int ,
111110 ): List <InlineSpanSnapshot > =
112- editable
113- .getSpans(composingStart, composingEnd, EnrichedInlineSpan ::class .java)
114- .mapNotNull { span ->
115- val style =
116- EnrichedSpans .inlineSpans.entries
117- .firstOrNull { (_, config) -> config.clazz.isInstance(span) }
118- ?.key
119- ? : return @mapNotNull null
111+ EnrichedSpans .inlineSpans.flatMap { (style, config) ->
112+ editable.getSpans(composingStart, composingEnd, config.clazz).mapNotNull { span ->
120113 val start = editable.getSpanStart(span).coerceAtLeast(composingStart)
121114 val end = editable.getSpanEnd(span).coerceAtMost(composingEnd)
122115
@@ -126,6 +119,7 @@ class EnrichedTextInputConnectionWrapper(
126119 null
127120 }
128121 }
122+ }
129123
130124 private fun restoreInlineSpans (snapshot : ComposingTextSnapshot ) {
131125 val editable = editText.text ? : return
@@ -182,7 +176,7 @@ class EnrichedTextInputConnectionWrapper(
182176
183177 val mappedStart = newRangeStart + intersectionStart - oldRangeStart
184178 val mappedEnd = newRangeStart + intersectionEnd - oldRangeStart
185- editText.inlineStyles?.restoreStyleOnRange (
179+ editText.inlineStyles?.applyStyleOnRange (
186180 snapshot.style,
187181 composingStart + mappedStart,
188182 composingStart + mappedEnd,
0 commit comments