feat: support middle-click on bookmark open buttons
This commit is contained in:
30
web/app.js
30
web/app.js
@@ -1512,6 +1512,32 @@ function openBookmarkQueries(baseQuery) {
|
||||
return opened;
|
||||
}
|
||||
|
||||
function bindMiddleMouseOpen(element, handler) {
|
||||
if (!element || typeof handler !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent browser auto-scroll so middle click behaves like link-open here.
|
||||
element.addEventListener('mousedown', (event) => {
|
||||
if (event.button === 1) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener('auxclick', (event) => {
|
||||
if (event.button !== 1) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
handler();
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.bindMiddleMouseOpen = bindMiddleMouseOpen;
|
||||
}
|
||||
|
||||
function openBookmark(bookmark) {
|
||||
if (!bookmark) {
|
||||
return;
|
||||
@@ -1611,7 +1637,9 @@ function createBookmarkRow(bookmark) {
|
||||
openButton.title = searchVariants.map((variant) => `• ${variant}`).join('\n');
|
||||
}
|
||||
|
||||
openButton.addEventListener('click', () => openBookmark(bookmark));
|
||||
const handleOpenBookmark = () => openBookmark(bookmark);
|
||||
openButton.addEventListener('click', handleOpenBookmark);
|
||||
bindMiddleMouseOpen(openButton, handleOpenBookmark);
|
||||
|
||||
const label = document.createElement('span');
|
||||
label.className = 'bookmark-row__label';
|
||||
|
||||
Reference in New Issue
Block a user