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