danielsaidi / RichTextKit

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

Keyboard Toolbar Doesn't Show #157

Closed Mcrich23 closed 8 months ago

Mcrich23 commented 8 months ago

When using the .toolbar modifier in regards to the keyboard for the RichTextEditor, the keyboard toolbar does not appear.

danielsaidi commented 8 months ago

Hi @Mcrich23

Yes, this is a known limitation when using a SwiftUI ViewRepresentable, which the RichTextEditor is.

The RichTextEditor docs mention this:

Since the view wraps a native UIKit or AppKit text view, you can't apply .toolbar modifiers to it, like you can do with other SwiftUI views. This means that this doesn't work:

 RichTextEditor(text: $text, context: context)
     .toolbar {
         ToolbarItemGroup(placement: .keyboard) {
             ....
         }
     }

This will not show anything. To work around this limitation, use a RichTextKeyboardToolbar instead.

danielsaidi commented 8 months ago

@Mcrich23 You can have a look at the demo app for an example on how to use that toolbar.