From a8815b34778bfdd206f009cc38382f9f5d50a40b Mon Sep 17 00:00:00 2001 From: tangchi-looki Date: Tue, 13 Aug 2024 12:04:00 +0800 Subject: [PATCH 1/4] [1.0.0] font size --- RZRichTextView/Classes/RZHtml.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RZRichTextView/Classes/RZHtml.swift b/RZRichTextView/Classes/RZHtml.swift index 4afaf49..6f81422 100644 --- a/RZRichTextView/Classes/RZHtml.swift +++ b/RZRichTextView/Classes/RZHtml.swift @@ -369,13 +369,13 @@ public extension String { let newfont: UIFont switch font.fontType { case .boldItalic: - newfont = UIFont.rzboldItalicFont.withSize(font.pointSize) + newfont = UIFont.rzboldItalicFont case .bold: - newfont = UIFont.rzboldFont.withSize(font.pointSize) + newfont = UIFont.rzboldFont case .italic: - newfont = UIFont.rzitalicFont.withSize(font.pointSize) + newfont = UIFont.rzitalicFont case .normal: - newfont = UIFont.rznormalFont.withSize(font.pointSize) + newfont = UIFont.rznormalFont } tempAttr.addAttribute(.font, value: newfont, range: range) } From 0357e942c305049aed834f1536e284f4ad4e28c8 Mon Sep 17 00:00:00 2001 From: tangchi-looki Date: Wed, 14 Aug 2024 09:54:12 +0800 Subject: [PATCH 2/4] [1.0.0] font --- RZRichTextView/Classes/RZHtml.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RZRichTextView/Classes/RZHtml.swift b/RZRichTextView/Classes/RZHtml.swift index 6f81422..4afaf49 100644 --- a/RZRichTextView/Classes/RZHtml.swift +++ b/RZRichTextView/Classes/RZHtml.swift @@ -369,13 +369,13 @@ public extension String { let newfont: UIFont switch font.fontType { case .boldItalic: - newfont = UIFont.rzboldItalicFont + newfont = UIFont.rzboldItalicFont.withSize(font.pointSize) case .bold: - newfont = UIFont.rzboldFont + newfont = UIFont.rzboldFont.withSize(font.pointSize) case .italic: - newfont = UIFont.rzitalicFont + newfont = UIFont.rzitalicFont.withSize(font.pointSize) case .normal: - newfont = UIFont.rznormalFont + newfont = UIFont.rznormalFont.withSize(font.pointSize) } tempAttr.addAttribute(.font, value: newfont, range: range) } From d4c8fe1ee6a96ce2c5dfd0567374375b3a85edc9 Mon Sep 17 00:00:00 2001 From: tangchi-looki Date: Thu, 5 Sep 2024 19:19:40 +0800 Subject: [PATCH 3/4] custom_ul_symbol --- Example/RZRichTextView/HowToUseDemo.swift | 4 ++++ RZRichTextView/Classes/RZRichTextView.swift | 3 ++- RZRichTextView/Classes/RZRichTextViewModel.swift | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Example/RZRichTextView/HowToUseDemo.swift b/Example/RZRichTextView/HowToUseDemo.swift index a1fc61e..85b3778 100644 --- a/Example/RZRichTextView/HowToUseDemo.swift +++ b/Example/RZRichTextView/HowToUseDemo.swift @@ -45,6 +45,10 @@ public extension RZRichTextViewModel { let viewModel = RZRichTextViewModel.init() viewModel.canEdit = edit + viewModel.ulSymbol = "•" + //viewModel.ulSymbol = "*" + viewModel.ulSymbolAlignment = .center + /// 链接颜色 viewModel.defaultLinkTypingAttributes = [.foregroundColor: UIColor.qhex(0x307bf6), .underlineColor: UIColor.qhex(0x307bf6), .underlineStyle: NSUnderlineStyle.styleSingle.rawValue] /// 显示音频文件名字 diff --git a/RZRichTextView/Classes/RZRichTextView.swift b/RZRichTextView/Classes/RZRichTextView.swift index 7688715..4aaeb1c 100644 --- a/RZRichTextView/Classes/RZRichTextView.swift +++ b/RZRichTextView/Classes/RZRichTextView.swift @@ -631,7 +631,7 @@ public extension RZRichTextView { index = 1 } lastType = .ul - temp.append(("·", range, p, dict)) + temp.append((viewModel.ulSymbol, range, p, dict)) } else { lastType = .none index = 0 @@ -648,6 +648,7 @@ public extension RZRichTextView { .qfont((dict[.font] as? UIFont) ?? .systemFont(ofSize: 16)) .qtextColor((dict[.foregroundColor] as? UIColor) ?? .black) .qtext("\(index)") + .qtextAliginment(viewModel.ulSymbolAlignment) self.addSubview(view) } } diff --git a/RZRichTextView/Classes/RZRichTextViewModel.swift b/RZRichTextView/Classes/RZRichTextViewModel.swift index 0c7fc1b..c9fe2a4 100644 --- a/RZRichTextView/Classes/RZRichTextViewModel.swift +++ b/RZRichTextView/Classes/RZRichTextViewModel.swift @@ -132,6 +132,9 @@ open class RZRichTextViewModel: NSObject { /// 初始化的时候配置此项,在编辑过程中,如果想禁用编辑,直接设置textView.isEditable = false open var canEdit: Bool = true + open var ulSymbol:String = "·" + open var ulSymbolAlignment:NSTextAlignment = .right + public override init() { super.init() /// 默认居左 From baeab64a902d8702702cff4d1d362cc9fd477ee2 Mon Sep 17 00:00:00 2001 From: tangchi-looki Date: Thu, 5 Sep 2024 19:32:22 +0800 Subject: [PATCH 4/4] custom_ul_symbol font --- Example/RZRichTextView/HowToUseDemo.swift | 1 + RZRichTextView/Classes/RZRichTextView.swift | 2 +- RZRichTextView/Classes/RZRichTextViewModel.swift | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Example/RZRichTextView/HowToUseDemo.swift b/Example/RZRichTextView/HowToUseDemo.swift index 85b3778..ab1c59b 100644 --- a/Example/RZRichTextView/HowToUseDemo.swift +++ b/Example/RZRichTextView/HowToUseDemo.swift @@ -48,6 +48,7 @@ public extension RZRichTextViewModel { viewModel.ulSymbol = "•" //viewModel.ulSymbol = "*" viewModel.ulSymbolAlignment = .center + viewModel.ulSymbolFont = .systemFont(ofSize: 14, weight: .medium) /// 链接颜色 viewModel.defaultLinkTypingAttributes = [.foregroundColor: UIColor.qhex(0x307bf6), .underlineColor: UIColor.qhex(0x307bf6), .underlineStyle: NSUnderlineStyle.styleSingle.rawValue] diff --git a/RZRichTextView/Classes/RZRichTextView.swift b/RZRichTextView/Classes/RZRichTextView.swift index 4aaeb1c..a3d1be6 100644 --- a/RZRichTextView/Classes/RZRichTextView.swift +++ b/RZRichTextView/Classes/RZRichTextView.swift @@ -645,7 +645,7 @@ public extension RZRichTextView { if index != "" { 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)) + .qfont(viewModel.ulSymbolFont ?? (dict[.font] as? UIFont) ?? .systemFont(ofSize: 16)) .qtextColor((dict[.foregroundColor] as? UIColor) ?? .black) .qtext("\(index)") .qtextAliginment(viewModel.ulSymbolAlignment) diff --git a/RZRichTextView/Classes/RZRichTextViewModel.swift b/RZRichTextView/Classes/RZRichTextViewModel.swift index c9fe2a4..7dc6b67 100644 --- a/RZRichTextView/Classes/RZRichTextViewModel.swift +++ b/RZRichTextView/Classes/RZRichTextViewModel.swift @@ -134,6 +134,7 @@ open class RZRichTextViewModel: NSObject { open var ulSymbol:String = "·" open var ulSymbolAlignment:NSTextAlignment = .right + open var ulSymbolFont:UIFont? public override init() { super.init()