import * as Y from 'yjs'; export function squashYjsState(yjsState: Uint8Array): Uint8Array { const fullStateDoc = new Y.Doc() const fullText = fullStateDoc.getText('quill'); Y.applyUpdate(fullStateDoc, Uint8Array.from(yjsState)); const simpleDoc = new Y.Doc(); const simpleText = simpleDoc.getText('quill'); simpleText.applyDelta( fullText.toDelta() ); const update = Y.encodeStateAsUpdate(simpleDoc); return update; }