Closed GregOriol closed 3 years ago
Hey,
Interesting question.
I implement text views delegate method shouldChangeTextInRange (https://developer.apple.com/documentation/uikit/uitextviewdelegate/1618630-textview)
When receiving a change I convert the given NSRange into a Swift.Range and use automerge replaceSubrange method.
I did not build a real-time editor, so I never build applying remote changes into a text view.
Is there a specific reason why you can not just replace the text views content with the new remote content?
Thanks for the shouldChange tip, I didn't think of this one!
Replacing content while the user is editing will break the cursor position or scroll position if the content has changed a lot, that doesn't seem very user friendly.
But, I just found another direction to look for: UITextView has a textStorage attribute, and it seems to provide access to its text content in a more detailed way.
Did a quick look into UITextView documentation.
textStorage looks promising (https://developer.apple.com/documentation/uikit/uitextview/1618611-textstorage)
Seems like we found the same solution.
If you feels confident with the solution close this issue.
I'll try it and reopen if needed.
Thanks!
Hi,
I'm very much interested in using automerge to sync a long text content on iOS between devices, but I'm a little bit confused between automerge's change methods (insertion of character at position, ...) and how to connect them with a UITextView: would you have any tips? Mainly, my questions are:
Best regards,