danielsaidi / RichTextKit

RichTextKit is a Swift SDK that helps you use rich text in Swift and SwiftUI.
MIT License
944 stars 126 forks source link

Add support to disable scrolling in text view #117

Closed screenworker closed 10 months ago

screenworker commented 10 months ago

For my macOS project it is necessary to have a way to turn off the automatic scrolling behavior of the richtext editor because I want to place the richtext editor view in a scroll view between two other view elements. I think this would also be feasible for other users. this could be a solution for that.

Issue: https://github.com/danielsaidi/RichTextKit/issues/118

danielsaidi commented 10 months ago

This looks great @screenworker - I understand the need and absolutely want to add this to the library.

There are some conflicts after the latest changes. Do you want me to fix those, or do you prefer to do it? I'd also switch, so the naming is isScrollEnabled instead of having the negation :)

@DominikBucher12 If you're thinking about adding a configuration parameter, that's what I'm thinking too. Instead of having many parameters, let's just go for a single config parameter.

screenworker commented 10 months ago

I would be very happy if you solved the problems yourself. I actually just wanted to contribute to further development with this post. You have been involved in the project much further. It can definitely be better in one place or another.

danielsaidi commented 10 months ago

Hi again @screenworker

I have added support for this in another way. You can now provide a configuration to the RichTextEditor, which it then passes down to the rich text view.

This configuration has a property for isScrollingEnabled, which by default is true. Please try it out and let me know if it works for you.

I will close this PR but would love to add your inline editor to the demo. Please feel free to create another PR with this functionality.

I will release support for this context in the upcoming 0.9.7.

alelordelo commented 8 months ago

@danielsaidi has this been merged?

I tried:

  RichTextFormatSidebar(context: context)
            .onAppear {
                context.isScrollingEnabled = true
             }

But Xcode prints: Value of type 'RichTextContext' has no dynamic member 'isScrollingEnabled' using key path from root type 'RichTextContext'

screenworker commented 7 months ago

@alelordelo yes, but please try the implementation of @danielsaidi. My approach was only an idea to implement this feature.