Diffdown is a real-time collaborative Markdown editor/previewer built on the AT Protocol diffdown.com

fix: remove applyingRemote from queueDeltas, clear debounce on WS close

+8 -4
+8 -4
templates/document_edit.html
··· 533 533 }; 534 534 535 535 ws.onclose = () => { 536 + clearTimeout(wsEditTimer); 537 + pendingDeltas = []; 536 538 stopHeartbeat(); 537 539 updatePresence([]); 538 540 scheduleReconnect(); ··· 643 645 644 646 // Queue a set of deltas and flush after a short debounce. 645 647 function queueDeltas(deltas) { 646 - if (!ws || ws.readyState !== WebSocket.OPEN || applyingRemote) return; 648 + if (!ws || ws.readyState !== WebSocket.OPEN) return; 647 649 pendingDeltas = pendingDeltas.concat(deltas); 648 650 clearTimeout(wsEditTimer); 649 651 wsEditTimer = setTimeout(flushDeltas, 50); ··· 658 660 pendingDeltas = []; 659 661 } 660 662 661 - // sendEdit is kept for any future callers; Milkdown switches to diffToOps 662 - // in Chunk 4 and no longer calls this directly. 663 + // sendEdit sends a full-document replacement via the granular-delta path. 664 + // to: -1 is a sentinel meaning "end of document" — the server OT engine 665 + // clamps it to len(documentText), and applyRemoteEdit clamps it to docLen. 666 + // Milkdown switches to diffToOps in Chunk 4 and no longer calls this directly. 663 667 function sendEdit(content) { 664 - if (!ws || ws.readyState !== WebSocket.OPEN || applyingRemote) return; 668 + if (!ws || ws.readyState !== WebSocket.OPEN) return; 665 669 queueDeltas([{ from: 0, to: -1, insert: content }]); 666 670 } 667 671