I haven't solved the problem, but maybe this is the best I can do without reinstalling the story as @Rishat mentioned (if I'm wrong, let me know).
Thanks to this answer , I understood this command:
document.execCommand("insertText", false, text);
This basically inserts text at the current focused input at the current caret position (why don't you pass the input as a parameter). And, of course, this function updates the history accordingly.
If I wanted to, I could coordinate each insert (e.g. ** mentioned in the question) so that everything was in the story. However, this would be too difficult because each markdown team has a different behavior. That would be too complicated.
Decision:
The following code should be included in componentDidUpdate and should only be executed after the text has been changed programmatically :
the effect
Ctrl + Z works fine, but if you keep coming back until the input time has been changed programmatically, it will select all the text. I mean, the story is saved, but at the cost of clutter with the choice if you return enough. I believe this is good enough, better than reimplementing the input story.
Demo
André pena
source share