Skip to content

Commit ec6e3c2

Browse files
Fix Li tag when switching the list style (issue #1307)
1 parent 969b90f commit ec6e3c2

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Aztec/Classes/TextKit/TextView.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,8 +1105,12 @@ open class TextView: UITextView {
11051105
toggle(formatter: formatter, atRange: range)
11061106

11071107
let liFormatter = LiFormatter(placeholderAttributes: typingAttributes)
1108-
toggle(formatter: liFormatter, atRange: range)
1108+
let isOlTagPresent = formatter.present(in: storage, at: range)
1109+
let isLiTagPresent = liFormatter.present(in: storage, at: range)
11091110

1111+
if (!isOlTagPresent && isLiTagPresent) || (isOlTagPresent && !isLiTagPresent) {
1112+
toggle(formatter: liFormatter, atRange: range)
1113+
}
11101114
forceRedrawCursorAfterDelay()
11111115
}
11121116

@@ -1122,8 +1126,12 @@ open class TextView: UITextView {
11221126
toggle(formatter: formatter, atRange: range)
11231127

11241128
let liFormatter = LiFormatter(placeholderAttributes: typingAttributes)
1125-
toggle(formatter: liFormatter, atRange: range)
1126-
1129+
let isOlTagPresent = formatter.present(in: storage, at: range)
1130+
let isLiTagPresent = liFormatter.present(in: storage, at: range)
1131+
1132+
if (!isOlTagPresent && isLiTagPresent) || (isOlTagPresent && !isLiTagPresent) {
1133+
toggle(formatter: liFormatter, atRange: range)
1134+
}
11271135
forceRedrawCursorAfterDelay()
11281136
}
11291137

0 commit comments

Comments
 (0)