From b480aae59b37eefcb70b07c07266d052f864459c Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 15 Nov 2020 15:59:47 +0000 Subject: [PATCH] Plugins: Make sure "replaceSelection" command can be undone in Rich Text editor --- .../app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx b/packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx index bd4f449fbb..af6c1ac6fc 100644 --- a/packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx +++ b/packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx @@ -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()); }, };