Closed cptiwari20 closed 10 months ago
temporary solution I found,
const handleUndo = (e, isUndo = true) => {
try {
e.preventDefault();
const event = new KeyboardEvent("keydown", {
// bubbles: true,
cancelable: true,
key: "z",
metaKey: /(Mac)/i.test(navigator.platform) ? true : false,
ctrlKey: /(Mac)/i.test(navigator.platform) ? false : true,
shiftKey: !isUndo,
});
document.getElementById("editorjs").dispatchEvent(event);
} catch (error) {
console.error("Error while Undo/Redo ", error);
}
};
@cptiwari20 Thank you for reporting the issue. To utilize the 'Undo' and 'Redo' functions outside of the plugin, you can assign a variable to the 'Undo' instance within the onReady() callback. Then, you can employ this variable anywhere within your code. For a practical example, please refer to the CodeSandbox demonstration provided.
Please let us know if this solution proves helpful to you.
Feature
I want to handle the Undo and Redo using a custom button inside or outside the editors,
Describe the solution you'd like
If there will be an event handler for undo library that would be very helpful.
If you have any existing solution for this, please tell me, I am not able to find it so far.