mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-11 18:24:43 +02:00
Desktop: TinyMCE: Fixed undo issue when pasting text
This commit is contained in:
parent
f2a1597ecc
commit
d65706aa9c
@ -669,7 +669,11 @@ const TinyMCE = (props:NoteBodyEditorProps, ref:any) => {
|
||||
// - Make a change
|
||||
// - Load note 2
|
||||
// - Undo => content is that of note 1
|
||||
editor.undoManager.clear();
|
||||
|
||||
// The doc is not very clear what's the different between
|
||||
// clear() and reset() but it seems reset() works best, in
|
||||
// particular for the onPaste bug.
|
||||
editor.undoManager.reset();
|
||||
|
||||
dispatchDidUpdate(editor);
|
||||
};
|
||||
@ -780,6 +784,11 @@ const TinyMCE = (props:NoteBodyEditorProps, ref:any) => {
|
||||
const result = await markupToHtml.current(MarkupToHtml.MARKUP_LANGUAGE_MARKDOWN, pastedText, markupRenderOptions({ bodyOnly: true }));
|
||||
editor.insertContent(result.html);
|
||||
} else {
|
||||
// HACK: TinyMCE doesn't add an undo step when pasting, for unclear reasons
|
||||
// so we manually add it here. We also can't do it immediately it seems, or
|
||||
// else nothing is added to the stack, so do it on the next frame.
|
||||
window.requestAnimationFrame(() => editor.undoManager.add());
|
||||
|
||||
onChangeHandler();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user