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

55 lines
1.5 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-table">
<tr>
<th>Note ID:</th>
<td colspan="3" class="note-info-note-id"></td>
2019-07-21 17:32:38 +08:00
</tr>
<tr>
<th>Created:</th>
<td colspan="3" class="note-info-date-created"></td>
2019-07-21 17:32:38 +08:00
</tr>
<tr>
<th>Modified:</th>
<td colspan="3" 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
async doRenderBody() {
this.$body.html(TPL);
2019-07-21 17:32:38 +08:00
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
const note = this.ctx.note;
$noteId.text(note.noteId);
$dateCreated.text(note.dateCreated);
$dateModified.text(note.dateModified);
$type.text(note.type);
$mime.text(note.mime);
}
syncDataReceived(syncData) {
if (syncData.find(sd => sd.entityName === 'notes' && sd.entityId === this.ctx.note.noteId)) {
this.doRenderBody();
}
}
2019-07-21 17:32:38 +08:00
}
export default NoteInfoWidget;