Skip to content

Commit

Permalink
优化:罗马数字、abc等序号统一成数字序号,其他统一成点序号
Browse files Browse the repository at this point in the history
  • Loading branch information
rztime committed Oct 23, 2023
1 parent 403f9d8 commit f4d1577
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
41 changes: 35 additions & 6 deletions RZRichTextView/Classes/RZCss.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,63 @@ public extension NSParagraphStyle {
return .none
}
}
/// 是否是有序段落
/// 是否是有序段落 罗马数字、abc等等等等,统一成序号
var isol: Bool {
if self.rzTextListType == .ol {
return true
}
var temp = false
let ollist: [String] = [NSTextList.MarkerFormat.decimal.rawValue,
NSTextList.MarkerFormat.lowercaseHexadecimal.rawValue,
NSTextList.MarkerFormat.uppercaseHexadecimal.rawValue,
NSTextList.MarkerFormat.octal.rawValue,
NSTextList.MarkerFormat.lowercaseAlpha.rawValue,
NSTextList.MarkerFormat.uppercaseAlpha.rawValue,
NSTextList.MarkerFormat.lowercaseLatin.rawValue,
NSTextList.MarkerFormat.uppercaseLatin.rawValue,
NSTextList.MarkerFormat.lowercaseRoman.rawValue,
NSTextList.MarkerFormat.uppercaseRoman.rawValue,
"num",
]
self.textLists.forEach { item in
if item.markerFormat.rawValue.contains(NSTextList.MarkerFormat.decimal.rawValue) {
temp = true
if temp { return }
let value = item.markerFormat.rawValue
ollist.forEach { text in
if temp { return }
if value.contains(text) {
temp = true
}
}
}
if temp { return true }
if self.firstLineHeadIndent > 30.08 && self.firstLineHeadIndent < 30.12 &&
self.headIndent > 30.08 && self.headIndent < 30.12{
temp = true
}
return temp
}
/// 是否是无序
/// 是否是无序 点、圈等等都当做无序
var isul: Bool {
if self.rzTextListType == .ul {
return true
}
var temp = false
let ullist : [String] = [NSTextList.MarkerFormat.disc.rawValue,
NSTextList.MarkerFormat.hyphen.rawValue,
NSTextList.MarkerFormat.circle.rawValue,
NSTextList.MarkerFormat.diamond.rawValue,
]
self.textLists.forEach { item in
if item.markerFormat.rawValue.contains(NSTextList.MarkerFormat.disc.rawValue) {
temp = true
if temp { return }
let value = item.markerFormat.rawValue
ullist.forEach { text in
if temp { return }
if value.contains(text) {
temp = true
}
}
}
if temp { return true }
if self.firstLineHeadIndent > 30.28 && self.firstLineHeadIndent < 30.32 &&
self.headIndent > 30.28 && self.headIndent < 30.32{
temp = true
Expand Down
13 changes: 6 additions & 7 deletions RZRichTextView/Classes/RZRichTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -612,13 +612,12 @@ public extension RZRichTextView {
}
temp.forEach { (index, range, p, dict) in
if index != "" {
if let rect = self.rz.rectFor(range: .init(location: range.location, length: 0)) {
let view = RZTextListView.init().qframe(.init(x: 3, y: rect.origin.y, width: 30, height: rect.size.height))
.qfont((dict[.font] as? UIFont) ?? .systemFont(ofSize: 16))
.qtextColor((dict[.foregroundColor] as? UIColor) ?? .black)
.qtext("\(index)")
self.addSubview(view)
}
let rect = self.qcaretRect(for: range.location)
let view = RZTextListView.init().qframe(.init(x: 3, y: rect.origin.y, width: 30, height: rect.size.height))
.qfont((dict[.font] as? UIFont) ?? .systemFont(ofSize: 16))
.qtextColor((dict[.foregroundColor] as? UIColor) ?? .black)
.qtext("\(index)")
self.addSubview(view)
}
}
}
Expand Down

0 comments on commit f4d1577

Please sign in to comment.