# הוסף תמיכה טובה יותר בביטול בעת הכנסת טקסט מעוצב

**URL:** <https://meta.discourse.org/t/add-better-undo-support-when-inserting-formatted-text/214821>\
**Category:** Feature\
**Created:** [14 בינואר,‏ 2022,‏ 4:16am UTC](https://meta.discourse.org/t/add-better-undo-support-when-inserting-formatted-text/214821 "2022-01-14T04:16:44Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)\
**Post date:** [14 בינואר,‏ 2022,‏ 7:02pm UTC](https://meta.discourse.org/t/add-better-undo-support-when-inserting-formatted-text/214821/3 "2022-01-14T19:02:46Z")

</div>

Right, undo doesn’t work by default whenever you use JavaScript to modify an input. But I googled around and found that [`document.execCommand`](https://stackoverflow.com/questions/27027833/is-it-possible-to-edit-a-text-input-with-javascript-and-add-to-the-undo-stack) can insert text while appending to the undo stack.

For example, if you do `document.getElementById('myInput').value = 'asd'` and then Ctrl+Z, it won’t undo.

But if you do `document.execCommand('insertText', false, 'asd')` while the cursor is where you want it (which it should be based on the current Discourse workflow), the text is properly inserted and Ctrl+Z will remove the added text as expected.

Basically, I’m wondering if `document.execCommand` (or some other process if another approach is considered better) can be used to append to the undo stack so Ctrl+Z works in these cases.

---

_[View the full topic](https://meta.discourse.org/t/add-better-undo-support-when-inserting-formatted-text/214821)._
