diff --git a/src/public/app/services/utils.js b/src/public/app/services/utils.js index 49edcf5ec..2041551f1 100644 --- a/src/public/app/services/utils.js +++ b/src/public/app/services/utils.js @@ -114,6 +114,17 @@ function formatLabel(label) { return str; } +function formatSize(size) { + size = Math.max(Math.round(size / 1024), 1); + + if (size < 1024) { + return `${size} KiB`; + } + else { + return `${Math.round(size / 102.4) / 10} MiB`; + } +} + function toObject(array, fn) { const obj = {}; @@ -363,6 +374,7 @@ export default { formatDate, formatDateISO, formatDateTime, + formatSize, localNowDateTime, now, isElectron, diff --git a/src/public/app/widgets/buttons/attachments_actions.js b/src/public/app/widgets/buttons/attachments_actions.js new file mode 100644 index 000000000..1fc1983b5 --- /dev/null +++ b/src/public/app/widgets/buttons/attachments_actions.js @@ -0,0 +1,95 @@ +import BasicWidget from "../basic_widget.js"; + +const TPL = ` +
`; + +export default class AttachmentActionsWidget extends BasicWidget { + constructor(attachment) { + super(); + + this.attachment = attachment; + } + + doRender() { + this.$widget = $(TPL); + + // this.$findInTextButton = this.$widget.find('.find-in-text-button'); + // this.$printActiveNoteButton = this.$widget.find('.print-active-note-button'); + // this.$showSourceButton = this.$widget.find('.show-source-button'); + // this.$renderNoteButton = this.$widget.find('.render-note-button'); + // + // this.$exportNoteButton = this.$widget.find('.export-note-button'); + // this.$exportNoteButton.on("click", () => { + // if (this.$exportNoteButton.hasClass("disabled")) { + // return; + // } + // + // this.triggerCommand("showExportDialog", { + // notePath: this.noteContext.notePath, + // defaultType: "single" + // }); + // }); + // + // this.$importNoteButton = this.$widget.find('.import-files-button'); + // this.$importNoteButton.on("click", () => this.triggerCommand("showImportDialog", {noteId: this.noteId})); + // + // this.$widget.on('click', '.dropdown-item', () => this.$widget.find("[data-toggle='dropdown']").dropdown('toggle')); + // + // this.$openNoteExternallyButton = this.$widget.find(".open-note-externally-button"); + // + // this.$deleteNoteButton = this.$widget.find(".delete-note-button"); + // this.$deleteNoteButton.on("click", () => { + // if (this.note.noteId === 'root') { + // return; + // } + // + // branchService.deleteNotes([this.note.getParentBranches()[0].branchId], true); + // }); + } + + refreshWithNote(note) { + // this.toggleDisabled(this.$findInTextButton, ['text', 'code', 'book', 'search'].includes(note.type)); + // + // this.toggleDisabled(this.$showSourceButton, ['text', 'relationMap', 'mermaid'].includes(note.type)); + // + // this.toggleDisabled(this.$printActiveNoteButton, ['text', 'code'].includes(note.type)); + // + // this.$renderNoteButton.toggle(note.type === 'render'); + // + // this.$openNoteExternallyButton.toggle(utils.isElectron()); + } + + toggleDisabled($el, enable) { + if (enable) { + $el.removeAttr('disabled'); + } else { + $el.attr('disabled', 'disabled'); + } + } +} diff --git a/src/public/app/widgets/floating_buttons/zpetne_odkazy.js b/src/public/app/widgets/floating_buttons/zpetne_odkazy.js index ec896cca5..7d3c76ca3 100644 --- a/src/public/app/widgets/floating_buttons/zpetne_odkazy.js +++ b/src/public/app/widgets/floating_buttons/zpetne_odkazy.js @@ -85,6 +85,11 @@ export default class BacklinksWidget extends NoteContextAwareWidget { async refreshWithNote(note) { this.clearItems(); + if (this.noteContext?.viewScope?.viewMode !== 'default') { + this.toggle(false); + return; + } + // can't use froca since that would count only relations from loaded notes const resp = await server.get(`note-map/${this.noteId}/backlink-count`); diff --git a/src/public/app/widgets/note_title.js b/src/public/app/widgets/note_title.js index 29ebd1f35..83a5e8a15 100644 --- a/src/public/app/widgets/note_title.js +++ b/src/public/app/widgets/note_title.js @@ -70,10 +70,16 @@ export default class NoteTitleWidget extends NoteContextAwareWidget { } async refreshWithNote(note) { - this.$noteTitle.val(note.title); + const viewMode = this.noteContext.viewScope.viewMode; + this.$noteTitle.val(viewMode === 'default' + ? note.title + : `${viewMode}: ${note.title}`); - this.$noteTitle.prop("readonly", (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) - || ['_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(note.noteId)); + this.$noteTitle.prop("readonly", + (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) + || ['_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(note.noteId) + || viewMode !== 'default' + ); this.setProtectedStatus(note); } diff --git a/src/public/app/widgets/ribbon_widgets/note_info_widget.js b/src/public/app/widgets/ribbon_widgets/note_info_widget.js index 28459da5d..c463c9c0d 100644 --- a/src/public/app/widgets/ribbon_widgets/note_info_widget.js +++ b/src/public/app/widgets/ribbon_widgets/note_info_widget.js @@ -1,5 +1,6 @@ import NoteContextAwareWidget from "../note_context_aware_widget.js"; import server from "../../services/server.js"; +import utils from "../../services/utils.js"; const TPL = `