In CodeMirror6, how to calculate the difference between two documents

In collaboration, if the length of the document is inconsistent, the server will notify the client and return the current version number and the latest document content of the server to the client. At this time, if the client has accumulated some data to be updated, After receiving the notification from the server, the latest document content of the server will be applied, but after these ‘unconfirmed’ are integrated, an error will be reported when pushed to the server.