mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 10:22:29 +08:00
ELIAN HELPED ME
This commit is contained in:
parent
34a9008d29
commit
023f0b607d
@ -11,7 +11,6 @@ import options from "./services/options.js";
|
||||
import type ElectronRemote from "@electron/remote";
|
||||
import type Electron from "electron";
|
||||
import "../stylesheets/bootstrap.scss";
|
||||
import rightPaneTabManager from "./services/right_pane_tab_manager.js";
|
||||
|
||||
await appContext.earlyInit();
|
||||
|
||||
|
@ -87,7 +87,6 @@ import utils from "../services/utils.js";
|
||||
import GeoMapButtons from "../widgets/floating_buttons/geo_map_button.js";
|
||||
import ContextualHelpButton from "../widgets/floating_buttons/help_button.js";
|
||||
import CloseZenButton from "../widgets/close_zen_button.js";
|
||||
import rightPaneTabManager from "../services/right_pane_tab_manager.js";
|
||||
import type { AppContext } from "./../components/app_context.js";
|
||||
import type { WidgetsByParent } from "../services/bundle.js";
|
||||
import SwitchSplitOrientationButton from "../widgets/floating_buttons/switch_layout_button.js";
|
||||
@ -246,7 +245,6 @@ export default class DesktopLayout {
|
||||
)
|
||||
.child(
|
||||
new RightPaneContainer()
|
||||
.id("right-pane-container")
|
||||
.child(new TocWidget())
|
||||
.child(new HighlightsListWidget())
|
||||
.child(...this.customWidgets.get("right-pane"))
|
||||
|
@ -1,127 +0,0 @@
|
||||
/**
|
||||
* Manager for tabs in the right pane
|
||||
*/
|
||||
class RightPaneTabManager {
|
||||
constructor() {
|
||||
this.tabs = [];
|
||||
this.activeTab = null;
|
||||
this.$tabContainer = null;
|
||||
this.$contentContainer = null;
|
||||
this.initialized = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the tab manager with container elements
|
||||
*/
|
||||
init($tabContainer, $contentContainer) {
|
||||
this.$tabContainer = $tabContainer;
|
||||
this.$contentContainer = $contentContainer;
|
||||
this.initialized = true;
|
||||
this.renderTabs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new tab context
|
||||
*/
|
||||
addTabContext(tabContext) {
|
||||
this.tabs.push(tabContext);
|
||||
|
||||
if (this.initialized) {
|
||||
this.renderTabs();
|
||||
|
||||
// If this is the first tab, activate it
|
||||
if (this.tabs.length === 1) {
|
||||
this.activateTab(tabContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render all tabs
|
||||
*/
|
||||
renderTabs() {
|
||||
if (!this.initialized) return;
|
||||
|
||||
this.$tabContainer.empty();
|
||||
|
||||
for (const tab of this.tabs) {
|
||||
const $tab = $('<div class="right-pane-tab"></div>')
|
||||
.attr('data-tab-id', this.tabs.indexOf(tab))
|
||||
.append(tab.renderTitle(tab.title))
|
||||
.toggleClass('active', tab === this.activeTab)
|
||||
.on('click', () => {
|
||||
this.activateTab(tab);
|
||||
});
|
||||
|
||||
this.$tabContainer.append($tab);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate a specific tab
|
||||
*/
|
||||
activateTab(tabContext) {
|
||||
if (this.activeTab === tabContext) return;
|
||||
|
||||
// Deactivate current tab
|
||||
if (this.activeTab) {
|
||||
this.activeTab.deactivate();
|
||||
}
|
||||
|
||||
// Activate new tab
|
||||
this.activeTab = tabContext;
|
||||
tabContext.activate();
|
||||
|
||||
// Update UI
|
||||
if (this.initialized) {
|
||||
this.renderTabs();
|
||||
this.renderContent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the content of the active tab
|
||||
*/
|
||||
renderContent() {
|
||||
if (!this.initialized || !this.activeTab) return;
|
||||
|
||||
this.$contentContainer.empty();
|
||||
|
||||
const widget = this.activeTab.widget;
|
||||
if (widget) {
|
||||
if (typeof widget.render === 'function') {
|
||||
const $renderedWidget = widget.render();
|
||||
this.$contentContainer.append($renderedWidget);
|
||||
} else if (widget instanceof jQuery) {
|
||||
this.$contentContainer.append(widget);
|
||||
} else if (widget.nodeType) {
|
||||
this.$contentContainer.append($(widget));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a tab
|
||||
*/
|
||||
removeTab(tabContext) {
|
||||
const index = this.tabs.indexOf(tabContext);
|
||||
if (index !== -1) {
|
||||
this.tabs.splice(index, 1);
|
||||
|
||||
if (this.activeTab === tabContext) {
|
||||
this.activeTab = this.tabs.length > 0 ? this.tabs[0] : null;
|
||||
if (this.activeTab) {
|
||||
this.activeTab.activate();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.initialized) {
|
||||
this.renderTabs();
|
||||
this.renderContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const rightPaneTabManager = new RightPaneTabManager();
|
||||
export default rightPaneTabManager;
|
@ -1,49 +0,0 @@
|
||||
/**
|
||||
* TabContext represents a tab in the right pane that can contain any widget
|
||||
*/
|
||||
export default class TabContext {
|
||||
/**
|
||||
* @param {string} title - Tab title
|
||||
* @param {object} widget - Widget to display in the tab
|
||||
*/
|
||||
constructor(title, widget) {
|
||||
this.title = title;
|
||||
this.widget = widget;
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom renderer for the tab title
|
||||
* @param {string} title
|
||||
* @returns {JQuery}
|
||||
*/
|
||||
renderTitle(title) {
|
||||
return $(`<span class="tab-title">${title}</span>`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate this tab
|
||||
*/
|
||||
activate() {
|
||||
this.active = true;
|
||||
|
||||
if (this.widget && typeof this.widget.activeTabChanged === 'function') {
|
||||
this.widget.activeTabChanged(true);
|
||||
}
|
||||
|
||||
if (typeof rightPaneTabManager.activateTab === 'function') {
|
||||
rightPaneTabManager.activateTab(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate this tab
|
||||
*/
|
||||
deactivate() {
|
||||
this.active = false;
|
||||
|
||||
if (this.widget && typeof this.widget.activeTabChanged === 'function') {
|
||||
this.widget.activeTabChanged(false);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user