assets/js/markdown.js (insertMarkdownFormat, insertMarkdownText, toolbarList, toolbarHeading, toolbarQuote, ~lines 360-503) all set textarea.value = ... directly. Assigning .value programmatically discards the browser's native undo stack (vs. document.execCommand('insertText', ...), which preserves it).
Repro: Type a paragraph, click Bold on a selection, then press Ctrl+Z — instead of undoing just the bold markup, the entire typed paragraph disappears (or undo does nothing further), because the whole prior undo history was wiped the moment the toolbar action ran.
Fix: Replace the direct .value = assignment in these toolbar handlers with document.execCommand('insertText', false, newText) (with a fallback to the current approach for browsers where execCommand is unavailable/deprecated) to preserve native undo/redo.
**Severity:** Medium
`assets/js/markdown.js` (`insertMarkdownFormat`, `insertMarkdownText`, `toolbarList`, `toolbarHeading`, `toolbarQuote`, ~lines 360-503) all set `textarea.value = ...` directly. Assigning `.value` programmatically discards the browser's native undo stack (vs. `document.execCommand('insertText', ...)`, which preserves it).
**Repro:** Type a paragraph, click Bold on a selection, then press Ctrl+Z — instead of undoing just the bold markup, the entire typed paragraph disappears (or undo does nothing further), because the whole prior undo history was wiped the moment the toolbar action ran.
**Fix:** Replace the direct `.value =` assignment in these toolbar handlers with `document.execCommand('insertText', false, newText)` (with a fallback to the current approach for browsers where `execCommand` is unavailable/deprecated) to preserve native undo/redo.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Severity: Medium
assets/js/markdown.js(insertMarkdownFormat,insertMarkdownText,toolbarList,toolbarHeading,toolbarQuote, ~lines 360-503) all settextarea.value = ...directly. Assigning.valueprogrammatically discards the browser's native undo stack (vs.document.execCommand('insertText', ...), which preserves it).Repro: Type a paragraph, click Bold on a selection, then press Ctrl+Z — instead of undoing just the bold markup, the entire typed paragraph disappears (or undo does nothing further), because the whole prior undo history was wiped the moment the toolbar action ran.
Fix: Replace the direct
.value =assignment in these toolbar handlers withdocument.execCommand('insertText', false, newText)(with a fallback to the current approach for browsers whereexecCommandis unavailable/deprecated) to preserve native undo/redo.