This is the Swift 5 version of cjwirth/RichEditorView using WKWebView that added several awesome functionalities.
Table of Contents:
You can use SPM to install this package. If you're using Pods or Carthage, since I haven't created a package for those yet, you'll need to do this manually.
Most features are the same from the parent repo, but I have added some other functionalities and some directions in the sample. Other features can be found in cjwirth's repo.
The following edited features assumes you have a property let editorView = RichEditorView()
editorView.getSelectedText
Void
, you must do the following:editorView.getSelectedText() { r in
// r is just a variable.
}
or
editorView.runJS("document.getElementById('editor')") { r in
print(r)
}
NOTE That these might run asynchronously. This might be due to WKWebView's memory efficiency feature. Don't quote me on that though, since I'm not too sure if that's true. Just an observation.
This is because the function is: public func getSelectedText(handler: @escaping (String) -> Void)
. Notice the (String) -> Void
. The variable r
is the string value returned by JavaScript.
<a href="https://github.com/" title="GitHub">The TEXT that user sees</a>
. When you insert a link, the following arguments are required: href and text. If there is a range selection, the text in the range selection will be cleared!License is under BSD-3 Clause
cjwirth - Original iOS-RichEditorView Creator
C. Bess - WKWebView Support
YoomamaFTW - Repository Maintainer
Andrew-Chen-Wang - Repository Maintainer
link |
Stars: 124 |
Last commit: 1 week ago |
First release of RichEditorView for Swift 5
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics