How to tell TinyMCE UndoManager to ignore changes until explicitly notified to resume?

222 Views Asked by At

Is it possible to use TinyMCE's UndoManager.ignore() when the callback is an asynchronous process?

What I am looking for is a way to "start ignoring" and a way to "stop ignoring".

(The background is that I have an async post-process that modifies the editor content, but I don't want those modifications to be part of the Undo/Redo stack, since they are not user-generated.)

This doesn't work, because the ignore() block callback finishes promise is resolved:

editor.undoManager.ignore(function() {
    doAsyncProcess(editor).then(function() {
        // doesn't work
    });
}

What I want is something like this:

editor.undoManager.startIgnoring();
doAsyncProcess(editor).then(function() {
    editor.undoManager.stopIgnoring();
});

but of course those APIs do not exist. Is there a workaround for this?

1

There are 1 best solutions below

0
On

What I am looking for is a way to "start ignoring" and a way to "stop ignoring".

It is hardly implementable. Mainly, because it may break something. Imagine the situation when something outside your process that needs a new undo level happened during that 'ignore time'.

Generally, all editor content operations within TinyMCE need to be synchronous. So the solution there is to normally get all the data needed asynchronously and then apply the update once it’s all been fetched.