Ace editor. Set current edits state as base

557 Views Asked by At

I'm using ace editor wrapped by react-ace for my project.

How can I destroy all undo/redo history in certain moment when I need it?

I've tried this.aceRef.editor.destroy(); (just react ref bound with editor), but unfortunately it doesn't play well in some circumstances. So, I just need to clean undo/redo session/history or something like that.

Any solution?

1

There are 1 best solutions below

0
Lim Kayas On BEST ANSWER

Ace editor actually has this reset method with UndoManager.

Then you need to assign temporary stored undomanager as base.

It could be done smth like that:

const { editor } = this.aceRef;
const session = editor.getSession();
const undoManager = session.getUndoManager();
undoManager.reset();
session.setUndoManager(undoManager);