I’m building an editor where users can edit JSON documents (in a text editor). This is all synced via yJS between users in a Y.XmlFragment.
Now, I want to implement a “format document”, that formats the document (adds correct indentation, etc). The library I’m using for this of course returns a string with the reformatted document.
Now, how would I apply this cleaned document to the Y.Text? Is the recommended way to calculate a diff between preformatted
and formatted
, convert the diff to edits (.insert()
, etc.). Or is there an easier recommended approach?