Plugins: Make sure "replaceSelection" command can be undone in Rich Text editor

pull/4093/head
Laurent Cozic 2020-11-15 15:59:47 +00:00
parent ce59d29bb3
commit b480aae59b
1 changed files with 6 additions and 0 deletions

View File

@ -275,6 +275,12 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
editor.selection.setContent(value);
editor.fire('joplinChange');
dispatchDidUpdate(editor);
// It doesn't make sense but it seems calling setContent
// doesn't create an undo step so we need to call it
// manually.
// https://github.com/tinymce/tinymce/issues/3745
window.requestAnimationFrame(() => editor.undoManager.add());
},
};