Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
added options to disable auto-opening of promoted attributes and edited notes ribbon tabs, closes #4151
zadama9cdd93cb425
diff --git a/src/public/app/widgets/ribbon_widgets/edited_notes.js b/src/public/app/widgets/ribbon_widgets/edited_notes.jsindex 2cf1f4898b..928cfcd060 100644--- a/src/public/app/widgets/ribbon_widgets/edited_notes.js+++ b/src/public/app/widgets/ribbon_widgets/edited_notes.js@@ -2,6 +2,7 @@ import linkService from "../../services/link.js";import server from "../../services/server.js";import froca from "../../services/froca.js";import NoteContextAwareWidget from "../note_context_aware_widget.js";+import options from "../../services/options.js";const TPL = `<div class="edited-notes-widget">@@ -34,7 +35,9 @@ export default class EditedNotesWidget extends NoteContextAwareWidget {return {show: this.isEnabled(),// promoted attributes have priority over edited notes- activate: this.note.getPromotedDefinitionAttributes().length === 0,+ activate:+ (this.note.getPromotedDefinitionAttributes().length === 0 || !options.is('promotedAttributesOpenInRibbon'))+ && options.is('editedNotesOpenInRibbon'),title: 'Edited Notes',icon: 'bx bx-calendar-edit'};diff --git a/src/public/app/widgets/ribbon_widgets/promoted_attributes.js b/src/public/app/widgets/ribbon_widgets/promoted_attributes.jsindex a346d76d57..2af4498154 100644--- a/src/public/app/widgets/ribbon_widgets/promoted_attributes.js+++ b/src/public/app/widgets/ribbon_widgets/promoted_attributes.js@@ -4,6 +4,7 @@ import treeService from "../../services/tree.js";import noteAutocompleteService from "../../services/note_autocomplete.js";import NoteContextAwareWidget from "../note_context_aware_widget.js";import attributeService from "../../services/attributes.js";+import options from "../../services/options.js";const TPL = `<div>@@ -62,7 +63,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {return {show: true,- activate: true,+ activate: options.is('promotedAttributesOpenInRibbon'),title: "Promoted Attributes",icon: "bx bx-table"};diff --git a/src/public/app/widgets/type_widgets/content_widget.js b/src/public/app/widgets/type_widgets/content_widget.jsindex 0529768f5e..fe7f105afb 100644--- a/src/public/app/widgets/type_widgets/content_widget.js+++ b/src/public/app/widgets/type_widgets/content_widget.js@@ -31,6 +31,7 @@ import VacuumDatabaseOptions from "./options/advanced/vacuum_database.js";import DatabaseAnonymizationOptions from "./options/advanced/database_anonymization.js";import BackendLogWidget from "./content/backend_log.js";import AttachmentErasureTimeoutOptions from "./options/other/attachment_erasure_timeout.js";+import RibbonOptions from "./options/appearance/ribbon.js";const TPL = `<div class="note-detail-content-widget note-detail-printable"><style>@@ -57,7 +58,8 @@ const CONTENT_WIDGETS = {FontsOptions,ZoomFactorOptions,NativeTitleBarOptions,- MaxContentWidthOptions+ MaxContentWidthOptions,+ RibbonOptions],_optionsShortcuts: [ KeyboardShortcutsOptions ],_optionsTextNotes: [diff --git a/src/public/app/widgets/type_widgets/options/appearance/ribbon.js b/src/public/app/widgets/type_widgets/options/appearance/ribbon.jsnew file mode 100644index 0000000000..6fe2466473--- /dev/null+++ b/src/public/app/widgets/type_widgets/options/appearance/ribbon.js@@ -0,0 +1,34 @@+import OptionsWidget from "../options_widget.js";++const TPL = `+<div class="options-section">+ <h4>Ribbon widgets</h4>+ <label>+ <input type="checkbox" class="promoted-attributes-open-in-ribbon">+ Promoted Attributes ribbon tab will automatically open if promoted attributes are present on the note+ </label>++ <label>+ <input type="checkbox" class="edited-notes-open-in-ribbon">+ Edited Notes ribbon tab will automatically open on day notes+ </label>+</div>`;++export default class RibbonOptions extends OptionsWidget {+ doRender() {+ this.$widget = $(TPL);++ this.$promotedAttributesOpenInRibbon = this.$widget.find(".promoted-attributes-open-in-ribbon");+ this.$promotedAttributesOpenInRibbon.on('change', () =>+ this.updateCheckboxOption('promotedAttributesOpenInRibbon', this.$promotedAttributesOpenInRibbon));++ this.$editedNotesOpenInRibbon = this.$widget.find(".edited-notes-open-in-ribbon");+ this.$editedNotesOpenInRibbon.on('change', () =>+ this.updateCheckboxOption('editedNotesOpenInRibbon', this.$editedNotesOpenInRibbon));+ }++ async optionsLoaded(options) {+ this.setCheckboxState(this.$promotedAttributesOpenInRibbon, options.promotedAttributesOpenInRibbon);+ this.setCheckboxState(this.$editedNotesOpenInRibbon, options.editedNotesOpenInRibbon);+ }+}diff --git a/src/routes/api/options.js b/src/routes/api/options.jsindex 708b89ac1f..a04f54306a 100644--- a/src/routes/api/options.js+++ b/src/routes/api/options.js@@ -55,7 +55,9 @@ const ALLOWED_OPTIONS = new Set(['eraseUnusedAttachmentsAfterSeconds','disableTray','customSearchEngineName',- 'customSearchEngineUrl'+ 'customSearchEngineUrl',+ 'promotedAttributesOpenInRibbon',+ 'editedNotesOpenInRibbon']);function getOptions() {diff --git a/src/services/options_init.js b/src/services/options_init.jsindex 714f912d90..7ed31b3434 100644--- a/src/services/options_init.js+++ b/src/services/options_init.js@@ -88,7 +88,9 @@ const defaultOptions = [{ name: 'disableTray', value: 'false', isSynced: false },{ name: 'eraseUnusedAttachmentsAfterSeconds', value: '2592000', isSynced: true },{ name: 'customSearchEngineName', value: 'DuckDuckGo', isSynced: true },- { name: 'customSearchEngineUrl', value: 'https://duckduckgo.com/?q={keyword}', isSynced: true }+ { name: 'customSearchEngineUrl', value: 'https://duckduckgo.com/?q={keyword}', isSynced: true },+ { name: 'promotedAttributesOpenInRibbon', value: 'true', isSynced: true },+ { name: 'editedNotesOpenInRibbon', value: 'true', isSynced: true }];function initStartupOptions() {