kommitters / editorjs-undo

Undo/Redo feature for Editor.js
https://www.npmjs.com/package/editorjs-undo
MIT License
165 stars 51 forks source link

How do I use api to trigger actions #218

Closed chf-gh closed 10 months ago

chf-gh commented 11 months ago

I want to use api to trigger undo/redo actions, what should I do?

MarioRodriguezS commented 10 months ago

@chf-gh Thank you for reporting the issue. To trigger undo or redo actions through the API you could assign a variable to the 'Undo' instance within the onReady() callback. Then, you can employ this variable anywhere within your code and do Undo.undo or Undo.redo. For a practical example, please refer to the CodeSandbox demonstration provided.

code sandbox example

Please let us know if this solution proves helpful to you.