mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	option to configure if sidebar should be enabled in new tab
This commit is contained in:
		
							
								
								
									
										2
									
								
								db/migrations/0139__show_sidebar_in_new_tab.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								db/migrations/0139__show_sidebar_in_new_tab.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) | ||||
| VALUES ('showSidebarInNewTab', '1', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
| @@ -354,10 +354,18 @@ addTabHandler((async function () { | ||||
| addTabHandler((function() { | ||||
|     const $sidebarMinWidth = $("#sidebar-min-width"); | ||||
|     const $sidebarWidthPercent = $("#sidebar-width-percent"); | ||||
|     const $showSidebarInNewTab = $("#show-sidebar-in-new-tab"); | ||||
|  | ||||
|     async function optionsLoaded(options) { | ||||
|         $sidebarMinWidth.val(options.sidebarMinWidth); | ||||
|         $sidebarWidthPercent.val(options.sidebarWidthPercent); | ||||
|  | ||||
|         if (parseInt(options.showSidebarInNewTab)) { | ||||
|             $showSidebarInNewTab.attr("checked", "checked"); | ||||
|         } | ||||
|         else { | ||||
|             $showSidebarInNewTab.removeAttr("checked"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     function resizeSidebar() { | ||||
| @@ -385,6 +393,14 @@ addTabHandler((function() { | ||||
|         resizeSidebar(); | ||||
|     }); | ||||
|  | ||||
|     $showSidebarInNewTab.change(async function() { | ||||
|         const flag = $(this).is(":checked") ? 1 : 0; | ||||
|  | ||||
|         await server.put('options/showSidebarInNewTab/' + flag); | ||||
|  | ||||
|         optionsInit.loadOptions(); | ||||
|     }); | ||||
|  | ||||
|     return { | ||||
|         optionsLoaded | ||||
|     }; | ||||
|   | ||||
| @@ -26,9 +26,16 @@ function addLoadListener(listener) { | ||||
|     optionsReady.then(listener); | ||||
| } | ||||
|  | ||||
| async function getOption(name) { | ||||
|     const options = await optionsReady; | ||||
|  | ||||
|     return options[name]; | ||||
| } | ||||
|  | ||||
| export default { | ||||
|     // use addLoadListener() which will be called also on refreshes | ||||
|     optionsReady, | ||||
|     addLoadListener, | ||||
|     loadOptions | ||||
|     loadOptions, | ||||
|     getOption | ||||
| } | ||||
| @@ -17,6 +17,7 @@ import noteDetailRender from "./note_detail_render.js"; | ||||
| import noteDetailRelationMap from "./note_detail_relation_map.js"; | ||||
| import noteDetailProtectedSession from "./note_detail_protected_session.js"; | ||||
| import protectedSessionService from "./protected_session.js"; | ||||
| import optionsInitService from "./options_init.js"; | ||||
| import linkService from "./link.js"; | ||||
| import Sidebar from "./sidebar.js"; | ||||
|  | ||||
| @@ -34,6 +35,12 @@ const componentClasses = { | ||||
|     'protected-session': noteDetailProtectedSession | ||||
| }; | ||||
|  | ||||
| let showSidebarInNewTab = true; | ||||
|  | ||||
| optionsInitService.addLoadListener(options => { | ||||
|     showSidebarInNewTab = options.showSidebarInNewTab === '1'; | ||||
| }); | ||||
|  | ||||
| class TabContext { | ||||
|     /** | ||||
|      * @param {TabRow} tabRow | ||||
| @@ -64,7 +71,11 @@ class TabContext { | ||||
|         this.attributes = new Attributes(this); | ||||
|  | ||||
|         if (utils.isDesktop()) { | ||||
|             this.sidebar = new Sidebar(this, state.sidebar); | ||||
|             const sidebarState = state.sidebar || { | ||||
|                 visible: showSidebarInNewTab | ||||
|             }; | ||||
|  | ||||
|             this.sidebar = new Sidebar(this, sidebarState); | ||||
|             this.noteType = new NoteTypeContext(this); | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -17,6 +17,7 @@ const ALLOWED_OPTIONS = [ | ||||
|     'leftPaneWidthPercent', | ||||
|     'sidebarMinWidth', | ||||
|     'sidebarWidthPercent', | ||||
|     'showSidebarInNewTab', | ||||
|     'hoistedNoteId', | ||||
|     'mainFontSize', | ||||
|     'treeFontSize', | ||||
|   | ||||
| @@ -4,7 +4,7 @@ const build = require('./build'); | ||||
| const packageJson = require('../../package'); | ||||
| const {TRILIUM_DATA_DIR} = require('./data_dir'); | ||||
|  | ||||
| const APP_DB_VERSION = 138; | ||||
| const APP_DB_VERSION = 139; | ||||
| const SYNC_VERSION = 10; | ||||
| const CLIPPER_PROTOCOL_VERSION = "1.0"; | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,13 @@ | ||||
| <div id="options-sidebar" class="tab-pane"> | ||||
|     <h3>Show sidebar in new tab</h3> | ||||
|  | ||||
|     <div class="form-check"> | ||||
|         <input type="checkbox" class="form-check-input" id="show-sidebar-in-new-tab"> | ||||
|         <label class="form-check-label" for="show-sidebar-in-new-tab">Show sidebar in new tab</label> | ||||
|     </div> | ||||
|  | ||||
|     <br> | ||||
|  | ||||
|     <h3>Sidebar sizing</h3> | ||||
|  | ||||
|     <div class="form-group row"> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user