MCPcopy
hub / github.com/antonmedv/codejar / handleUndoRedo

Function handleUndoRedo

codejar.ts:402–423  ·  view source on GitHub ↗
(event: KeyboardEvent)

Source from the content-addressed store, hash-verified

400 }
401
402 function handleUndoRedo(event: KeyboardEvent) {
403 if (isUndo(event)) {
404 preventDefault(event)
405 at--
406 const record = history[at]
407 if (record) {
408 editor.innerHTML = record.html
409 restore(record.pos)
410 }
411 if (at < 0) at = 0
412 }
413 if (isRedo(event)) {
414 preventDefault(event)
415 at++
416 const record = history[at]
417 if (record) {
418 editor.innerHTML = record.html
419 restore(record.pos)
420 }
421 if (at >= history.length) at--
422 }
423 }
424
425 function recordHistory() {
426 if (!focus) return

Callers 1

CodeJarFunction · 0.85

Calls 4

isUndoFunction · 0.85
preventDefaultFunction · 0.85
restoreFunction · 0.85
isRedoFunction · 0.85

Tested by

no test coverage detected