mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
client: Improve code selection in note type
This commit is contained in:
parent
13860a3f16
commit
07170a5a39
@ -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">✓</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);
|
||||
let $typeLink;
|
||||
|
||||
this.save(noteType.type, noteType.mime);
|
||||
});
|
||||
if (noteType.type !== "code") {
|
||||
$typeLink = $('<a class="dropdown-item">')
|
||||
.attr("data-note-type", noteType.type)
|
||||
.append('<span class="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">✓</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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user