import bundleService from "./bundle.js"; import ws from "./ws.js"; import optionsService from "./options.js"; import splitService from "./split.js"; import optionService from "./options.js"; import server from "./server.js"; import noteDetailService from "./note_detail.js"; const $sidebar = $("#right-pane"); const $sidebarContainer = $('#sidebar-container'); const $showSidebarButton = $("#show-sidebar-button"); const $hideSidebarButton = $("#hide-sidebar-button"); optionService.waitForOptions().then(options => toggleSidebar(options.is('rightPaneVisible'))); function toggleSidebar(show) { $sidebar.toggle(show); $showSidebarButton.toggle(!show); $hideSidebarButton.toggle(show); if (show) { splitService.setupSplitWithSidebar(); } else { splitService.setupSplitWithoutSidebar(); } } $hideSidebarButton.on('click', () => { toggleSidebar(false); server.put('options/rightPaneVisible/false'); }); $showSidebarButton.on('click', async () => { toggleSidebar(true); await server.put('options/rightPaneVisible/true'); const {sidebar} = noteDetailService.getActiveTabContext(); await sidebar.noteLoaded(); sidebar.show(); }); class Sidebar { /** * @param {TabContext} ctx * @param {object} state */ constructor(ctx, state = {}) { /** @property {TabContext} */ this.ctx = ctx; this.state = Object.assign({ widgets: [] }, state); this.widgets = []; this.$widgetContainer = $sidebar.find(`.sidebar-widget-container[data-tab-id=${this.ctx.tabId}]`); if (this.$widgetContainer.length === 0) { this.$widgetContainer = $(`