mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	added options to disable auto-opening of promoted attributes and edited notes ribbon tabs, closes #4151
This commit is contained in:
		
							parent
							
								
									4240da349d
								
							
						
					
					
						commit
						a9cdd93cb4
					
				| @ -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' | ||||
|         }; | ||||
|  | ||||
| @ -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" | ||||
|         }; | ||||
|  | ||||
| @ -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: [ | ||||
|  | ||||
| @ -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); | ||||
|     } | ||||
| } | ||||
| @ -55,7 +55,9 @@ const ALLOWED_OPTIONS = new Set([ | ||||
|     'eraseUnusedAttachmentsAfterSeconds', | ||||
|     'disableTray', | ||||
|     'customSearchEngineName', | ||||
|     'customSearchEngineUrl' | ||||
|     'customSearchEngineUrl', | ||||
|     'promotedAttributesOpenInRibbon', | ||||
|     'editedNotesOpenInRibbon' | ||||
| ]); | ||||
| 
 | ||||
| function getOptions() { | ||||
|  | ||||
| @ -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() { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam