Recorder
Change the starter code. Every edit and cursor movement is queued by
CodeRecord.
CodeMirror 5 · session playback
CodeMirror Record captures text edits, selections, and cursor activity as portable JSON. Load that payload into a player to reproduce the coding session at any speed.
Upgraded to CodeMirror 6.x? Try the version 2 demo instead.
CodeRecord.listen()getRecords()addOperations(json)CodePlay.play()Editor activity JSON repeatable playback
The mental model
Recording and playback are separate. The JSON payload is the bridge between them, so it can be stored, sent, or replayed later.
Attach CodeRecord to an editable CodeMirror instance.
Call getRecords() to drain pending activity into JSON.
Pass the payload to CodePlay.addOperations().
Play, pause, seek, or change speed without touching the recording.
Interactive demo
Edit on the left, inspect the serialized payload, then replay it on the right.
Change the starter code. Every edit and cursor movement is queued by
CodeRecord.
Capture drains pending operations. Load sends the cumulative payload to the player.
No payload yet.
Edit the recorder, then capture.
Waiting for a recorded edit.
CodePlay applies the loaded operations to an identical
starting document.
Player events make application state easy to synchronize.
Minimal integration
The recorder and player can live in different views—or different systems. Preserve the same starting document and move the JSON payload wherever the replay needs to run.
getRecords() returns a JSON string and clears the pending batch.addOperations() accepts that string and prepares the timeline.play, pause, seek, and end.import {CodeRecord, CodePlay} from 'codemirror-record';
const recorder = new CodeRecord(editor);
recorder.listen();
// Capture and persist this JSON string.
const records = recorder.getRecords();
const player = new CodePlay(replayEditor, {
maxDelay: 3000,
speed: 1,
});
player.on('end', () => {
console.log('Replay complete');
});
if (JSON.parse(records).length > 0) {
player.addOperations(records);
player.play();
}