Skip to content

SwiftUI UIRepresentable EditorView extends beyond swiftUI view #106

@santi-g-s

Description

@santi-g-s

I am using Proton with swiftUI through a UIRepresentableView. I am having trouble enabling the scroll functionality when the editor reaches its container size.

I set up my view this way:

struct RepresentableRichTextEditor: UIViewRepresentable {
    
    @Binding var attributedText: NSAttributedString
    
    func makeCoordinator() -> Coordinator {
        Coordinator(self)
    }
    
    let commandExecutor = EditorCommandExecutor()
    
    func makeUIView(context: Context) -> UIView {
        
        let editor = EditorView()
        editor.delegate = context.coordinator

        //This forces the editor view to scroll however disables the auto layout provided by the representable view
        //editor.translatesAutoresizingMaskIntoConstraints = false 
        //editor.maxHeight = 300

        EditorViewContext.shared.delegate = context.coordinator
        editor.setFocus()
        return editor
    }

    func updateUIView(_ uiView: UIView, context: Context) {

       //Update logic here
        
    }
}

I have tried using .frame(height) in the parent SwiftUI View but this didn't seem to affect the underlying editorView.

Does anyone know how to get scrolling working with SwiftUI?

Many thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions