mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-11 18:24:43 +02:00
Fix #119
Fix the bug that permit to undo changes from different notes. I save the editor instance into the state and in the componentWillReceiveProps i reset the undo state
This commit is contained in:
parent
0926755635
commit
0bf5c9ebdd
@ -37,6 +37,7 @@ class NoteTextComponent extends React.Component {
|
||||
webviewReady: false,
|
||||
scrollHeight: null,
|
||||
editorScrollTop: 0,
|
||||
editor:null
|
||||
};
|
||||
|
||||
this.lastLoadedNoteId_ = null;
|
||||
@ -167,6 +168,13 @@ class NoteTextComponent extends React.Component {
|
||||
async componentWillReceiveProps(nextProps) {
|
||||
if ('noteId' in nextProps && nextProps.noteId !== this.props.noteId) {
|
||||
await this.reloadNote(nextProps);
|
||||
const editor=this.state.editor;
|
||||
if(editor){
|
||||
const session = editor.getSession();
|
||||
const undoManager = session.getUndoManager();
|
||||
undoManager.reset();
|
||||
session.setUndoManager(undoManager);
|
||||
}
|
||||
}
|
||||
|
||||
if ('syncStarted' in nextProps && !nextProps.syncStarted && !this.isModified()) {
|
||||
@ -334,6 +342,10 @@ class NoteTextComponent extends React.Component {
|
||||
this.scheduleSave();
|
||||
}
|
||||
|
||||
aceEditor_onLoad(editor){
|
||||
this.setState({editor:editor});
|
||||
}
|
||||
|
||||
async commandAttachFile() {
|
||||
const noteId = this.props.noteId;
|
||||
if (!noteId) return;
|
||||
@ -549,7 +561,6 @@ class NoteTextComponent extends React.Component {
|
||||
delete editorRootStyle.width;
|
||||
delete editorRootStyle.height;
|
||||
delete editorRootStyle.fontSize;
|
||||
|
||||
const editor = <AceEditor
|
||||
value={body}
|
||||
mode="markdown"
|
||||
@ -559,6 +570,7 @@ class NoteTextComponent extends React.Component {
|
||||
height={editorStyle.height + 'px'}
|
||||
fontSize={editorStyle.fontSize}
|
||||
showGutter={false}
|
||||
onLoad={editor => this.aceEditor_onLoad.bind(this)(editor)}
|
||||
name="note-editor"
|
||||
wrapEnabled={true}
|
||||
onScroll={(event) => { this.editor_scroll(); }}
|
||||
|
Loading…
Reference in New Issue
Block a user