import TabAwareWidget from "./tab_aware_widget.js"; const TPL = ` `; export default class NoteActionsWidget extends TabAwareWidget { doRender() { this.$widget = $(TPL); this.$showSourceButton = this.$widget.find('.show-source-button'); this.$exportNoteButton = this.$widget.find('.export-note-button'); this.$exportNoteButton.on("click", () => { if (this.$exportNoteButton.hasClass("disabled")) { return; } import('../dialogs/export.js').then(d => d.showDialog(this.tabContext.notePath, 'single')); }); this.$importNoteButton = this.$widget.find('.import-files-button'); this.$importNoteButton.on("click", () => import('../dialogs/import.js').then(d => d.showDialog(this.tabContext.note.noteId))); return this.$widget; } refreshWithNote(note) { this.$showSourceButton.prop('disabled', !['text', 'relation-map', 'search', 'code'].includes(note.type)); this.$exportNoteButton.prop('disabled', note.type !== 'text'); } triggerEvent(e, eventName) { const $item = $(e.target).closest('dropdown-item'); if ($item.is('[disabled]')) { return; } this.trigger(eventName); } }