Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
rztime committed Dec 18, 2024
1 parent 5344627 commit 559af4a
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Example/RZRichTextView/HTML2AttrViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class HTML2AttrViewController: UIViewController {

self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(customView: btn)
let html = (try? String.init(contentsOfFile: "/Users/rztime/Desktop/test.html")) ?? ""
let t = "<body style=\"font-size:16px;color:#110000;\">\(html)</body>"
let t = html.toHtml()
textView.html2Attributedstring(html: t)
}
}
2 changes: 1 addition & 1 deletion Example/RZRichTextView/HowToUseDemo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public extension RZRichTextViewModel {
return true
}
viewModel.uploadAttachmentsComplete.subscribe({ value in
// print("上传是否完成:\(value)")
print("上传是否完成:\(value)")
}, disposebag: viewModel)
/// 有新的附件插入时,需在附件的infoLayer上,添加自定义的视图,用于显示图片、视频、音频,以及交互
viewModel.reloadAttachmentInfoIfNeed = { [weak viewModel] info in
Expand Down
2 changes: 1 addition & 1 deletion Example/RZRichTextView/LabelLoadHtmlViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class LabelLoadHtmlViewController: UIViewController {
self?.tableView.reloadData()
}
let html = (try? String.init(contentsOfFile: "/Users/rztime/Desktop/test.html")) ?? ""
let t = "<body style=\"font-size:16px;color:#110000;\">\(html)</body>"
let t = html.toHtml()
cell.html = t
return cell
}
Expand Down
2 changes: 1 addition & 1 deletion Example/RZRichTextView/NormalTestViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class NormalTestViewController: UIViewController {

])
let html = (try? String.init(contentsOfFile: "/Users/rztime/Desktop/test.html"))
let t = "<body style=\"font-size:16px;color:#110000;\">\(html ?? "")</body>"
let t = html?.toHtml()
textView.rz.colorfulConfer { confer in
confer.htmlString(t)
}
Expand Down
19 changes: 0 additions & 19 deletions Example/RZRichTextView/NormalViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,7 @@ class NormalViewController: UIViewController {
.qtitleColor(.red)
.qtap { [weak self] view in
guard let self = self else { return }
let attachments = self.textView.attachments
if let _ = attachments.firstIndex(where: { info in
if case .complete(let success, _) = info.uploadStatus.value {
return !success
}
return true
}) {
// 有未完成上传的
print("有未完成上传的")
return
}
let html = self.textView.code2html()
print("\(html)")
}
/// 上传完成时,可以点击
textView.viewModel.uploadAttachmentsComplete.subscribe({ [weak btn] value in
btn?.isEnabled = value
btn?.alpha = value ? 1 : 0.3
}, disposebag: btn)

self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(customView: btn)
}
}
7 changes: 3 additions & 4 deletions Example/RZRichTextView/TableViewViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class TableViewViewController: UIViewController {
let btn = UIButton.init(type: .custom)
self.navigationItem.rightBarButtonItem = .init(customView: btn)
let temphtml = (try? String.init(contentsOfFile: "/Users/rztime/Desktop/test.html")) ?? ""
let html1 = "<body style=\"font-size:16px;color:#110000;\">\(temphtml)</body>"
let html2 = "<body style=\"font-size:16px;color:#110000;\">\(temphtml)</body>"
let html1 = temphtml.toHtml()
let html2 = temphtml.toHtml()
var html = html1
btn.qtitle("测试").qtitleColor(.red)
.qtap { [weak self] view in
Expand All @@ -51,8 +51,7 @@ class TableViewViewController: UIViewController {
self?.tableView.reloadData()
}
}
let t = "<body style=\"font-size:16px;\">\(html)</body>"
cell?.html = t
cell?.html = html
return cell!
}
}
Expand Down
4 changes: 4 additions & 0 deletions RZRichTextView/Classes/RZHtml.swift
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ public extension String {
}
return temp
}
/// 将html字符转换为html,包一层,这样可以设置默认字号,以支持rem,em,pt,%,px
func toHtml(size: CGFloat = 16) -> String {
return "<!DOCTYPE html><html style=\"font-size: \(size)px;\"><head><style>p{font-size: 1rem;}</style></head><body>\(self)</body></html>"
}
}

public class RZLabelInfo {
Expand Down
2 changes: 1 addition & 1 deletion RZRichTextView/Classes/RZInputAccessoryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import QuicklySwift
/// 工具栏视图
open class RZInputAccessoryView: UIView {
open var collectionView: UICollectionView = .init(frame: .zero, collectionViewLayout: .init())

.qbackgroundColor(.clear)
open var stackView = QStackView.qbody(.horizontal, 0, .fill, .equalSpacing, nil)
.qshowType(.horizontal, type: .height)
.qbackgroundColor(.white)
Expand Down
1 change: 1 addition & 0 deletions RZRichTextView/Classes/RZRichTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ public extension RZRichTextView {
}
/// 插入附件
func insetAttachment(_ attachmentinfo: RZAttachmentInfo) {
self.viewModel.uploadAttachmentsComplete.accept(false)
let attachment = NSTextAttachment.createWithinfo(attachmentinfo)
let attr = NSMutableAttributedString.init(attachment: attachment)
attr.addAttributes(self.typingAttributes, range: .init(location: 0, length: attr.length))
Expand Down

0 comments on commit 559af4a

Please sign in to comment.