mirror of
https://github.com/devon22/obsidian-gridexplorer.git
synced 2026-07-22 12:00:25 +00:00
2.9.24
This commit is contained in:
parent
19b555e577
commit
4f9ffe0516
6 changed files with 52 additions and 13 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "gridexplorer",
|
||||
"name": "GridExplorer",
|
||||
"version": "2.9.23",
|
||||
"version": "2.9.24",
|
||||
"minAppVersion": "1.1.0",
|
||||
"description": "Browse note files in a grid view.",
|
||||
"author": "Devon22",
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "gridexplorer",
|
||||
"version": "2.9.23",
|
||||
"version": "2.9.24",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "gridexplorer",
|
||||
"version": "2.9.23",
|
||||
"version": "2.9.24",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.6",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "gridexplorer",
|
||||
"version": "2.9.23",
|
||||
"version": "2.9.24",
|
||||
"description": "Browse note files in a grid view.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -1388,8 +1388,13 @@ export class GridView extends ItemView {
|
|||
this.openMediaFile(file, files);
|
||||
}
|
||||
} else {
|
||||
// 開啟文件檔案到新分頁
|
||||
this.app.workspace.getLeaf(true).openFile(file);
|
||||
if (event.ctrlKey && event.altKey) {
|
||||
// Ctrl+Alt:開啟在分割視窗
|
||||
this.app.workspace.getLeaf('split').openFile(file);
|
||||
} else {
|
||||
// 開啟文件檔案到新分頁
|
||||
this.app.workspace.getLeaf(true).openFile(file);
|
||||
}
|
||||
}
|
||||
event.preventDefault();
|
||||
return;
|
||||
|
|
@ -1417,7 +1422,7 @@ export class GridView extends ItemView {
|
|||
this.openMediaFile(file, files);
|
||||
}
|
||||
} else if (file.extension === 'pdf' || file.extension === 'canvas' || file.extension === 'base') {
|
||||
this.app.workspace.getLeaf(true).openFile(file);
|
||||
this.getLeafByMode(file).openFile(file);
|
||||
} else {
|
||||
// 非媒體檔案
|
||||
// 如果是捷徑檔案,則開啟捷徑,否則在網格視圖中直接顯示筆記
|
||||
|
|
@ -1445,7 +1450,7 @@ export class GridView extends ItemView {
|
|||
// 如果是捷徑檔案,則開啟捷徑,否則正常開啟檔案
|
||||
if (!this.openShortcutFile(file)) {
|
||||
// 非捷徑就正常開啟檔案
|
||||
const leaf = this.getLeafByMode();
|
||||
const leaf = this.getLeafByMode(file);
|
||||
if (this.searchQuery) {
|
||||
this.app.vault.cachedRead(file).then((content) => {
|
||||
const searchQuery = this.searchQuery;
|
||||
|
|
@ -1849,10 +1854,28 @@ export class GridView extends ItemView {
|
|||
}
|
||||
|
||||
// 根據 openNoteLayout 設定獲取對應的 leaf
|
||||
getLeafByMode(): WorkspaceLeaf {
|
||||
getLeafByMode(file?: TFile): WorkspaceLeaf {
|
||||
const mode = this.plugin.settings.openNoteLayout;
|
||||
switch (mode) {
|
||||
case 'newTab':
|
||||
// 如果提供了檔案,先檢查是否已經在某個分頁中開啟
|
||||
if (file) {
|
||||
// 獲取所有 leaves,不限定類型
|
||||
const allLeaves = this.app.workspace.getLeavesOfType('markdown')
|
||||
.concat(this.app.workspace.getLeavesOfType('pdf'))
|
||||
.concat(this.app.workspace.getLeavesOfType('canvas'))
|
||||
.concat(this.app.workspace.getLeavesOfType('bases'))
|
||||
.concat(this.app.workspace.getLeavesOfType('excalidraw'));;
|
||||
for (const leaf of allLeaves) {
|
||||
const viewState = leaf.getViewState();
|
||||
if (viewState.state?.file === file.path) {
|
||||
// 找到已開啟的分頁,切換焦點到該分頁
|
||||
this.app.workspace.setActiveLeaf(leaf, { focus: true });
|
||||
return leaf;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 沒有找到已開啟的分頁,開新分頁
|
||||
return this.app.workspace.getLeaf('tab');
|
||||
case 'split':
|
||||
// 檢查是否已經有 split 視圖存在
|
||||
|
|
@ -1899,7 +1922,7 @@ export class GridView extends ItemView {
|
|||
if (!target) return false;
|
||||
|
||||
if (target instanceof TFile) {
|
||||
this.getLeafByMode().openFile(target);
|
||||
this.getLeafByMode(target).openFile(target);
|
||||
return true;
|
||||
} else {
|
||||
new Notice(`${t('target_not_found')}: ${redirectPath}`);
|
||||
|
|
@ -1990,7 +2013,7 @@ export class GridView extends ItemView {
|
|||
const editButton = rightBar.createEl('button', { cls: 'ge-note-edit-button' });
|
||||
setIcon(editButton, 'pencil');
|
||||
editButton.addEventListener('click', () => {
|
||||
this.getLeafByMode().openFile(file);
|
||||
this.getLeafByMode(file).openFile(file);
|
||||
});
|
||||
|
||||
// 關閉按鈕
|
||||
|
|
@ -2051,7 +2074,7 @@ export class GridView extends ItemView {
|
|||
const linkText = link.getAttribute('data-href') || href;
|
||||
const linkedFile = this.app.metadataCache.getFirstLinkpathDest(linkText, file.path);
|
||||
if (linkedFile) {
|
||||
this.getLeafByMode().openFile(linkedFile);
|
||||
this.getLeafByMode(linkedFile).openFile(linkedFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
16
styles.css
16
styles.css
|
|
@ -2,6 +2,8 @@
|
|||
.ge-grid-view-container {
|
||||
padding: 0px;
|
||||
height: 100%;
|
||||
container-type: inline-size;
|
||||
container-name: grid-view;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------- */
|
||||
|
|
@ -645,6 +647,20 @@
|
|||
align-items: center;
|
||||
}
|
||||
|
||||
/* 針對非常窄的側邊欄(寬度小於 350px)進一步優化 */
|
||||
@container (max-width: 350px) {
|
||||
.ge-header-buttons {
|
||||
gap: 7px;
|
||||
padding: 9px 7px; /* 保持上下 padding 9px,減少左右 padding 到 6px */
|
||||
}
|
||||
|
||||
.ge-header-buttons button {
|
||||
padding: 6px 9px; /* 保持上下 padding 6px,減少左右 padding 到 8px */
|
||||
gap: 3px;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------- */
|
||||
|
||||
/* 模式名稱容器 */
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"2.9.23": "1.1.0"
|
||||
"2.9.24": "1.1.0"
|
||||
}
|
||||
Loading…
Reference in a new issue