Twitter Text Editor is a standalone, flexible API that provides a full-featured rich text editor for iOS applications. We use this for Tweet composers on Twitter for iOS.
Today we’re happy to share Twitter Text Editor so iOS developers outside Twitter can add robust text editing to their applications.
Text editing is one of those common tasks in iOS applications which looks easy but can be unexpectedly complicated. Twitter Text Editor aims to solve common text editing problems that can be hard for developers to get right, like syntax highlighting and text content filtering.
Apple provides a set of high-level and low-level APIs for text editing, but developers are often left to fill the gap. The high-level APIs don’t always offer enough power or control to create a truly great in-app experience. Meanwhile, the lower level APIs require a lot of knowledge about how text editing works in a variety of languages, including support for bidirectional scripts, alternative input methods (like those used for East Asian languages), and assistive technology like braille keyboards.
We’ve learned a lot about text editing while working to address these problems over the last few years, and we hope Twitter Text Editor helps you improve your applications’ text editing experience.
Twitter Text Editor features:
Twitter Text Editor also comes with a sample application, written in both Swift and Objective-C, that demonstrates how to implement a text editor with multiple rich editing features, including syntax highlighting.
Twitter Text Editor is implemented as a Swift Package that you can easily add to your project in Xcode. It’s also possible to use via CocoaPods. It doesn’t have any dependencies beyond iOS system frameworks.
Twitter Text Editor encapsulates UITextView and provides familiar delegate-based APIs like many common UIKit APIs. It extends LayoutManager and TextStorage to provide custom text attributes, including attributes for presenting custom emoji. Twitter Text Editor has event schedulers to process events, providing consistent delegate callback order to your code.
Twitter Text Editor is useful to developers who wants to add flexible rich text editing to their iOS application without worrying about the pitfalls of Apple’s APIs. Its delegate methods allow you to focus on what your application provides to your users.
Twitter Text Editor project can be found on Twitter’s GitHub page.
We would love to get contributions from you! Please refer CONTRIBUTING.md for the details.
Editor's Note: This article has been modified to remove a reference to Fleets. We said goodbye to Fleets on August 3, 2021. We are grateful to you for being part of this community. Keep the conversation going on Twitter. Go to Twitter.