Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danielsaidi/RichTextKit
RichTextKit is a Swift SDK that helps you use rich text in Swift and SwiftUI.
https://github.com/danielsaidi/RichTextKit
appkit ios macos rich-text rich-text-editor swift swiftui tvos uikit watchos
Last synced: 7 days ago
JSON representation
RichTextKit is a Swift SDK that helps you use rich text in Swift and SwiftUI.
- Host: GitHub
- URL: https://github.com/danielsaidi/RichTextKit
- Owner: danielsaidi
- License: mit
- Created: 2022-05-10T18:28:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-09T07:31:57.000Z (27 days ago)
- Last Synced: 2024-10-19T18:26:09.528Z (17 days ago)
- Topics: appkit, ios, macos, rich-text, rich-text-editor, swift, swiftui, tvos, uikit, watchos
- Language: Swift
- Homepage:
- Size: 5.89 MB
- Stars: 903
- Watchers: 17
- Forks: 118
- Open Issues: 43
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
## About RichTextKit
RichTextKit is a Swift SDK that lets you edit rich text in `Swift` & `SwiftUI` with a multi-platform `RichTextEditor`:
The `RichTextEditor` supports text styles (bold, italic, underline, etc.), fonts, font sizes, colors, text alignments, image attachments, and much more. It's powered by a `RichTextView` that bridges `UITextView` & `NSTextView` and adds additional, platform-agnostic APIs that make the two views behave more alike.
If you just want to view rich text content, you can use the `RichTextViewer` SwiftUI view, which wraps the editor and applies a read-only configuration to it.
## Installation
RichTextKit can be installed with the Swift Package Manager:
```
https://github.com/danielsaidi/RichTextKit.git
```## Getting started
RichTextKit has a SwiftUI ``RichTextEditor`` that takes a text binding and a ``RichTextContext``:
```swift
struct MyView: View {@State
private var text = NSAttributedString(string: "Type here...")
@StateObject
var context = RichTextContext()var body: some View {
RichTextEditor(text: $text, context: context) {
// You can customize the native text view here
}
.focusedValue(\.richTextContext, context)
}
}
```The editor uses a ``RichTextCoordinator`` to sync changes between the editor, context, and platform-specific view. You can use the context to change font, colors, alignment etc. and observe context changes to update the UI.
If you just want to display rich text, you can use the ``RichTextViewer`` instead:
```swift
struct MyView: View {private var text = NSAttributedString(...)
var body: some View {
RichTextViewer(text: text)
}
}
```RichTextKit provides UI components, keyboard shortcuts & menu commands that can be used in a rich text editor.
For more information, please see the [getting started guide][Getting-Started].
## Documentation
The [online documentation][Documentation] has more information, articles, code examples, etc.
## Demo App & Inspiration
The RichTextKit demo lets you explore the library on iOS & macOS. To try it out, just open and run the `Demo` app.
RichTextKit is also used in the following apps, so make sure to check them out for inspiration:
Don't hesitate to reach out if you are using RichTextKit, and want to add your app to this list. I'd love to feature it.
## Sponsor my work
Please consider supporting my work if you find this and my other [open-source projects][OpenSource] helpful. I manage them on my spare time, and any help to keep them going is greatly appreciated.
You can [sponsor me][Sponsors] on GitHub Sponsors, [reach out][Email] for paid support, or hire me for [freelance work][Website].
## Contact
Feel free to reach out if you have questions or want to contribute in any way:
* Website: [danielsaidi.com][Website]
* Mastodon: [@[email protected]][Mastodon]
* Twitter: [@danielsaidi][Twitter]
* E-mail: [[email protected]][Email]## License
RichTextKit is available under the MIT license. See the [LICENSE][License] file for more info.
[Email]: mailto:[email protected]
[Website]: https://www.danielsaidi.com
[GitHub]: https://www.github.com/danielsaidi
[Twitter]: https://www.twitter.com/danielsaidi
[Mastodon]: https://mastodon.social/@danielsaidi
[Sponsors]: https://github.com/sponsors/danielsaidi
[OpenSource]: https://www.danielsaidi.com/opensource[Documentation]: https://danielsaidi.github.io/RichTextKit/documentation/richtextkit/
[Getting-Started]: https://danielsaidi.github.io/RichTextKit/documentation/richtextkit/getting-started
[License]: https://github.com/danielsaidi/RichTextKit/blob/master/LICENSE