mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
context menu on tab and "close all except for this tab"
This commit is contained in:
parent
aef0e552a0
commit
4ea27e604f
@ -277,6 +277,14 @@
|
|||||||
this.setupDraggabilly()
|
this.setupDraggabilly()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeAllTabsExceptForThis(remainingTabEl) {
|
||||||
|
for (const tabEl of this.tabEls) {
|
||||||
|
if (remainingTabEl !== tabEl) {
|
||||||
|
this.removeTab(tabEl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateTab(tabEl, tabProperties) {
|
updateTab(tabEl, tabProperties) {
|
||||||
tabEl.querySelector('.chrome-tab-title').textContent = tabProperties.title
|
tabEl.querySelector('.chrome-tab-title').textContent = tabProperties.title
|
||||||
|
|
||||||
|
@ -2,6 +2,10 @@ const $contextMenuContainer = $("#context-menu-container");
|
|||||||
|
|
||||||
let dateContextMenuOpenedMs = 0;
|
let dateContextMenuOpenedMs = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param event - originating click event (used to get coordinates to display menu at position)
|
||||||
|
* @param {object} contextMenu - needs to have getContextMenuItems() and selectContextMenuItem(e, cmd)
|
||||||
|
*/
|
||||||
async function initContextMenu(event, contextMenu) {
|
async function initContextMenu(event, contextMenu) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import NoteFull from "../entities/note_full.js";
|
|||||||
import bundleService from "./bundle.js";
|
import bundleService from "./bundle.js";
|
||||||
import utils from "./utils.js";
|
import utils from "./utils.js";
|
||||||
import importDialog from "../dialogs/import.js";
|
import importDialog from "../dialogs/import.js";
|
||||||
|
import contextMenuService from "./context_menu.js";
|
||||||
|
|
||||||
const chromeTabsEl = document.querySelector('.chrome-tabs');
|
const chromeTabsEl = document.querySelector('.chrome-tabs');
|
||||||
const chromeTabs = new ChromeTabs();
|
const chromeTabs = new ChromeTabs();
|
||||||
@ -263,6 +264,23 @@ chromeTabsEl.addEventListener('tabRemove', ({ detail }) => {
|
|||||||
console.log(`Removed tab ${tabId}`);
|
console.log(`Removed tab ${tabId}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(chromeTabsEl).on('contextmenu', '.chrome-tab', e => {
|
||||||
|
const tab = $(e.target).closest(".chrome-tab");
|
||||||
|
|
||||||
|
contextMenuService.initContextMenu(e, {
|
||||||
|
getContextMenuItems: () => {
|
||||||
|
return [
|
||||||
|
{title: "Close all tabs except for this", cmd: "removeAllTabsExceptForThis", uiIcon: "empty"}
|
||||||
|
];
|
||||||
|
},
|
||||||
|
selectContextMenuItem: (e, cmd) => {
|
||||||
|
if (cmd === 'removeAllTabsExceptForThis') {
|
||||||
|
chromeTabs.removeAllTabsExceptForThis(tab[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
utils.bindShortcut('ctrl+w', () => {
|
utils.bindShortcut('ctrl+w', () => {
|
||||||
if (noteContexts.length === 1) {
|
if (noteContexts.length === 1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user