Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftUI UIRepresentable EditorView extends beyond swiftUI view #106

Open
santi-g-s opened this issue Mar 1, 2021 · 1 comment
Open

SwiftUI UIRepresentable EditorView extends beyond swiftUI view #106

santi-g-s opened this issue Mar 1, 2021 · 1 comment

Comments

@santi-g-s
Copy link

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

@niklasgrewe
Copy link

@santi-g-s could you share your full view setup with Coordinator? How do you make the Binding etc?
I am also looking to implement Proton in SwiftUI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants