From 4e76d1fa8534cfb7ba73558c60ad65bcbbb55cb6 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 12 Mar 2021 20:39:42 +0100 Subject: [PATCH 1/6] hide some "boring" attributes from book listing view --- package-lock.json | 2 +- src/public/app/services/attribute_renderer.js | 10 ++++++++++ .../app/widgets/attribute_widgets/attribute_detail.js | 2 +- src/public/app/widgets/note_detail.js | 2 +- src/routes/api/clipper.js | 2 +- src/services/attributes.js | 3 ++- src/services/note_cache/similarity.js | 1 - 7 files changed, 16 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index aebe0d41f..7efaa46d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "trilium", - "version": "0.46.3-beta", + "version": "0.46.4-beta", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/public/app/services/attribute_renderer.js b/src/public/app/services/attribute_renderer.js index 5212536d2..08120e754 100644 --- a/src/public/app/services/attribute_renderer.js +++ b/src/public/app/services/attribute_renderer.js @@ -79,6 +79,15 @@ async function renderAttributes(attributes, renderIsInheritable) { return $container; } +const HIDDEN_ATTRIBUTES = [ + 'originalFileName', + 'template', + 'cssClass', + 'iconClass', + 'pageSize', + 'viewType' +]; + async function renderNormalAttributes(note) { const promotedDefinitionAttributes = note.getPromotedDefinitionAttributes(); let attrs = note.getAttributes(); @@ -90,6 +99,7 @@ async function renderNormalAttributes(note) { attrs = attrs.filter( attr => !attr.isDefinition() && !attr.isAutoLink + && !HIDDEN_ATTRIBUTES.includes(attr.name) && attr.noteId === note.noteId ); } diff --git a/src/public/app/widgets/attribute_widgets/attribute_detail.js b/src/public/app/widgets/attribute_widgets/attribute_detail.js index b4f79ba6d..fefcc047e 100644 --- a/src/public/app/widgets/attribute_widgets/attribute_detail.js +++ b/src/public/app/widgets/attribute_widgets/attribute_detail.js @@ -194,7 +194,7 @@ const ATTR_HELP = { "appTheme": "marks CSS notes which are full Trilium themes and are thus available in Trilium options.", "cssClass": "value of this label is then added as CSS class to the node representing given note in the tree. This can be useful for advanced theming. Can be used in template notes.", "iconClass": "value of this label is added as a CSS class to the icon on the tree which can help visually distinguish the notes in the tree. Example might be bx bx-home - icons are taken from boxicons. Can be used in template notes.", - "bookZoomLevel": 'applies only to book note and sets the "zoom level" (how many notes fit on 1 row)', + "pageSize": "number of items per page in note listing", "customRequestHandler": 'see Custom request handler', "customResourceProvider": 'see Custom request handler' }, diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js index 5105c2481..f2cd6521b 100644 --- a/src/public/app/widgets/note_detail.js +++ b/src/public/app/widgets/note_detail.js @@ -278,7 +278,7 @@ export default class NoteDetailWidget extends TabAwareWidget { const label = attrs.find(attr => attr.type === 'label' - && ['readOnly', 'autoReadOnlyDisabled', 'cssClass', 'bookZoomLevel', 'displayRelations'].includes(attr.name) + && ['readOnly', 'autoReadOnlyDisabled', 'cssClass', 'displayRelations'].includes(attr.name) && attr.isAffecting(this.note)); const relation = attrs.find(attr => diff --git a/src/routes/api/clipper.js b/src/routes/api/clipper.js index 324b7c5bb..13b7a4496 100644 --- a/src/routes/api/clipper.js +++ b/src/routes/api/clipper.js @@ -106,7 +106,7 @@ function processContent(images, note, content) { for (const {src, dataUrl, imageId} of images) { const filename = path.basename(src); - if (!dataUrl.startsWith("data:image")) { + if (!dataUrl || !dataUrl.startsWith("data:image")) { log.info("Image could not be recognized as data URL:", dataUrl.substr(0, Math.min(100, dataUrl.length))); continue; } diff --git a/src/services/attributes.js b/src/services/attributes.js index 38832b958..3a684adbc 100644 --- a/src/services/attributes.js +++ b/src/services/attributes.js @@ -27,7 +27,6 @@ const BUILTIN_ATTRIBUTES = [ { type: 'label', name: 'run', isDangerous: true }, { type: 'label', name: 'customRequestHandler', isDangerous: true }, { type: 'label', name: 'customResourceProvider', isDangerous: true }, - { type: 'label', name: 'bookZoomLevel', isDangerous: false }, { type: 'label', name: 'widget', isDangerous: true }, { type: 'label', name: 'noteInfoWidgetDisabled' }, { type: 'label', name: 'linkMapWidgetDisabled' }, @@ -41,6 +40,8 @@ const BUILTIN_ATTRIBUTES = [ { type: 'label', name: 'hoistedSearchHome' }, { type: 'label', name: 'sqlConsoleHome' }, { type: 'label', name: 'datePattern' }, + { type: 'label', name: 'pageSize' }, + { type: 'label', name: 'viewType' }, // relation names { type: 'relation', name: 'runOnNoteCreation', isDangerous: true }, diff --git a/src/services/note_cache/similarity.js b/src/services/note_cache/similarity.js index 4fecae088..f5cf3b17d 100644 --- a/src/services/note_cache/similarity.js +++ b/src/services/note_cache/similarity.js @@ -23,7 +23,6 @@ const IGNORED_ATTR_NAMES = [ "archived", "hidepromotedattributes", "keyboardshortcut", - "bookzoomlevel", "noteinfowidgetdisabled", "linkmapwidgetdisabled", "noterevisionswidgetdisabled", From 584fea19921aa1a2c5911f4b977c642755625264 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 12 Mar 2021 20:44:19 +0100 Subject: [PATCH 2/6] Revert "delete notes skeleton dialog" This reverts commit 03a11e6f --- src/public/app/dialogs/delete_notes.js | 54 -------------------------- src/public/app/services/branches.js | 9 +++-- src/views/desktop.ejs | 1 - src/views/dialogs/delete_notes.ejs | 23 ----------- 4 files changed, 5 insertions(+), 82 deletions(-) delete mode 100644 src/public/app/dialogs/delete_notes.js delete mode 100644 src/views/dialogs/delete_notes.ejs diff --git a/src/public/app/dialogs/delete_notes.js b/src/public/app/dialogs/delete_notes.js deleted file mode 100644 index 35eb880f5..000000000 --- a/src/public/app/dialogs/delete_notes.js +++ /dev/null @@ -1,54 +0,0 @@ -const $dialog = $("#delete-notes-dialog"); -const $confirmContent = $("#delete-notes-dialog-content"); -const $okButton = $("#delete-notes-dialog-ok-button"); -const $cancelButton = $("#delete-notes-dialog-cancel-button"); -const $custom = $("#delete-notes-dialog-custom"); - -const DELETE_NOTE_BUTTON_ID = "delete-notes-dialog-delete-note"; - -let $originallyFocused; // element focused before the dialog was opened so we can return to it afterwards - -export function showDialog(message) { - $originallyFocused = $(':focus'); - - $custom.hide(); - - glob.activeDialog = $dialog; - - if (typeof message === 'string') { - message = $("
").text(message); - } - - $confirmContent.empty().append(message); - - $dialog.modal(); - - return new Promise((res, rej) => { resolve = res; }); -} - -export function isDeleteNoteChecked() { - return $("#" + DELETE_NOTE_BUTTON_ID + ":checked").length > 0; -} - -$dialog.on('shown.bs.modal', () => $okButton.trigger("focus")); - -$dialog.on("hidden.bs.modal", () => { - if (resolve) { - resolve(false); - } - - if ($originallyFocused) { - $originallyFocused.trigger('focus'); - $originallyFocused = null; - } -}); - -function doResolve(ret) { - resolve(ret); - resolve = null; - - $dialog.modal("hide"); -} - -$cancelButton.on('click', () => doResolve(false)); -$okButton.on('click', () => doResolve(true)); diff --git a/src/public/app/services/branches.js b/src/public/app/services/branches.js index 8f368626b..0ae9c0a96 100644 --- a/src/public/app/services/branches.js +++ b/src/public/app/services/branches.js @@ -74,9 +74,6 @@ async function deleteNotes(branchIdsToDelete) { return false; } - const deleteNotesDialog = await import("../dialogs/delete_notes.js"); - deleteNotesDialog.showDialog(); - const $deleteClonesCheckbox = $('
') .append($('')) .append($('