Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
50bf708
Open new tab when clicking file tree with mouse wheel
bytedream May 28, 2025
83e925a
Use own function instead
bytedream May 29, 2025
0941d5f
Merge branch 'main' into mouse-wheel-click-file-tree
bytedream Jun 15, 2025
91069cf
use click.middle instead of auxclick
bytedream Jun 15, 2025
2b5e119
also check if ctrl key was pressed
bytedream Jun 16, 2025
7fef0bb
Merge branch 'main' into mouse-wheel-click-file-tree
bytedream Jun 16, 2025
06ac1c9
update comment
bytedream Jun 16, 2025
10d9471
check meta key in addition to ctrl
bytedream Jun 16, 2025
9c4a8e2
add aux click check to doLoadDirContent
bytedream Jun 16, 2025
9915581
add sub module aux click support
bytedream Jun 16, 2025
3c6e803
Merge branch 'main' into mouse-wheel-click-file-tree
bytedream Jun 18, 2025
ee2f52a
use `a` for file tree files
bytedream Jun 18, 2025
2bf13d0
Merge branch 'main' into mouse-wheel-click-file-tree
bytedream Jun 18, 2025
0c8c45f
use class to disable default link styling
bytedream Jun 18, 2025
e2655f3
move plain click check to utils
bytedream Jun 18, 2025
35ab11f
mark mouse event explicitly null
bytedream Jun 18, 2025
ed23d70
update docs
bytedream Jun 18, 2025
7914f27
Merge branch 'main' into mouse-wheel-click-file-tree
wxiaoguang Jun 19, 2025
156de30
refactor
wxiaoguang Jun 19, 2025
5519577
refactor
wxiaoguang Jun 19, 2025
ef3873c
refactor
wxiaoguang Jun 19, 2025
f01e51f
prevent page reload on subtree load
bytedream Jun 19, 2025
390b63e
Merge branch 'main' into mouse-wheel-click-file-tree
GiteaBot Jun 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion web_src/js/components/ViewFileTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ async function loadViewContent(url: string) {
document.querySelector('.repo-view-content').innerHTML = await response.text();
}

async function navigateTreeView(treePath: string) {
async function navigateTreeView(treePath: string, newTab?: boolean) {
const url = `${props.repoLink}/src/${props.currentRefNameSubURL}/${pathEscapeSegments(treePath)}`;
if (newTab) {
window.open(url, '_blank');
return;
}
window.history.pushState({treePath, url}, null, url);
selectedItem.value = treePath;
await loadViewContent(url);
Expand Down
13 changes: 10 additions & 3 deletions web_src/js/components/ViewFileTreeItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Item = {

const props = defineProps<{
item: Item,
navigateViewContent:(treePath: string) => void,
navigateViewContent:(treePath: string, newTab?: boolean) => void,
loadChildren:(treePath: string, subPath?: string) => Promise<Item[]>,
selectedItem?: string,
}>();
Expand All @@ -40,8 +40,12 @@ const doLoadDirContent = () => {
props.navigateViewContent(props.item.fullPath);
};

const doLoadFileContent = () => {
props.navigateViewContent(props.item.fullPath);
const doLoadFileContent = (event: MouseEvent) => {
// open the file in a new tab if either
// - the auxiliary button (usually the mouse wheel button) is the origin of the click
// - the ctrl key was pressed while clicking
const openNewTab = event.button === 1 || event.ctrlKey;
props.navigateViewContent(props.item.fullPath, openNewTab);
};

const doGotoSubModule = () => {
Expand All @@ -68,6 +72,7 @@ const doGotoSubModule = () => {
:class="{'selected': selectedItem === item.fullPath}"
:title="item.entryName"
@click.stop="doLoadFileContent"
@click.middle.stop="doLoadFileContent"
>
<!-- symlink -->
<div class="item-content">
Expand All @@ -81,6 +86,7 @@ const doGotoSubModule = () => {
:class="{'selected': selectedItem === item.fullPath}"
:title="item.entryName"
@click.stop="doLoadFileContent"
@click.middle.stop="doLoadFileContent"
>
<!-- file -->
<div class="item-content">
Expand All @@ -94,6 +100,7 @@ const doGotoSubModule = () => {
:class="{'selected': selectedItem === item.fullPath}"
:title="item.entryName"
@click.stop="doLoadDirContent"
@click.middle.stop="doLoadFileContent"
>
<!-- directory -->
<div class="item-toggle">
Expand Down