(event: KeyboardEvent)
| 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 |
no test coverage detected