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
option to configure if sidebar should be enabled in new tab
zadamb818f020a75d
diff --git a/db/migrations/0139__show_sidebar_in_new_tab.sql b/db/migrations/0139__show_sidebar_in_new_tab.sqlnew file mode 100644index 0000000000..83a8783846--- /dev/null+++ b/db/migrations/0139__show_sidebar_in_new_tab.sql@@ -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);\ No newline at end of filediff --git a/src/public/javascripts/dialogs/options.js b/src/public/javascripts/dialogs/options.jsindex d50c0746e9..323ebfb0fb 100644--- a/src/public/javascripts/dialogs/options.js+++ b/src/public/javascripts/dialogs/options.js@@ -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};diff --git a/src/public/javascripts/services/options_init.js b/src/public/javascripts/services/options_init.jsindex a3010e449f..cea79f6f67 100644--- a/src/public/javascripts/services/options_init.js+++ b/src/public/javascripts/services/options_init.js@@ -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 refreshesoptionsReady,addLoadListener,- loadOptions+ loadOptions,+ getOption}\ No newline at end of filediff --git a/src/public/javascripts/services/tab_context.js b/src/public/javascripts/services/tab_context.jsindex 1afeb13612..ae431dee33 100644--- a/src/public/javascripts/services/tab_context.js+++ b/src/public/javascripts/services/tab_context.js@@ -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);}diff --git a/src/routes/api/options.js b/src/routes/api/options.jsindex 32dc59cab4..e2e000ceb1 100644--- a/src/routes/api/options.js+++ b/src/routes/api/options.js@@ -17,6 +17,7 @@ const ALLOWED_OPTIONS = ['leftPaneWidthPercent','sidebarMinWidth','sidebarWidthPercent',+ 'showSidebarInNewTab','hoistedNoteId','mainFontSize','treeFontSize',diff --git a/src/services/app_info.js b/src/services/app_info.jsindex 7c6bd436c6..8b2e450586 100644--- a/src/services/app_info.js+++ b/src/services/app_info.js@@ -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";diff --git a/src/views/dialogs/options/sidebar.ejs b/src/views/dialogs/options/sidebar.ejsindex e2f7275077..4fcd15dd03 100644--- a/src/views/dialogs/options/sidebar.ejs+++ b/src/views/dialogs/options/sidebar.ejs@@ -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">