diff --git a/manifest.json b/manifest.json index 35b4e59..1e1e720 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "gridexplorer", "name": "GridExplorer", - "version": "2.2.0", + "version": "2.2.1", "minAppVersion": "1.1.0", "description": "Browse note files in a grid view.", "author": "Devon22", diff --git a/package-lock.json b/package-lock.json index 0de1fc5..b07a08b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gridexplorer", - "version": "2.2.0", + "version": "2.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gridexplorer", - "version": "2.2.0", + "version": "2.2.1", "license": "MIT", "devDependencies": { "@types/node": "^16.11.6", diff --git a/package.json b/package.json index 445b518..7d79677 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gridexplorer", - "version": "2.2.0", + "version": "2.2.1", "description": "Browse note files in a grid view.", "main": "main.js", "scripts": { diff --git a/src/GridView.ts b/src/GridView.ts index 00872bb..e889c4c 100644 --- a/src/GridView.ts +++ b/src/GridView.ts @@ -890,6 +890,41 @@ export class GridView extends ItemView { event.preventDefault(); const menu = new Menu(); + //在新網格視圖開啟 + menu.addItem((item) => { + item + .setTitle( t('open_in_new_grid_view')) + .setIcon('grid') + .onClick(() => { + const { workspace } = this.app; + let leaf = null; + workspace.getLeavesOfType('grid-view'); + switch (this.plugin.settings.defaultOpenLocation) { + case 'left': + leaf = workspace.getLeftLeaf(false); + break; + case 'right': + leaf = workspace.getRightLeaf(false); + break; + case 'tab': + default: + leaf = workspace.getLeaf('tab'); + break; + } + if (!leaf) { + // 如果無法獲取指定位置的 leaf,則回退到新分頁 + leaf = workspace.getLeaf('tab'); + } + leaf.setViewState({ type: 'grid-view', active: true }); + // 設定資料來源 + if (leaf.view instanceof GridView) { + leaf.view.setSource('folder', folder.path); + } + // 確保視圖是活躍的 + workspace.revealLeaf(leaf); + }); + }); + // 檢查同名筆記是否存在 const notePath = `${folder.path}/${folder.name}.md`; let noteFile = this.app.vault.getAbstractFileByPath(notePath); @@ -992,8 +1027,8 @@ export class GridView extends ItemView { }); } - // 資料夾渲染完插入 break(僅當有資料夾時) - if (subfolders.length > 0) { + // 資料夾渲染完插入 break(僅當有資料夾時或有顯示回上一層資料夾項目時) + if (subfolders.length > 0 || (subfolders.length === 0 && this.plugin.settings.showParentFolderItem)) { container.createDiv('ge-break'); } } diff --git a/src/translations.ts b/src/translations.ts index d543efb..39794da 100644 --- a/src/translations.ts +++ b/src/translations.ts @@ -156,6 +156,7 @@ export const TRANSLATIONS: Translations = { 'open_recent_files_in_grid_view': '在最近檔案中開啟當前筆記', 'open_settings': '開啟設定', 'open_new_grid_view': '開啟新網格視圖', + 'open_in_new_grid_view': '在新網格視圖中開啟', 'min_mode': '最小化模式', 'close_min_mode': '關閉最小化模式', 'show_ignored_folders': '顯示忽略的資料夾', @@ -350,6 +351,7 @@ export const TRANSLATIONS: Translations = { 'open_recent_files_in_grid_view': 'Open current note in recent files', 'open_settings': 'Open settings', 'open_new_grid_view': 'Open new grid view', + 'open_in_new_grid_view': 'Open in new grid view', 'min_mode': 'Minimize mode', 'close_min_mode': 'Close minimize mode', 'show_ignored_folders': 'Show ignored folders', @@ -544,6 +546,7 @@ export const TRANSLATIONS: Translations = { 'open_recent_files_in_grid_view': '在最近文件中打开当前笔记', 'open_settings': '打开设置', 'open_new_grid_view': '打开新网格视图', + 'open_in_new_grid_view': '在新网格视图中打开', 'min_mode': '最小化模式', 'close_min_mode': '关闭最小化模式', 'show_ignored_folders': '显示忽略的文件夹', @@ -738,6 +741,7 @@ export const TRANSLATIONS: Translations = { 'open_recent_files_in_grid_view': '最近のファイルで現在のノートを開く', 'open_settings': '設定を開く', 'open_new_grid_view': '新しいグリッドビューを開く', + 'open_in_new_grid_view': '新しいグリッドビューで開く', 'min_mode': '最小化モード', 'close_min_mode': '最小化モードを閉じる', 'show_ignored_folders': '無視するフォルダーを表示', @@ -932,6 +936,7 @@ export const TRANSLATIONS: Translations = { 'open_recent_files_in_grid_view': 'Открыть текущую заметку в недавних файлах', 'open_settings': 'Открыть настройки', 'open_new_grid_view': 'Открыть новый сеточный вид', + 'open_in_new_grid_view': 'Открыть в новом сеточном виде', 'min_mode': 'Минимизировать вид', 'close_min_mode': 'Закрыть минимизированный вид', 'show_ignored_folders': 'Показать игнорируемые папки', @@ -1126,6 +1131,7 @@ export const TRANSLATIONS: Translations = { 'open_recent_files_in_grid_view': 'Відкрити поточну нотатку в останніх файлах', 'open_settings': 'Відкрити налаштування', 'open_new_grid_view': 'Відкрити новий сітковий вигляд', + 'open_in_new_grid_view': 'Відкрити в новому сітковому вигляді', 'min_mode': 'Мінімізувати вигляд', 'close_min_mode': 'Закрити мінімізоване вигляд', 'show_ignored_folders': 'Показати ігноровані папки', diff --git a/versions.json b/versions.json index 6689942..a48bd55 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,3 @@ { - "2.2.0": "1.1.0" + "2.2.1": "1.1.0" } \ No newline at end of file