This commit is contained in:
Vanessa 2022-11-07 22:14:33 +08:00
parent 76b832b02c
commit a15d69a615
4 changed files with 38 additions and 12 deletions

View File

@ -7,7 +7,7 @@
"id": "20200924100950-9op5xi1",
"title": "Shortcuts",
"type": "doc",
"updated": "20221107215308"
"updated": "20221107221232"
},
"Children": [
{
@ -8293,7 +8293,7 @@
"Properties": {
"colgroup": "||",
"id": "20220619002135-s399g7e",
"updated": "20221107215308"
"updated": "20221107221232"
},
"Children": [
{
@ -8571,7 +8571,7 @@
},
{
"Type": "NodeText",
"Data": ""
"Data": " / Middle mouse button"
}
]
},

View File

@ -7,7 +7,7 @@
"id": "20200813004551-gm0pbn1",
"title": "快捷键",
"type": "doc",
"updated": "20221107215100"
"updated": "20221107220925"
},
"Children": [
{
@ -8238,7 +8238,7 @@
"Properties": {
"colgroup": "||",
"id": "20220619001217-e9cwukj",
"updated": "20221107215100"
"updated": "20221107220925"
},
"Children": [
{
@ -8508,7 +8508,7 @@
},
{
"Type": "NodeText",
"Data": ""
"Data": " / 鼠标中键"
}
]
},
@ -8529,10 +8529,10 @@
{
"ID": "20221107214439-v40c6qz",
"Type": "NodeHeading",
"HeadingLevel": 2,
"HeadingLevel": 3,
"Properties": {
"id": "20221107214439-v40c6qz",
"updated": "20221107214442"
"updated": "20221107220850"
},
"Children": [
{

View File

@ -6,7 +6,7 @@
"icon": "2328",
"id": "20211226122549-jktxego",
"title": "快捷鍵",
"updated": "20221107215259"
"updated": "20221107221152"
},
"Children": [
{
@ -8294,7 +8294,7 @@
"Properties": {
"colgroup": "||",
"id": "20220619002223-xwob5s8",
"updated": "20221107215259"
"updated": "20221107221152"
},
"Children": [
{
@ -8580,7 +8580,7 @@
},
{
"Type": "NodeText",
"Data": ""
"Data": " / 鼠標中鍵"
}
]
},

View File

@ -183,6 +183,26 @@ export class Files extends Model {
}
setPanelFocus(this.element.parentElement);
});
this.element.addEventListener("mousedown", (event) => {
// 点击鼠标滚轮关闭
if (event.button !== 1 || !window.siyuan.config.fileTree.openFilesUseCurrentTab) {
return;
}
let target = event.target as HTMLElement;
while (target && !target.isEqualNode(this.element)) {
if (target.tagName === "LI") {
openFileById({
removeCurrentTab: false,
id: target.getAttribute("data-node-id"),
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
});
event.stopPropagation();
event.preventDefault();
break;
}
target = target.parentElement;
}
})
this.element.addEventListener("click", (event) => {
if (event.detail !== 1) {
setPanelFocus(this.element.parentElement);
@ -249,9 +269,15 @@ export class Files extends Model {
position: "bottom",
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
});
} else if (window.siyuan.config.fileTree.openFilesUseCurrentTab &&
event.altKey && (event.metaKey || event.ctrlKey) && !event.shiftKey) {
openFileById({
removeCurrentTab: false,
id: target.getAttribute("data-node-id"),
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
});
} else {
openFileById({
removeCurrentTab: !((event.altKey && (event.metaKey || event.ctrlKey) && !event.shiftKey)),
id: target.getAttribute("data-node-id"),
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
});