ui: custom undo/redo stack for editor — up to 200 steps

Native browser undo breaks when ta.value is set programmatically (tab,
enter, ctrl+/) — replaced with a custom snapshot-based undo system.

Stack behaviour:
- oninput → debounced capture (600ms) — groups rapid typing into chunks
- Tab / Enter / Ctrl+/ → immediate capture BEFORE edit, then capture AFTER
  (each programmatic edit gets its own undo step)
- Content load → vvUndoCaptureInitial() seeds the stack with a clean baseline
- Max 200 history entries (VV_UNDO_MAX); old entries dropped from front

Keyboard: Ctrl/Cmd+Z = undo, Ctrl/Cmd+Y or Ctrl/Cmd+Shift+Z = redo
(both handled in vvEditorKeydown before any other key processing)

Buttons: ↩ Undo / ↪ Redo appear in toolbar beside Cancel/Save when editor
is open; disabled state with 0.28 opacity when no steps available; Undo
button shows step count "↩ Undo 5" so you can see how deep the history is

Cleanup: vvEditorReset() calls vvUndoReset() so stack is cleared on every
editor open/close — fresh baseline each time

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gmer4Lfe
2026-05-31 20:54:42 -04:00
co-authored by Claude Sonnet 4.6
parent 4722382d49
commit 1ea3f595cc
2 changed files with 124 additions and 8 deletions
+6
View File
@@ -394,6 +394,12 @@
.vv-es-sel { color: #555; }
.vv-es-lang { margin-left: auto; color: #4a6a7a; }
/* Undo / Redo buttons */
.vv-undo-redo-btn { border-color: #444 !important; color: #666 !important; }
.vv-undo-redo-btn:not([disabled]):hover { border-color: #777 !important; color: #ccc !important; background: #1e1e1e !important; }
.vv-undo-redo-btn[disabled] { opacity: 0.28 !important; cursor: default !important; pointer-events: none; }
.vv-undo-count { font-size: 10px; opacity: 0.7; margin-left: 2px; }
/* Suggestions panel — accordion */
#vv-suggestions { overflow-y: auto; }
.vv-sug-block { border-bottom: 1px solid #1e1e1e; }