shaps80 / SwiftUIBackports

A collection of SwiftUI backports for iOS, macOS, tvOS and watchOS
MIT License
931 stars 59 forks source link

Rich text support in TextEditor #56

Closed tmaly1980 closed 1 year ago

tmaly1980 commented 1 year ago

I've been using TextView for a few months and recently noticed that it has been deprecated in favor of Backports.TextEditor. However, I don't see how I'm supposed to enable rich text, ie where URLs, phone numbers and emails are tappable. I'm a bit surprised I don't see any ViewModifiers for this component. Any samples would be appreciated.

shaps80 commented 1 year ago

The TextEditor backport behaves identically to the official SwiftUI component, therefore links etc are not supported. Backports should be drop-in replacements, so I can't add features there.

If TextView was fine for your usage, continue using it, however I'm no longer supporting it directly.

I have an extension of the backports called SwiftUIPlus that will soon inherit a whole new TextView implementation that does indeed include rich text support, including bindings and actions for wiring up toolbar items, etc.

I didn't have the time to complete this when I initially implemented TextView, so it was more useful as a non-editable component.

Its not released or available just yet, but I am actively working on it, so it will be released shortly.

tmaly1980 commented 1 year ago

That's great to hear. The README on TextView unfortunately referred to this project, which doesn't honestly seem like the right place to point. TextEditor does not replace TextView as you say yourself. Perhaps when you have that updated module you can modify the TextView readme to point to that specific module?

shaps80 commented 1 year ago

Yeah I think I was just trying to point out that it's no longer supported.

But you're right it's unclear. I'll edit to clarify. Thanks for raising

tmaly1980 commented 1 year ago

What's the ETA for the rewrite? Is there an experimental version available somewhere? I noticed you closed a PR back in December (6 months ago) because of this rewrite, and without actually anything tangible to start using, I'm stuck using the existing TextView package. Unfortunately, it's buggy and incomplete and unless are replacing it immediately, I'd hope you could find someone else to take over/fork the project so it can be maintained elsewhere, assuming you're just not wanting to spend time on maintaining it.

I noticed the issue (where the cursor always moves to the end of the line after key press, even delete. That makes the editor pretty useless without a fix. It also caused a glitch with the cursor jumping around on very long multiline content. I wasted probably two days on this because the new version isn't out yet AFAIK and for whatever bizarre reason, XCode 14.3 has a broken implementation of TextEditor where clearing the background is no longer an option even on iOS 15.

I went ahead and grabbed the PR code (https://github.com/SwiftUI-Plus/TextView/issues/5) and patched my own fork but frankly I would have preferred that a known bug to have been fixed, at least somewhere. If not on your fork then someone else's fork that would at least be highlighted in the README for the time being.

shaps80 commented 1 year ago

What's the ETA for the rewrite? Is there an experimental version available somewhere? I noticed you closed a PR back in December (6 months ago) because of this rewrite, and without actually anything tangible to start using, I'm stuck using the existing TextView package. Unfortunately, it's buggy and incomplete and unless are replacing it immediately, I'd hope you could find someone else to take over/fork the project so it can be maintained elsewhere, assuming you're just not wanting to spend time on maintaining it.

I noticed the issue (where the cursor always moves to the end of the line after key press, even delete. That makes the editor pretty useless without a fix. It also caused a glitch with the cursor jumping around on very long multiline content. I wasted probably two days on this because the new version isn't out yet AFAIK and for whatever bizarre reason, XCode 14.3 has a broken implementation of TextEditor where clearing the background is no longer an option even on iOS 15.

I went ahead and grabbed the PR code (SwiftUI-Plus/TextView#5) and patched my own fork but frankly I would have preferred that a known bug to have been fixed, at least somewhere. If not on your fork then someone else's fork that would at least be highlighted in the README for the time being.

I have a lot of open source libraries and I'm one person so I have limited time to work on essentially free libraries for everyone to use and expand.

I'm always open to contributions but a lot of developers just want to use others work without contributing unfortunately.

Atm I have family, work and other higher priority packages that have far more users, including these backports.

I do understand your frustration, but that frustration is what drove me to do these libraries in the first place. I don't wait for others to do it for me, I just dig in and then share the results, hopefully being helpful to others.

I admit you're right that other package is buggy, hence why it was ARCHIVED and I had made it clear I'll no longer be supporting that.

The rewrite is NOT something I can share at this stage I'm afraid, not even an experimental stage. I just don't work that way, I'm deliberate about what I write and when I'm ready to share.

I would not however have expected, a known bug on a no-longer-supported library to have been fixed I'm afraid.

Another great developer has actually created a very similar implementation to my rewrite approach, perhaps even more complete as I know he's actively supporting it. Perhaps it's best I recommend you check that out instead.

https://github.com/danielsaidi/RichTextKit