Closed Abdelilahskali closed 3 years ago
@Abdelilahskali I can see you closed this issue. Did you solve this issue? If so, can you share the solution please?
@Abdelilahskali can you please share solution.
This solution work for me
Update code in "RichEditorView"
private func updateHeight() {
runJS("RE.getHtml()") { content in
let attributedString = NSMutableAttributedString(string: content,
attributes: [
.font: UIFont.systemFont(ofSize: 16.0)
])
let stringToMeasure = attributedString.string.replacingOccurrences(of: "<br>", with: "\n")
let modifiedAttributedString = NSAttributedString(string: stringToMeasure, attributes: [
.font: UIFont.systemFont(ofSize: 16.0)
])
// Calculate the bounding rect
let maxWidth: CGFloat = UIScreen.main.bounds.width - 30
let options: NSStringDrawingOptions = [.usesLineFragmentOrigin, .usesFontLeading]
let boundingRect = modifiedAttributedString.boundingRect(with: CGSize(width: maxWidth, height: .greatestFiniteMagnitude), options: options, context: nil)
// Extract the calculated height
let height = ceil(boundingRect.height)
self.editorHeight = Int(height)
print(height)
}
}
Firstly thank you for this API I integrated the editor in a uitableviewcell and I increase the height of the cell from the delegate function heightDidChange. But when I remove the newlines the height always stays the same, the heightDidChange is not called is there a way to know the new editor height if i delete some text (newlines) to decrease cell height ?