Editor activity
Capture text changes, directed selections, and cursor movement in either editor generation.
CM5 events · CM6 transactions
CodeMirror 6 · stable v2
Version 2 is the default CodeMirror 6 recorder and player. CodeMirror 5
stays maintained on version 1, with the same CodeRecord,
CodePlay, and portable JSON recording contract.
npm install codemirror-record@^2 @codemirror/state@^6 @codemirror/view@^6
npm install codemirror-record@^1 codemirror@^5
Using CodeMirror 5.x? Try CodeMirror Record version 1 instead.
Moving an existing application? Follow the CM5 → CM6 migration runbook and keep stored recording strings unchanged.
Release tracks
How it works
Recording and playback remain separate. The JSON string is the bridge, so your application decides when and where a session moves.
Attach CodeRecord and call listen().
getRecords() drains pending activity into JSON.
Pass a non-empty records string to addOperations().
Play, pause, seek, and adjust the timeline speed.
What gets recorded
CodeMirror Record keeps the payload compact while preserving the interaction details that make a coding session understandable.
Capture text changes, directed selections, and cursor movement in either editor generation.
CM5 events · CM6 transactions
Add JSON-serializable events that happen outside the editor.
recordExtraActivity()
Pause, seek, change speed, and subscribe to player lifecycle events.
play · pause · seek · end
Quick start
Start both editors with the same document. Capture only after the user has interacted with the recording editor, then guard against an empty batch before loading it.
import {CodeRecord, CodePlay} from 'codemirror-record';
const recorder = new CodeRecord(recordView);
const player = new CodePlay(playView, {
maxDelay: 3000,
speed: 1,
});
recorder.listen();
function replayPendingOperations() {
const records = recorder.getRecords();
if (JSON.parse(records).length === 0) return;
player.addOperations(records);
player.play();
}
Choose the editor seam
The editor adapters differ because CodeMirror 6 replaced the CM5 event model with transactions. Stored sessions stay on the established wire format.
Transaction-native recording and atomic playback for an EditorView.
codemirror-record@^2
Every published v1.x release is exercised with operations, selections, timing, and extras in both directions.
The established event-based adapter remains available for existing applications.
codemirror-record@^1
Existing ^1 installations do not cross the major-version line.
Real CM5 and CM6 recorders and players pass the full two-way package matrix;
recorded JSON does not require a schema migration.
Read the migration runbook or
inspect the release policy.
Ready for the full round trip?