mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-28 02:22:26 +08:00
refactor(code): use dedicated method for setting text
This commit is contained in:
parent
0c9be9291b
commit
ef312c9550
@ -56,13 +56,7 @@ export default class AbstractCodeTypeWidget extends TypeWidget {
|
|||||||
* @param {*} content the new content of the note.
|
* @param {*} content the new content of the note.
|
||||||
*/
|
*/
|
||||||
_update(note: { mime: string }, content: string) {
|
_update(note: { mime: string }, content: string) {
|
||||||
this.codeEditor.dispatch({
|
this.codeEditor.setText(content);
|
||||||
changes: {
|
|
||||||
from: 0,
|
|
||||||
to: this.codeEditor.state.doc.length,
|
|
||||||
insert: content || "",
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// this.codeEditor.clearHistory();
|
// this.codeEditor.clearHistory();
|
||||||
|
|
||||||
// let info = CodeMirror.findModeByMIME(note.mime);
|
// let info = CodeMirror.findModeByMIME(note.mime);
|
||||||
|
@ -11,4 +11,14 @@ export default class CodeMirror extends EditorView {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setText(content: string) {
|
||||||
|
this.dispatch({
|
||||||
|
changes: {
|
||||||
|
from: 0,
|
||||||
|
to: this.state.doc.length,
|
||||||
|
insert: content || "",
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user