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() { | addTabHandler((function() { | ||||||
|     const $sidebarMinWidth = $("#sidebar-min-width"); |     const $sidebarMinWidth = $("#sidebar-min-width"); | ||||||
|     const $sidebarWidthPercent = $("#sidebar-width-percent"); |     const $sidebarWidthPercent = $("#sidebar-width-percent"); | ||||||
|  |     const $showSidebarInNewTab = $("#show-sidebar-in-new-tab"); | ||||||
|  |  | ||||||
|     async function optionsLoaded(options) { |     async function optionsLoaded(options) { | ||||||
|         $sidebarMinWidth.val(options.sidebarMinWidth); |         $sidebarMinWidth.val(options.sidebarMinWidth); | ||||||
|         $sidebarWidthPercent.val(options.sidebarWidthPercent); |         $sidebarWidthPercent.val(options.sidebarWidthPercent); | ||||||
|  |  | ||||||
|  |         if (parseInt(options.showSidebarInNewTab)) { | ||||||
|  |             $showSidebarInNewTab.attr("checked", "checked"); | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|  |             $showSidebarInNewTab.removeAttr("checked"); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     function resizeSidebar() { |     function resizeSidebar() { | ||||||
| @@ -385,6 +393,14 @@ addTabHandler((function() { | |||||||
|         resizeSidebar(); |         resizeSidebar(); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  |     $showSidebarInNewTab.change(async function() { | ||||||
|  |         const flag = $(this).is(":checked") ? 1 : 0; | ||||||
|  |  | ||||||
|  |         await server.put('options/showSidebarInNewTab/' + flag); | ||||||
|  |  | ||||||
|  |         optionsInit.loadOptions(); | ||||||
|  |     }); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         optionsLoaded |         optionsLoaded | ||||||
|     }; |     }; | ||||||
|   | |||||||
| @@ -26,9 +26,16 @@ function addLoadListener(listener) { | |||||||
|     optionsReady.then(listener); |     optionsReady.then(listener); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | async function getOption(name) { | ||||||
|  |     const options = await optionsReady; | ||||||
|  |  | ||||||
|  |     return options[name]; | ||||||
|  | } | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|     // use addLoadListener() which will be called also on refreshes |     // use addLoadListener() which will be called also on refreshes | ||||||
|     optionsReady, |     optionsReady, | ||||||
|     addLoadListener, |     addLoadListener, | ||||||
|     loadOptions |     loadOptions, | ||||||
|  |     getOption | ||||||
| } | } | ||||||
| @@ -17,6 +17,7 @@ import noteDetailRender from "./note_detail_render.js"; | |||||||
| import noteDetailRelationMap from "./note_detail_relation_map.js"; | import noteDetailRelationMap from "./note_detail_relation_map.js"; | ||||||
| import noteDetailProtectedSession from "./note_detail_protected_session.js"; | import noteDetailProtectedSession from "./note_detail_protected_session.js"; | ||||||
| import protectedSessionService from "./protected_session.js"; | import protectedSessionService from "./protected_session.js"; | ||||||
|  | import optionsInitService from "./options_init.js"; | ||||||
| import linkService from "./link.js"; | import linkService from "./link.js"; | ||||||
| import Sidebar from "./sidebar.js"; | import Sidebar from "./sidebar.js"; | ||||||
|  |  | ||||||
| @@ -34,6 +35,12 @@ const componentClasses = { | |||||||
|     'protected-session': noteDetailProtectedSession |     'protected-session': noteDetailProtectedSession | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | let showSidebarInNewTab = true; | ||||||
|  |  | ||||||
|  | optionsInitService.addLoadListener(options => { | ||||||
|  |     showSidebarInNewTab = options.showSidebarInNewTab === '1'; | ||||||
|  | }); | ||||||
|  |  | ||||||
| class TabContext { | class TabContext { | ||||||
|     /** |     /** | ||||||
|      * @param {TabRow} tabRow |      * @param {TabRow} tabRow | ||||||
| @@ -64,7 +71,11 @@ class TabContext { | |||||||
|         this.attributes = new Attributes(this); |         this.attributes = new Attributes(this); | ||||||
|  |  | ||||||
|         if (utils.isDesktop()) { |         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); |             this.noteType = new NoteTypeContext(this); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -17,6 +17,7 @@ const ALLOWED_OPTIONS = [ | |||||||
|     'leftPaneWidthPercent', |     'leftPaneWidthPercent', | ||||||
|     'sidebarMinWidth', |     'sidebarMinWidth', | ||||||
|     'sidebarWidthPercent', |     'sidebarWidthPercent', | ||||||
|  |     'showSidebarInNewTab', | ||||||
|     'hoistedNoteId', |     'hoistedNoteId', | ||||||
|     'mainFontSize', |     'mainFontSize', | ||||||
|     'treeFontSize', |     'treeFontSize', | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ const build = require('./build'); | |||||||
| const packageJson = require('../../package'); | const packageJson = require('../../package'); | ||||||
| const {TRILIUM_DATA_DIR} = require('./data_dir'); | const {TRILIUM_DATA_DIR} = require('./data_dir'); | ||||||
|  |  | ||||||
| const APP_DB_VERSION = 138; | const APP_DB_VERSION = 139; | ||||||
| const SYNC_VERSION = 10; | const SYNC_VERSION = 10; | ||||||
| const CLIPPER_PROTOCOL_VERSION = "1.0"; | const CLIPPER_PROTOCOL_VERSION = "1.0"; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,4 +1,13 @@ | |||||||
| <div id="options-sidebar" class="tab-pane"> | <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> |     <h3>Sidebar sizing</h3> | ||||||
|  |  | ||||||
|     <div class="form-group row"> |     <div class="form-group row"> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user