Skip to content

Build your personal knowledge base with Trilium Notes

fix(code): syntax highlighting not working in read-only code

Elian Doranc24e1f0ec50e
diff --git a/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts b/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts
index e769015777..6dd68139a0 100644
--- a/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts
+++ b/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts
@@ -61,6 +61,7 @@ export default class AbstractCodeTypeWidget extends TypeWidget {
*/
_update(note: FNote, content: string) {
this.codeEditor.setText(content);
+ this.codeEditor.setMimeType(note.mime);
this.codeEditor.clearHistory();
}
diff --git a/apps/client/src/widgets/type_widgets/editable_code.ts b/apps/client/src/widgets/type_widgets/editable_code.ts
index 339caada85..b60e8e422b 100644
--- a/apps/client/src/widgets/type_widgets/editable_code.ts
+++ b/apps/client/src/widgets/type_widgets/editable_code.ts
@@ -66,7 +66,6 @@ export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget {
this._update(note, blob?.content ?? "");
});
- this.codeEditor.setMimeType(note.mime);
this.show();
if (this.parent && hasTouchBar) {