1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-13 00:10:37 +02:00

Desktop: WYSIWYG: Fix undo issue

This commit is contained in:
Laurent Cozic
2020-06-21 14:37:04 +01:00
parent 44024371ff
commit 254735fcae

View File

@ -779,17 +779,6 @@ const TinyMCE = (props:NoteBodyEditorProps, ref:any) => {
await loadDocumentAssets(editor, await props.allAssets(props.contentMarkupLanguage)); await loadDocumentAssets(editor, await props.allAssets(props.contentMarkupLanguage));
// Need to clear UndoManager to avoid this problem:
// - Load note 1
// - Make a change
// - Load note 2
// - Undo => content is that of note 1
// 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); dispatchDidUpdate(editor);
}; };
@ -800,6 +789,21 @@ const TinyMCE = (props:NoteBodyEditorProps, ref:any) => {
}; };
}, [editor, props.markupToHtml, props.allAssets, props.content, props.resourceInfos]); }, [editor, props.markupToHtml, props.allAssets, props.content, props.resourceInfos]);
useEffect(() => {
if (!editor) return;
// Need to clear UndoManager to avoid this problem:
// - Load note 1
// - Make a change
// - Load note 2
// - Undo => content is that of note 1
// 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();
}, [editor, props.contentKey]);
useEffect(() => { useEffect(() => {
if (!editor) return () => {}; if (!editor) return () => {};