1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-17 18:44:45 +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,6 +779,19 @@ const TinyMCE = (props:NoteBodyEditorProps, ref:any) => {
await loadDocumentAssets(editor, await props.allAssets(props.contentMarkupLanguage));
dispatchDidUpdate(editor);
};
loadContent();
return () => {
cancelled = true;
};
}, [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
@ -789,16 +802,7 @@ const TinyMCE = (props:NoteBodyEditorProps, ref:any) => {
// clear() and reset() but it seems reset() works best, in
// particular for the onPaste bug.
editor.undoManager.reset();
dispatchDidUpdate(editor);
};
loadContent();
return () => {
cancelled = true;
};
}, [editor, props.markupToHtml, props.allAssets, props.content, props.resourceInfos]);
}, [editor, props.contentKey]);
useEffect(() => {
if (!editor) return () => {};