How to make changes to a document in DesignMode programmatically so that they can be undone? #4039
Unanswered
techNIKtos
asked this question in
Q&A
Replies: 2 comments
-
Thanks for reaching out. I've assigned this to a dev that can follow up on this. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Sorry for the late reply. We are looking for this now. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
How can I change the document loaded into WebView2 programmatically (DesignMode) so that these changes are included in the input history and then they could be undone using the 'Ctrl+Z' hotkey or context menu?
Version
SDK: 1.0.1462.37
Framework: Winforms
OS: Windows 10
My use case: I use WebView2 in DesignMode as an HTML editor. It works well. But I have an issue: when I change the content, it is not added to the input history, and undo/redo is not worked with these changes.
I used 'getSelection', 'clipboard', 'appendChild', 'insertBefore', etc. in the script. And all changes made in this way cannot be undone using 'Ctrl+Z'. I didn't find API for a built-in UndoManager and the implementation of custom UndoManager can be problematic and related to other issues, for example, how to link together built-in undo/redo feature and the custom UndoManager.
I found that if I use 'execCommand' instead, than undo/redo will work. But the execCommand is marked as deprecated. Is it safe to use the 'execCommand' in the script for WebView2 now, or is there an alternative way to achieve the desired behavior?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions