I am developing a keyboard extension application using SwiftUI. In this application, I need to be able to manipulate the text entered by the user into the input box.
I have a KeyboardViewController class that extends UIInputViewController, and it has a textDocumentProxy property to manipulate the input box. I am able to read and manipulate short texts. Also I don’t have any problem with inserting or deleting a text. However, when it comes to longer paragraphs, I am unable to read the entire text.
Currently, I am using textDocumentProxy.documentContextBeforeInput to read the text, but it only retrieves the last sentence. I have also tried moving the cursor to the beginning of the paragraph and reading sentence by sentence using documentContextAfterInput, but this approach is not working either.
How can I read long texts effectively?