Is there a native javascript API to manipulate the undo stack of HTML elements?

I created a contenteditable element in my page and during some events I update it by replacing the innerHTML. When I do that, the undo stack gets reset.

I found some recommendations to use the executeCommand api, but the MDN doc says it’s deprecated and does not offer an alternative.

  • Is there a way to update the innerHTML while keeping the undo stack intact?
  • Alternatively, is there a way to manipulate the undo stack of an element using javascript?