Skip to content

Commit 02e3552

Browse files
authored
fix(Android): removing paragraph styles (#430)
# Summary Fixes removing paragraph continuous styles by using backspace. ## Test Plan - Enter multiline code block or blockquote - Remove text from the second line - Notice that styles are still applied to other lines, but there is no style for second line ## Screenshots / Videos ### Before https://github.com/user-attachments/assets/bfd6ff7b-0146-4770-b9b9-158b80d65108 ### After https://github.com/user-attachments/assets/18789024-625b-4f88-b665-c7d93feef9fc ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ❌ | | Android | ✅ |
1 parent 651a237 commit 02e3552

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

android/src/main/java/com/swmansion/enriched/textinput/styles/ParagraphStyles.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,7 @@ class ParagraphStyles(
221221
}
222222

223223
val currSpan = currParagraphSpans[0]
224-
val nextSpan = getNextParagraphSpan(s, end, type)
225-
226-
if (nextSpan == null) {
227-
return
228-
}
224+
val nextSpan = getNextParagraphSpan(s, end, type) ?: return
229225

230226
val newStart = s.getSpanStart(currSpan)
231227
val newEnd = s.getSpanEnd(nextSpan)
@@ -347,9 +343,12 @@ class ParagraphStyles(
347343
continue
348344
}
349345

346+
// If removing text at the beginning of the line, we want to remove the span for the whole paragraph
350347
if (isBackspace) {
351-
endCursorPosition -= 1
348+
val currentParagraphBounds = s.getParagraphBounds(endCursorPosition)
349+
removeSpansForRange(s, currentParagraphBounds.first, currentParagraphBounds.second, config.clazz)
352350
spanState.setStart(style, null)
351+
continue
353352
} else {
354353
s.insert(endCursorPosition, EnrichedConstants.ZWS_STRING)
355354
endCursorPosition += 1

0 commit comments

Comments
 (0)