mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
Merge pull request #3709 from PJB3005/23-03-14-mermaid-code-mode
Avoid EditableCode inheriting mode from previous notes.
This commit is contained in:
commit
af4470ead1
@ -77,12 +77,15 @@ export default class EditableCodeTypeWidget extends TypeWidget {
|
|||||||
this.codeEditor.setValue(noteComplement.content || "");
|
this.codeEditor.setValue(noteComplement.content || "");
|
||||||
this.codeEditor.clearHistory();
|
this.codeEditor.clearHistory();
|
||||||
|
|
||||||
const info = CodeMirror.findModeByMIME(note.mime);
|
let info = CodeMirror.findModeByMIME(note.mime);
|
||||||
|
if (!info) {
|
||||||
if (info) {
|
// Switch back to plain text if CodeMirror does not have a mode for whatever MIME type we're editing.
|
||||||
this.codeEditor.setOption("mode", info.mime);
|
// To avoid inheriting a mode from a previously open code note.
|
||||||
CodeMirror.autoLoadMode(this.codeEditor, info.mode);
|
info = CodeMirror.findModeByMIME("text/plain");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.codeEditor.setOption("mode", info.mime);
|
||||||
|
CodeMirror.autoLoadMode(this.codeEditor, info.mode);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.show();
|
this.show();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user