Editor activity
Capture text changes, selections, and cursor movement from CodeMirror 5.
changes · cursorActivity
CodeMirror 5 · MIT
CodeRecord captures editor activity—and application
events you add—as a JSON string. CodePlay loads that
string for pause, seek, and speed-controlled playback.
npm install codemirror-record@^1 codemirror@^5
Prefer an explicit maintenance selector? Use
codemirror-record@cm5.
Upgraded to CodeMirror 6.x? Use CodeMirror Record version 2 instead.
Recorded activity
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, selections, and cursor movement from CodeMirror 5.
changes · cursorActivity
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';
playEditor.setValue(recordEditor.getValue());
const recorder = new CodeRecord(recordEditor);
const player = new CodePlay(playEditor, {
maxDelay: 3000,
speed: 1,
});
recorder.listen();
function replayPendingOperations() {
const records = recorder.getRecords();
if (JSON.parse(records).length === 0) return;
player.addOperations(records);
player.play();
}
Compatibility
Use the same starting document in the recorder and player. CodeMirror 6 uses a different editor API and is supported by package v2. Existing recording JSON stays portable; follow the migration guide when changing editor generations.
Ready for the full round trip?