twitter / TwitterTextEditor

A standalone, flexible API that provides a full-featured rich text editor for iOS applications.
Apache License 2.0
2.98k stars 164 forks source link

What's your take on making this library platform-independent? #14

Open Moriquendi opened 3 years ago

Moriquendi commented 3 years ago

Hello Twitter folks, What's your take on making this library platform-independent? Specifically, it now relies on UIKit which prevents it from being used on macOS.

Is supporting macOS on the radar? Both UITextView and NSTextView relies on the same NSTextStorage and NSTextContainer classes so I think this should be possible without a major refactor. Would you accept a contribution that tries to make the library work on macOS?

Cheers 👋

niw commented 3 years ago

Hi, @Moriquendi

Short answer is that we don’t have a plan to make it works on AppKit natively for now.

There are a few reasons. First, AppKit’s NSTextView and UIKit’s UITextView are both using same NSTextStorage and NSTextContainer as you mentioned, however both APIs are not same and behaviors are not same. This is because NSTextView is actually very, very old component that is built since original Nextstep era, yet also UITextView is built for touch interactions for iOS. Another reason is that there is Mac Catalyst which allows UIKit app runs on macOS, which covers our use case of macOS support (I know that is not what you want probably, though.)

I believe, however, some techniques that Twitter Text Editor is using can be used as-is with NSTextView such as how it provides APIs to apply attributes. Therefore in future at some point, probably some potion of API set can be platform independent and can be exported from Twitter Text Editor for AppKit, like when SwiftUI API provides seamless API for both platform for example. Yet, just I think it’s not now.

Moriquendi commented 3 years ago

Gotcha, thanks @niw. I'm gonna keep fingers crossed for making libraries like this work on macOS too. In the meantime, I might play around with porting some of the functionalities to macOS. I'll let you know if I have something to share or contribute :)