Skip to content

Build your personal knowledge base with Trilium Notes

client: Improve code selection in note type

Elian Doran07170a5a3956
diff --git a/src/public/app/widgets/note_type.js b/src/public/app/widgets/note_type.js
index b26977ead5..66e699effb 100644
--- a/src/public/app/widgets/note_type.js
+++ b/src/public/app/widgets/note_type.js
@@ -70,25 +70,32 @@ export default class NoteTypeWidget extends NoteContextAwareWidget {
this.$noteTypeDropdown.empty();
for (const noteType of NOTE_TYPES.filter(nt => nt.selectable)) {
- const $typeLink = $('<a class="dropdown-item">')
- .attr("data-note-type", noteType.type)
- .append('<span class="check">&check;</span> ')
- .append($('<span>').text(noteType.title))
- .on('click', e => {
- const type = $typeLink.attr('data-note-type');
- const noteType = NOTE_TYPES.find(nt => nt.type === type);
-
- this.save(noteType.type, noteType.mime);
- });
-
+ let $typeLink;
+
+ if (noteType.type !== "code") {
+ $typeLink = $('<a class="dropdown-item">')
+ .attr("data-note-type", noteType.type)
+ .append('<span class="check">&check;</span> ')
+ .append($('<span>').text(noteType.title))
+ .on('click', e => {
+ const type = $typeLink.attr('data-note-type');
+ const noteType = NOTE_TYPES.find(nt => nt.type === type);
+
+ this.save(noteType.type, noteType.mime);
+ });
+ } else {
+ this.$noteTypeDropdown
+ .append('<div class="dropdown-divider"></div>');
+ $typeLink = $('<a class="dropdown-item disabled">')
+ .attr("data-note-type", noteType.type)
+ .append('<span class="check">&check;</span> ')
+ .append($('<strong>').text(noteType.title));
+ }
+
if (this.note.type === noteType.type) {
$typeLink.addClass("selected");
}
- if (noteType.type === 'code') {
- this.$noteTypeDropdown.append('<div class="dropdown-divider"></div>');
- }
-
this.$noteTypeDropdown.append($typeLink);
}