Skip to content

Commit a592bf2

Browse files
fix: removing conflicting styles
1 parent ec1c03f commit a592bf2

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

android/src/main/java/com/swmansion/enriched/textinput/utils/ShortcutsHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ShortcutsHandler(
4646
val resolvedStyle = resolveStyleName(styleName) ?: continue
4747

4848
s.replace(effectiveTriggerStart, effectiveTriggerStart + trigger.length, "")
49-
view.toggleStyle(resolvedStyle)
49+
view.verifyAndToggleStyle(resolvedStyle)
5050
return
5151
}
5252
}

ios/utils/ShortcutsUtils.mm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,12 @@ + (BOOL)tryHandlingParagraphShortcutsInRange:(NSRange)range
407407

408408
input->blockEmitting = NO;
409409

410-
// Drop conflicting inline typing attrs (e.g. italic) at the cursor before
411-
// applying the codeblock style.
410+
// Drop conflicting inline styles (e.g. italic) across the whole paragraph
411+
// before applying the block style.
412+
NSRange paragraphRange = [input->textView.textStorage.string
413+
paragraphRangeForRange:input->textView.selectedRange];
412414
[StyleUtils handleStyleBlocksAndConflicts:type
413-
range:input->textView.selectedRange
415+
range:paragraphRange
414416
forHost:input];
415417

416418
[ParagraphAttributesUtils resetTypingAttributes:input

0 commit comments

Comments
 (0)