trilium/src/public/javascripts/widgets/note_info.js

77 lines
2.1 KiB
JavaScript
Raw Normal View History

import StandardWidget from "./standard_widget.js";
2019-07-21 17:32:38 +08:00
const TPL = `
<table class="note-info-widget-table">
<style>
.note-info-widget-table {
table-layout: fixed;
width: 100%;
}
.note-info-widget-table td, .note-info-widget-table th {
padding: 5px;
}
</style>
2019-07-21 17:32:38 +08:00
<tr>
<th nowrap>Note ID:</th>
<td nowrap colspan="3" class="note-info-note-id"></td>
2019-07-21 17:32:38 +08:00
</tr>
<tr>
<th nowrap>Created:</th>
<td nowrap colspan="3" style="overflow: hidden; text-overflow: ellipsis;" class="note-info-date-created"></td>
2019-07-21 17:32:38 +08:00
</tr>
<tr>
<th nowrap>Modified:</th>
<td nowrap colspan="3" style="overflow: hidden; text-overflow: ellipsis;" class="note-info-date-modified"></td>
2019-07-21 17:32:38 +08:00
</tr>
<tr>
<th>Type:</th>
2019-07-21 17:32:38 +08:00
<td class="note-info-type"></td>
<th>MIME:</th>
2019-07-21 17:32:38 +08:00
<td class="note-info-mime"></td>
</tr>
</table>
`;
class NoteInfoWidget extends StandardWidget {
2019-08-17 16:45:20 +08:00
getWidgetTitle() { return "Note info"; }
2019-07-21 17:32:38 +08:00
doRenderBody() {
this.$body.html(TPL);
}
2019-07-21 17:32:38 +08:00
2020-02-01 18:33:31 +08:00
async refreshWithNote(note) {
const $noteId = this.$body.find(".note-info-note-id");
const $dateCreated = this.$body.find(".note-info-date-created");
const $dateModified = this.$body.find(".note-info-date-modified");
const $type = this.$body.find(".note-info-type");
const $mime = this.$body.find(".note-info-mime");
2019-07-21 17:32:38 +08:00
2020-02-01 18:33:31 +08:00
const noteComplement = await this.tabContext.getNoteComplement();
2019-07-21 17:32:38 +08:00
$noteId.text(note.noteId);
$dateCreated
2020-02-01 18:15:58 +08:00
.text(noteComplement.dateCreated)
.attr("title", noteComplement.dateCreated);
$dateModified
2020-02-01 18:15:58 +08:00
.text(noteComplement.dateModified)
.attr("title", noteComplement.dateCreated);
2019-07-21 17:32:38 +08:00
$type.text(note.type);
$mime
.text(note.mime)
.attr("title", note.mime);
2019-07-21 17:32:38 +08:00
}
syncDataListener({data}) {
2020-01-21 03:51:22 +08:00
if (data.find(sd => sd.entityName === 'notes' && this.isNote(sd.entityId))) {
this.refresh();
}
}
2019-07-21 17:32:38 +08:00
}
export default NoteInfoWidget;