| 423 | } |
| 424 | |
| 425 | function recordHistory() { |
| 426 | if (!focus) return |
| 427 | |
| 428 | const html = editor.innerHTML |
| 429 | const pos = save() |
| 430 | |
| 431 | const lastRecord = history[at] |
| 432 | if (lastRecord) { |
| 433 | if (lastRecord.html === html |
| 434 | && lastRecord.pos.start === pos.start |
| 435 | && lastRecord.pos.end === pos.end) return |
| 436 | } |
| 437 | |
| 438 | at++ |
| 439 | history[at] = {html, pos} |
| 440 | history.splice(at + 1) |
| 441 | |
| 442 | const maxHistory = 300 |
| 443 | if (at > maxHistory) { |
| 444 | at = maxHistory |
| 445 | history.splice(0, 1) |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | function handlePaste(event: ClipboardEvent) { |
| 450 | if (event.defaultPrevented) return |