Closed RaviPulpstrategy closed 4 years ago
@RaviPulpstrategy did you found any solution ?
Not yet!
Did you try checking the RichEditorDelegate? Here's what I've got:
var prevText: String!
@objc func richEditor(_ editor: RichEditorView, contentDidChange content: String) {
if content.count > 20 {
editor.html = prevText
// Where content is the HTML, not the visible text and 20 is the max number of characters
} else {
prevText = content
}
}
I just started iOS development, so I'm not sure if this'll cause any issues regarding threading. I haven't tested copy and paste, but it should work just fine since the previous text onTextChange is saved in the variable.
Cheers!
@RaviPulpstrategy @jahid1297
https://gist.github.com/YoomamaFTW/6f436e17f34f43ebda13e08d629e9d56
This is if you want the full code (it has some other issue I had, so sorry for the clump). The gist is the full programmatically made view controller of an editor view controller. The comment's code itself is the same for both storyboard and programmatically.
Do note: Make sure when you're inheriting classes that you also inherit RichEditorDelegate, so like this:
class EditorViewController: UIViewController, RichEditorDelegate {
let editorView = RichEditorView()
var prevText: String!
override viewDidLoad() {
super.viewDidLoad()
editorView.delegate = self
// Some other stuff
}
@objc func richEditor(_ editor: RichEditorView, contentDidChange content: String) {
if content.count > 20 {
editor.html = prevText
// Where content is the HTML, not the visible text and 20 is the max number of characters
} else {
prevText = content
}
}
}
Yes, it will work! Thanks
@RaviPulpstrategy did you found any solution ?