Added support for split views persisting between sessions

This commit is contained in:
mr. M
2025-03-24 23:58:06 +01:00
parent bd5d3c00f1
commit 342186584e
10 changed files with 184 additions and 53 deletions

View File

@@ -58,6 +58,11 @@ tab-group[split-view-group] {
right: 50%;
transform: translateX(50%);
}
& .tab-content {
min-width: 0;
justify-content: unset !important;
}
}
&:has(> tab:is([visuallyselected], [multiselected])) {

View File

@@ -365,7 +365,7 @@ menuitem {
}
& .zen-toast {
padding: 0.9rem 0.8rem;
padding: 0.5rem 0.6rem;
border-radius: 12px;
background: linear-gradient(
170deg,

View File

@@ -1722,6 +1722,33 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
return null;
}
storeDataForSessionStore() {
// We cant store any tab or browser elements in the session store
// so we need to store the tab indexes and group indexes
const data = this._data.map((group) => {
return {
groupId: group.tabs[0].group?.id,
gridType: group.gridType,
};
});
return data;
}
restoreDataFromSessionStore(data) {
if (!data) {
return;
}
// We can just get the tab group with document.getElementById(group.groupId)
// and add the tabs to it
for (const group of data) {
const groupElement = document.getElementById(group.groupId);
if (groupElement) {
const tabs = groupElement.querySelectorAll('tab');
this.splitTabs([...tabs], group.gridType);
}
}
}
}
window.gZenViewSplitter = new ZenViewSplitter();

View File

@@ -263,12 +263,13 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
_organizeTabsToWorkspaceSections(workspace, section, pinnedSection, tabs) {
const workspaceTabs = Array.from(tabs).filter((tab) => tab.getAttribute('zen-workspace-id') === workspace.uuid);
let firstNormalTab = null;
for (const tab of workspaceTabs) {
for (let tab of workspaceTabs) {
if (tab.hasAttribute('zen-essential')) {
continue; // Ignore essentials as they need to be in their own section
}
// remove tab from list
tabs.splice(tabs.indexOf(tab), 1);
tab = tab.group ?? tab;
if (tab.pinned) {
pinnedSection.insertBefore(tab, pinnedSection.nextSibling);
} else {
@@ -2323,6 +2324,23 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
return this._allStoredTabs;
}
get allTabGroups() {
if (!this._hasInitializedTabsStrip) {
let children = this.tabboxChildren;
return children.filter((node) => node.tagName == 'tab-group');
}
const pinnedContainers = document.querySelectorAll('#vertical-pinned-tabs-container .zen-workspace-tabs-section');
const normalContainers = document.querySelectorAll('#tabbrowser-arrowscrollbox .zen-workspace-tabs-section');
const containers = [...pinnedContainers, ...normalContainers];
const tabGroups = [];
for (const container of containers) {
for (const tabGroup of container.querySelectorAll('tab-group')) {
tabGroups.push(tabGroup);
}
}
return tabGroups;
}
get allUsedBrowsers() {
if (!this._hasInitializedTabsStrip) {
return gBrowser.browsers;