diff --git a/manifest.json b/manifest.json index a6e784b..8df742a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "gridexplorer", "name": "GridExplorer", - "version": "2.8.4", + "version": "2.8.5", "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 f0ac4c6..001120b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gridexplorer", - "version": "2.8.4", + "version": "2.8.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gridexplorer", - "version": "2.8.4", + "version": "2.8.5", "license": "MIT", "devDependencies": { "@types/node": "^16.11.6", diff --git a/package.json b/package.json index 47cd6d6..525c4ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gridexplorer", - "version": "2.8.4", + "version": "2.8.5", "description": "Browse note files in a grid view.", "main": "main.js", "scripts": { diff --git a/src/FileWatcher.ts b/src/FileWatcher.ts index 4a25cee..73151a8 100644 --- a/src/FileWatcher.ts +++ b/src/FileWatcher.ts @@ -27,7 +27,7 @@ export class FileWatcher { this.app.vault.on('modify', (file) => { if (file instanceof TFile) { if (this.gridView.sourceMode === 'recent-files') { - if(isDocumentFile(file) || (isMediaFile(file) && this.gridView.randomNoteIncludeMedia)) { + if(isDocumentFile(file) || (isMediaFile(file) && this.gridView.includeMedia)) { this.scheduleRender(5000); } } @@ -39,14 +39,14 @@ export class FileWatcher { this.plugin.registerEvent( this.app.vault.on('create', (file) => { if (file instanceof TFile) { - if(this.gridView.searchQuery !== '' && this.gridView.searchAllFiles) { + if(this.gridView.searchQuery && !this.gridView.searchCurrentLocationOnly) { this.scheduleRender(2000); return; } if(this.gridView.sourceMode === 'random-note') { return; } else if (this.gridView.sourceMode === 'recent-files') { - if(isDocumentFile(file) || (isMediaFile(file) && this.gridView.randomNoteIncludeMedia)) { + if(isDocumentFile(file) || (isMediaFile(file) && this.gridView.includeMedia)) { this.scheduleRender(2000); } } else if (this.gridView.sourceMode === 'folder') { diff --git a/src/GridView.ts b/src/GridView.ts index 0b20e1d..4de1819 100644 --- a/src/GridView.ts +++ b/src/GridView.ts @@ -36,10 +36,10 @@ export class GridView extends ItemView { sortType: string; // 排序模式 folderSortType: string = ''; // 資料夾排序模式 searchQuery: string = ''; // 搜尋關鍵字 - searchAllFiles: boolean = true; // 是否搜尋所有筆記 + searchCurrentLocationOnly: boolean = false; // 是否只搜尋當前位置 searchFilesNameOnly: boolean = false; // 是否只搜尋筆記名稱 searchMediaFiles: boolean = false; // 是否搜尋媒體檔案 - randomNoteIncludeMedia: boolean = false; // 隨機筆記是否包含圖片和影片 + includeMedia: boolean = false; // 是否包含媒體檔案 selectedItemIndex: number = -1; // 當前選中的項目索引 selectedItems: Set = new Set(); // 存儲多選的項目索引 gridItems: HTMLElement[] = []; // 存儲所有網格項目的引用 @@ -70,6 +70,9 @@ export class GridView extends ItemView { this.cardLayout = this.baseCardLayout; this.showDateDividers = this.plugin.settings.dateDividerMode !== 'none'; this.showNoteTags = this.plugin.settings.showNoteTags; + this.searchCurrentLocationOnly = this.plugin.settings.searchCurrentLocationOnly; + this.searchFilesNameOnly = this.plugin.settings.searchFilesNameOnly; + this.searchMediaFiles = this.plugin.settings.searchMediaFiles; // 根據設定決定是否註冊檔案變更監聽器 if (this.plugin.settings.enableFileWatcher) { @@ -169,7 +172,7 @@ export class GridView extends ItemView { mode: string, path: string | null, searchQuery: string = '', - searchAllFiles: boolean = true, + searchCurrentLocationOnly: boolean = false, searchFilesNameOnly: boolean = false, searchMediaFiles: boolean = false, ) { @@ -178,7 +181,7 @@ export class GridView extends ItemView { mode, path: sanitizedPath, searchQuery, - searchAllFiles, + searchCurrentLocationOnly, searchFilesNameOnly, searchMediaFiles, }); @@ -198,7 +201,7 @@ export class GridView extends ItemView { path = '', recordHistory = true, // 是否將當前狀態加入歷史記錄 searchQuery?: string, - searchAllFiles?: boolean, + searchCurrentLocationOnly?: boolean, searchFilesNameOnly?: boolean, searchMediaFiles?: boolean ) { @@ -207,7 +210,7 @@ export class GridView extends ItemView { if (this.sourceMode === mode && this.sourcePath === path && this.searchQuery === searchQuery && - this.searchAllFiles === searchAllFiles && + this.searchCurrentLocationOnly === searchCurrentLocationOnly && this.searchFilesNameOnly === searchFilesNameOnly && this.searchMediaFiles === searchMediaFiles) { return; @@ -219,14 +222,14 @@ export class GridView extends ItemView { this.sourceMode, this.sourcePath, this.searchQuery, - this.searchAllFiles, + this.searchCurrentLocationOnly, this.searchFilesNameOnly, this.searchMediaFiles, ); } // 全域搜尋時切換路徑則清空搜尋 - if (this.searchQuery !== '' && this.searchAllFiles) { + if (this.searchQuery && !this.searchCurrentLocationOnly) { this.searchQuery = ''; } @@ -269,8 +272,8 @@ export class GridView extends ItemView { if (searchQuery !== undefined) { this.searchQuery = searchQuery; } - if (searchAllFiles !== undefined) { - this.searchAllFiles = searchAllFiles; + if (searchCurrentLocationOnly !== undefined) { + this.searchCurrentLocationOnly = searchCurrentLocationOnly; } if (searchFilesNameOnly !== undefined) { this.searchFilesNameOnly = searchFilesNameOnly; @@ -1199,7 +1202,7 @@ export class GridView extends ItemView { if (!this.openShortcutFile(file)) { // 非捷徑就正常開啟檔案 const leaf = this.app.workspace.getLeaf(); - if (this.searchQuery !== '') { + if (this.searchQuery) { this.app.vault.cachedRead(file).then((content) => { const searchQuery = this.searchQuery; const lowerContent = content.toLowerCase(); @@ -1438,7 +1441,7 @@ export class GridView extends ItemView { lastSource.path || '', false, lastSource.searchQuery || '', - lastSource.searchAllFiles ?? true, + lastSource.searchCurrentLocationOnly ?? false, lastSource.searchFilesNameOnly ?? false, lastSource.searchMediaFiles ?? false ); @@ -1558,7 +1561,7 @@ export class GridView extends ItemView { // 如果沒有傳入媒體檔案列表,則獲取 const getMediaFilesPromise = mediaFiles ? Promise.resolve(mediaFiles.filter(f => isMediaFile(f))) - : getFiles(this, this.randomNoteIncludeMedia).then(allFiles => allFiles.filter(f => isMediaFile(f))); + : getFiles(this, this.includeMedia).then(allFiles => allFiles.filter(f => isMediaFile(f))); getMediaFilesPromise.then(filteredMediaFiles => { // 找到當前檔案在媒體檔案列表中的索引 @@ -1614,10 +1617,10 @@ export class GridView extends ItemView { this.clearSelection(); return true; } else if (redirectType === 'search') { - const searchLocationFiles = fileCache?.frontmatter?.searchLocationFiles || false; + const searchCurrentLocationOnly = fileCache?.frontmatter?.searchCurrentLocationOnly || false; const searchFilesNameOnly = fileCache?.frontmatter?.searchFilesNameOnly || false; const searchMediaFiles = fileCache?.frontmatter?.searchMediaFiles || false; - this.setSource('', '', true, redirectPath, !searchLocationFiles, searchFilesNameOnly, searchMediaFiles); + this.setSource('', '', true, redirectPath, searchCurrentLocationOnly, searchFilesNameOnly, searchMediaFiles); this.clearSelection(); return true; } else if (redirectType === 'uri') { @@ -1795,9 +1798,10 @@ export class GridView extends ItemView { sortType: this.sortType, folderSortType: this.folderSortType, searchQuery: this.searchQuery, - searchAllFiles: this.searchAllFiles, + searchCurrentLocationOnly: this.searchCurrentLocationOnly, + searchFilesNameOnly: this.searchFilesNameOnly, searchMediaFiles: this.searchMediaFiles, - randomNoteIncludeMedia: this.randomNoteIncludeMedia, + includeMedia: this.includeMedia, minMode: this.minMode, showIgnoredFolders: this.showIgnoredFolders, baseCardLayout: this.baseCardLayout, @@ -1806,7 +1810,7 @@ export class GridView extends ItemView { showDateDividers: this.showDateDividers, showNoteTags: this.showNoteTags, recentSources: this.recentSources, - futureSources: this.futureSources, + futureSources: this.futureSources, } }; } @@ -1819,9 +1823,10 @@ export class GridView extends ItemView { this.sortType = state.state.sortType || this.plugin.settings.defaultSortType; this.folderSortType = state.state.folderSortType || ''; this.searchQuery = state.state.searchQuery || ''; - this.searchAllFiles = state.state.searchAllFiles ?? true; + this.searchCurrentLocationOnly = state.state.searchCurrentLocationOnly ?? false; + this.searchFilesNameOnly = state.state.searchFilesNameOnly ?? false; this.searchMediaFiles = state.state.searchMediaFiles ?? false; - this.randomNoteIncludeMedia = state.state.randomNoteIncludeMedia ?? false; + this.includeMedia = state.state.includeMedia ?? false; this.minMode = state.state.minMode ?? false; this.showIgnoredFolders = state.state.showIgnoredFolders ?? false; this.baseCardLayout = state.state.baseCardLayout ?? 'horizontal'; diff --git a/src/modal/folderSelectionModal.ts b/src/modal/folderSelectionModal.ts index fd9a2fb..dbb3883 100644 --- a/src/modal/folderSelectionModal.ts +++ b/src/modal/folderSelectionModal.ts @@ -17,7 +17,8 @@ export class FolderSelectionModal extends Modal { selectedIndex: number = -1; // 當前選中的選項索引 searchInput: HTMLInputElement; buttonElement: HTMLElement | undefined; - + searchOption: HTMLElement | null = null; // 搜尋選項元素 + constructor(app: App, plugin: GridExplorerPlugin, activeView?: GridView, buttonElement?: HTMLElement) { super(app); this.plugin = plugin; @@ -36,7 +37,7 @@ export class FolderSelectionModal extends Modal { } // 添加搜尋輸入框 - const searchContainer = contentEl.createEl('div', { + const searchContainer = contentEl.createEl('div', { cls: 'ge-folder-search-container' }); this.searchInput = searchContainer.createEl('input', { @@ -49,7 +50,7 @@ export class FolderSelectionModal extends Modal { }); // 創建一個容器來存放所有資料夾選項 - this.folderOptionsContainer = contentEl.createEl('div', { + this.folderOptionsContainer = contentEl.createEl('div', { cls: 'ge-folder-options-container', attr: Platform.isMobile ? { tabindex: '0' } : {} }); @@ -58,6 +59,7 @@ export class FolderSelectionModal extends Modal { this.searchInput.addEventListener('input', () => { const searchTerm = this.searchInput.value.toLowerCase(); this.filterFolderOptions(searchTerm); + this.updateSearchOption(this.searchInput.value.trim()); }); // 鍵盤事件處理 @@ -86,7 +88,7 @@ export class FolderSelectionModal extends Modal { this.folderOptions.push(customOption); }); } - + // 建立書籤選項 if (this.plugin.settings.showBookmarksMode) { const bookmarksPlugin = (this.app as any).internalPlugins.plugins.bookmarks; @@ -117,7 +119,7 @@ export class FolderSelectionModal extends Modal { if (searchLeaf) { const searchView = searchLeaf.view; const searchInputEl = searchView.searchComponent ? searchView.searchComponent.inputEl : null; - if(searchInputEl) { + if (searchInputEl) { if (searchInputEl.value.trim().length > 0) { const searchOption = this.folderOptionsContainer.createEl('div', { cls: 'ge-grid-view-folder-option', @@ -190,7 +192,7 @@ export class FolderSelectionModal extends Modal { this.folderOptions.push(outgoinglinksOption); } } - + // 建立最近檔案選項 if (this.plugin.settings.showRecentFilesMode) { const recentFilesOption = this.folderOptionsContainer.createEl('div', { @@ -300,20 +302,20 @@ export class FolderSelectionModal extends Modal { .filter(folder => { // 使用 isFolderIgnored 函數檢查是否應該忽略此資料夾 return !isFolderIgnored( - folder, - this.plugin.settings.ignoredFolders, - this.plugin.settings.ignoredFolderPatterns, + folder, + this.plugin.settings.ignoredFolders, + this.plugin.settings.ignoredFolderPatterns, false // 在選擇資料夾時不考慮 showIgnoredFolders 設置 ); }) .sort((a, b) => a.path.localeCompare(b.path)); - + // 建立資料夾選項 folders.forEach(folder => { // 計算資料夾層級 const depth = (folder.path.match(/\//g) || []).length; const displayName = folder.path.split('/').pop() || '/'; - + const folderOption = this.folderOptionsContainer.createEl('div', { cls: 'ge-grid-view-folder-option', attr: { @@ -321,7 +323,7 @@ export class FolderSelectionModal extends Modal { 'data-path': folder.path } }); - + // 產生 ascii tree 前綴 const prefixSpan = document.createElement('span'); prefixSpan.className = 'ge-folder-tree-prefix'; @@ -359,12 +361,53 @@ export class FolderSelectionModal extends Modal { }); } + // 更新搜尋選項 + updateSearchOption(searchTerm: string) { + // 移除現有的搜尋選項 + if (this.searchOption) { + this.searchOption.remove(); + const index = this.folderOptions.indexOf(this.searchOption); + if (index > -1) { + this.folderOptions.splice(index, 1); + } + this.searchOption = null; + } + + // 如果有搜尋內容,添加搜尋選項 + if (searchTerm.length > 0) { + this.searchOption = this.folderOptionsContainer.createEl('div', { + cls: 'ge-grid-view-folder-option ge-search-option', + text: `🔍 ${t('search_for')} "${searchTerm}"` + }); + + this.searchOption.addEventListener('click', async () => { + if (this.activeView) { + await this.activeView.setSource('folder', '/', true, searchTerm); + } else { + const view = await this.plugin.activateView(); + if (view instanceof GridView) { + await view.setSource('folder', '/', true, searchTerm); + } + } + this.close(); + }); + + this.searchOption.addEventListener('mouseenter', () => { + const index = this.folderOptions.length; + this.updateSelection(index); + }); + + // 將搜尋選項添加到選項列表的最後 + this.folderOptions.push(this.searchOption); + } + } + // 處理鍵盤事件 handleKeyDown(event: KeyboardEvent) { const visibleOptions = this.getVisibleOptions(); - + if (visibleOptions.length === 0) return; - + switch (event.key) { case 'ArrowDown': event.preventDefault(); @@ -393,28 +436,28 @@ export class FolderSelectionModal extends Modal { moveSelection(direction: number, visibleOptions: HTMLElement[]) { // 如果沒有選中項或當前選中項不可見,則從頭開始 let currentVisibleIndex = -1; - + if (this.selectedIndex >= 0) { const selectedOption = this.folderOptions[this.selectedIndex]; currentVisibleIndex = visibleOptions.indexOf(selectedOption); } - + // 計算新的可見索引 let newVisibleIndex = currentVisibleIndex + direction; - + // 循環選擇 if (newVisibleIndex < 0) { newVisibleIndex = visibleOptions.length - 1; } else if (newVisibleIndex >= visibleOptions.length) { newVisibleIndex = 0; } - + // 轉換為實際的選項索引 if (newVisibleIndex >= 0 && newVisibleIndex < visibleOptions.length) { const newSelectedOption = visibleOptions[newVisibleIndex]; const newIndex = this.folderOptions.indexOf(newSelectedOption); this.updateSelection(newIndex); - + // 確保選中項在視圖中可見 newSelectedOption.scrollIntoView({ block: 'nearest' }); } @@ -426,9 +469,9 @@ export class FolderSelectionModal extends Modal { if (this.selectedIndex >= 0 && this.selectedIndex < this.folderOptions.length) { this.folderOptions[this.selectedIndex].removeClass('ge-selected-option'); } - + this.selectedIndex = index; - + // 設置新的選擇 if (this.selectedIndex >= 0 && this.selectedIndex < this.folderOptions.length) { this.folderOptions[this.selectedIndex].addClass('ge-selected-option'); @@ -437,7 +480,7 @@ export class FolderSelectionModal extends Modal { // 獲取當前可見的選項 getVisibleOptions(): HTMLElement[] { - return this.folderOptions.filter(option => + return this.folderOptions.filter(option => option.style.display !== 'none' ); } @@ -445,8 +488,13 @@ export class FolderSelectionModal extends Modal { // 篩選資料夾選項 filterFolderOptions(searchTerm: string) { let hasVisibleOptions = false; - + this.folderOptions.forEach(option => { + // 跳過搜尋選項,它會單獨處理 + if (option === this.searchOption) { + return; + } + // 根據搜尋狀態動態調整資料夾顯示文字 const dataPath = option.getAttribute('data-path'); if (dataPath) { @@ -486,10 +534,10 @@ export class FolderSelectionModal extends Modal { option.style.display = 'none'; } }); - + // 重置選擇,並選中第一個可見選項(如果有) this.updateSelection(-1); - + if (hasVisibleOptions) { const visibleOptions = this.getVisibleOptions(); if (visibleOptions.length > 0) { @@ -516,7 +564,7 @@ export class FolderSelectionModal extends Modal { // 計算位置 const viewportWidth = window.innerWidth; const viewportHeight = window.innerHeight; - + // 預設位置:按鈕下方中心對齊 let left = buttonRect.left + (buttonRect.width / 2) - 150; // 150 是 modal 寬度的一半 let top = buttonRect.bottom + 8; // 8px 間距 diff --git a/src/modal/inputModal.ts b/src/modal/inputModal.ts index c53cceb..19f36f3 100644 --- a/src/modal/inputModal.ts +++ b/src/modal/inputModal.ts @@ -2,7 +2,7 @@ import { App, Modal } from 'obsidian'; import { t } from '../translations'; export interface SearchOptions { - searchLocationFiles: boolean; + searchCurrentLocationOnly: boolean; searchFilesNameOnly: boolean; searchMediaFiles: boolean; } @@ -44,7 +44,7 @@ export class InputModal extends Modal { // 如果是搜尋文字,添加搜尋選項 let searchOptions: SearchOptions = { - searchLocationFiles: false, + searchCurrentLocationOnly: false, searchFilesNameOnly: false, searchMediaFiles: false }; @@ -57,14 +57,14 @@ export class InputModal extends Modal { const searchScopeCheckbox = searchScopeContainer.createEl('input', { type: 'checkbox', attr: { - id: 'searchLocationFiles' + id: 'searchCurrentLocationOnly' } }) as HTMLInputElement; - if (searchOptions.searchLocationFiles) { + if (searchOptions.searchCurrentLocationOnly) { searchScopeCheckbox.checked = true; } const searchScopeLabel = searchScopeContainer.createEl('label', { text: t('search_current_location_only') }); - searchScopeLabel.setAttribute('for', 'searchLocationFiles'); + searchScopeLabel.setAttribute('for', 'searchCurrentLocationOnly'); // 只搜尋檔名選項 const searchNameContainer = searchOptionsContainer.createDiv('ge-search-option'); @@ -97,7 +97,7 @@ export class InputModal extends Modal { // 更新搜尋選項 const updateSearchOptions = () => { searchOptions = { - searchLocationFiles: searchScopeCheckbox.checked, + searchCurrentLocationOnly: searchScopeCheckbox.checked, searchFilesNameOnly: searchNameCheckbox.checked, searchMediaFiles: searchMediaFilesCheckbox.checked }; diff --git a/src/modal/searchModal.ts b/src/modal/searchModal.ts index e6876c0..b25b5df 100644 --- a/src/modal/searchModal.ts +++ b/src/modal/searchModal.ts @@ -153,7 +153,7 @@ export class SearchModal extends Modal { type: 'checkbox', cls: 'ge-search-scope-checkbox' }); - searchScopeCheckbox.checked = !this.gridView.searchAllFiles; + searchScopeCheckbox.checked = this.gridView.searchCurrentLocationOnly; searchScopeContainer.createEl('span', { text: t('search_current_location_only'), cls: 'ge-search-scope-label' @@ -198,7 +198,7 @@ export class SearchModal extends Modal { searchScopeContainer.addEventListener('click', (e) => { if (e.target !== searchScopeCheckbox) { searchScopeCheckbox.checked = !searchScopeCheckbox.checked; - this.gridView.searchAllFiles = !searchScopeCheckbox.checked; + this.gridView.searchCurrentLocationOnly = !searchScopeCheckbox.checked; } }); searchNameContainer.addEventListener('click', (e) => { @@ -216,7 +216,7 @@ export class SearchModal extends Modal { // 勾選框變更時更新搜尋範圍 searchScopeCheckbox.addEventListener('change', () => { - this.gridView.searchAllFiles = !searchScopeCheckbox.checked; + this.gridView.searchCurrentLocationOnly = !searchScopeCheckbox.checked; }); searchMediaFilesCheckbox.addEventListener('change', () => { @@ -318,7 +318,7 @@ export class SearchModal extends Modal { // 先保存開啟 Modal 時的原始狀態 const originalSearchQuery = this.gridView.searchQuery; - const originalSearchAllFiles = this.gridView.searchAllFiles; + const originalsearchCurrentLocationOnly = this.gridView.searchCurrentLocationOnly; const originalSearchFilesNameOnly = this.gridView.searchFilesNameOnly; const originalSearchMediaFiles = this.gridView.searchMediaFiles; @@ -329,12 +329,12 @@ export class SearchModal extends Modal { this.gridView.sourceMode, this.gridView.sourcePath, originalSearchQuery, - originalSearchAllFiles, + originalsearchCurrentLocationOnly, originalSearchFilesNameOnly, originalSearchMediaFiles, ); this.gridView.searchQuery = searchInput.value; - this.gridView.searchAllFiles = !searchScopeCheckbox.checked; + this.gridView.searchCurrentLocationOnly = searchScopeCheckbox.checked; this.gridView.searchFilesNameOnly = searchNameCheckbox.checked; this.gridView.searchMediaFiles = searchMediaFilesCheckbox.checked; this.gridView.clearSelection(); diff --git a/src/modal/shortcutSelectionModal.ts b/src/modal/shortcutSelectionModal.ts index dc588f3..51f59a0 100644 --- a/src/modal/shortcutSelectionModal.ts +++ b/src/modal/shortcutSelectionModal.ts @@ -68,13 +68,6 @@ export class ShortcutSelectionModal extends Modal { // 點擊搜尋按鈕時打開搜尋輸入模態框 searchButton.addEventListener('click', () => { showSearchInputModal(this.app, (searchText, searchOptions) => { - const searchParams = new URLSearchParams(); - if (searchOptions) { - searchParams.set('allFiles', searchOptions.searchLocationFiles.toString()); - searchParams.set('nameOnly', searchOptions.searchFilesNameOnly.toString()); - searchParams.set('mediaOnly', searchOptions.searchMediaFiles.toString()); - } - this.onSubmit({ type: 'search', value: searchText, diff --git a/src/renderFiles.ts b/src/renderFiles.ts index 1a45559..35e99d1 100644 --- a/src/renderFiles.ts +++ b/src/renderFiles.ts @@ -17,7 +17,7 @@ export async function renderFiles(gridView: GridView, container: HTMLElement) { if (gridView.searchQuery) { // 取得 vault 中所有支援的檔案 let allFiles: TFile[] = []; - if (gridView.searchAllFiles) { + if (!gridView.searchCurrentLocationOnly) { // 全部檔案 allFiles = gridView.app.vault.getFiles().filter(file => isDocumentFile(file) || (isMediaFile(file) && gridView.searchMediaFiles) @@ -196,7 +196,7 @@ export async function renderFiles(gridView: GridView, container: HTMLElement) { ); // 排序檔案 - if (gridView.searchAllFiles) { + if (!gridView.searchCurrentLocationOnly) { // 搜尋所有檔案時 files = sortFiles(files, gridView); } else { @@ -236,7 +236,7 @@ export async function renderFiles(gridView: GridView, container: HTMLElement) { files = ignoredFiles(files, gridView); } else { // 無搜尋關鍵字的情況 - files = await getFiles(gridView, gridView.randomNoteIncludeMedia); + files = await getFiles(gridView, gridView.includeMedia); // 忽略檔案 files = ignoredFiles(files, gridView) diff --git a/src/renderHeaderButton.ts b/src/renderHeaderButton.ts index 156687c..87de17a 100644 --- a/src/renderHeaderButton.ts +++ b/src/renderHeaderButton.ts @@ -40,7 +40,7 @@ export function renderHeaderButton(gridView: GridView) { mode: gridView.sourceMode, path: gridView.sourcePath, searchQuery: gridView.searchQuery, - searchAllFiles: gridView.searchAllFiles, + searchCurrentLocationOnly: gridView.searchCurrentLocationOnly, searchFilesNameOnly: gridView.searchFilesNameOnly, searchMediaFiles: gridView.searchMediaFiles, }); @@ -59,7 +59,7 @@ export function renderHeaderButton(gridView: GridView) { lastSource.path || '', false, // 不記錄到歷史 lastSource.searchQuery || '', - lastSource.searchAllFiles ?? true, + lastSource.searchCurrentLocationOnly ?? false, lastSource.searchFilesNameOnly ?? false, lastSource.searchMediaFiles ?? false ); @@ -83,7 +83,7 @@ export function renderHeaderButton(gridView: GridView) { mode: gridView.sourceMode, path: gridView.sourcePath, searchQuery: gridView.searchQuery, - searchAllFiles: gridView.searchAllFiles, + searchCurrentLocationOnly: gridView.searchCurrentLocationOnly, searchFilesNameOnly: gridView.searchFilesNameOnly, searchMediaFiles: gridView.searchMediaFiles, }); @@ -102,7 +102,7 @@ export function renderHeaderButton(gridView: GridView) { nextSource.path || '', false, // 不記錄到歷史 nextSource.searchQuery || '', - nextSource.searchAllFiles ?? true, + nextSource.searchCurrentLocationOnly ?? false, nextSource.searchFilesNameOnly ?? false, nextSource.searchMediaFiles ?? false ); @@ -180,7 +180,7 @@ export function renderHeaderButton(gridView: GridView) { // 處理搜尋顯示文字 if (sourceInfo.searchQuery) { - if (sourceInfo.searchAllFiles) { + if (!sourceInfo.searchCurrentLocationOnly) { // 全域搜尋僅顯示搜尋字串 displayText = '"' + (sourceInfo.searchQuery || t('search_results')) + '"'; } else { @@ -200,7 +200,7 @@ export function renderHeaderButton(gridView: GridView) { mode: gridView.sourceMode, path: gridView.sourcePath, searchQuery: gridView.searchQuery, - searchAllFiles: gridView.searchAllFiles, + searchCurrentLocationOnly: gridView.searchCurrentLocationOnly, searchFilesNameOnly: gridView.searchFilesNameOnly, searchMediaFiles: gridView.searchMediaFiles, }); @@ -224,7 +224,7 @@ export function renderHeaderButton(gridView: GridView) { path, false, // 不記錄到歷史 sourceInfo.searchQuery || '', - sourceInfo.searchAllFiles ?? true, + sourceInfo.searchCurrentLocationOnly ?? false, sourceInfo.searchFilesNameOnly ?? false, sourceInfo.searchMediaFiles ?? false ); @@ -308,7 +308,7 @@ export function renderHeaderButton(gridView: GridView) { // 處理搜尋顯示文字 if (sourceInfo.searchQuery) { - if (sourceInfo.searchAllFiles) { + if (!sourceInfo.searchCurrentLocationOnly) { displayText = '"' + (sourceInfo.searchQuery || t('search_results')) + '"'; } else { displayText += `: \"${sourceInfo.searchQuery}\"`; @@ -325,7 +325,7 @@ export function renderHeaderButton(gridView: GridView) { mode: gridView.sourceMode, path: gridView.sourcePath, searchQuery: gridView.searchQuery, - searchAllFiles: gridView.searchAllFiles, + searchCurrentLocationOnly: gridView.searchCurrentLocationOnly, searchFilesNameOnly: gridView.searchFilesNameOnly, searchMediaFiles: gridView.searchMediaFiles, }); @@ -348,7 +348,7 @@ export function renderHeaderButton(gridView: GridView) { path, false, sourceInfo.searchQuery || '', - sourceInfo.searchAllFiles ?? true, + sourceInfo.searchCurrentLocationOnly ?? false, sourceInfo.searchFilesNameOnly ?? false, sourceInfo.searchMediaFiles ?? false ); @@ -520,7 +520,7 @@ export function renderHeaderButton(gridView: GridView) { // 先保存開啟 Modal 時的原始狀態 const originalSearchQuery = gridView.searchQuery; - const originalSearchAllFiles = gridView.searchAllFiles; + const originalsearchCurrentLocationOnly = gridView.searchCurrentLocationOnly; const originalSearchFilesNameOnly = gridView.searchFilesNameOnly; const originalSearchMediaFiles = gridView.searchMediaFiles; @@ -533,7 +533,7 @@ export function renderHeaderButton(gridView: GridView) { gridView.sourceMode, gridView.sourcePath, originalSearchQuery, - originalSearchAllFiles, + originalsearchCurrentLocationOnly, originalSearchFilesNameOnly, originalSearchMediaFiles, ); @@ -765,7 +765,7 @@ async function createShortcut( value: string; display: string; searchOptions?: { - searchLocationFiles: boolean; + searchCurrentLocationOnly: boolean; searchFilesNameOnly: boolean; searchMediaFiles: boolean; }; @@ -813,7 +813,7 @@ async function createShortcut( frontmatter.redirect = option.value; // 添加搜尋選項到 frontmatter if (option.searchOptions) { - frontmatter.searchLocationFiles = option.searchOptions.searchLocationFiles; + frontmatter.searchCurrentLocationOnly = option.searchOptions.searchCurrentLocationOnly; frontmatter.searchFilesNameOnly = option.searchOptions.searchFilesNameOnly; frontmatter.searchMediaFiles = option.searchOptions.searchMediaFiles; } diff --git a/src/renderModePath.ts b/src/renderModePath.ts index 247d771..b10743a 100644 --- a/src/renderModePath.ts +++ b/src/renderModePath.ts @@ -81,7 +81,7 @@ export function renderModePath(gridView: GridView) { // 顯示目前資料夾及完整路徑 if (gridView.sourceMode === 'folder' && - (gridView.searchQuery === '' || (gridView.searchQuery && !gridView.searchAllFiles))) { + (gridView.searchQuery === '' || (gridView.searchQuery && gridView.searchCurrentLocationOnly))) { // 分割路徑 const pathParts = gridView.sourcePath.split('/').filter(part => part.trim() !== ''); @@ -468,7 +468,7 @@ export function renderModePath(gridView: GridView) { }); } } - } else if (!(gridView.searchQuery !== '' && gridView.searchAllFiles)) { + } else if (!(gridView.searchQuery && !gridView.searchCurrentLocationOnly)) { // 顯示目前模式名稱 let modeName = ''; @@ -582,25 +582,25 @@ export function renderModePath(gridView: GridView) { case 'all-files': if (gridView.plugin.settings.showMediaFiles && gridView.searchQuery === '') { // "顯示類型"選項 - const showTypeName = gridView.randomNoteIncludeMedia ? t('random_note_include_media_files') : t('random_note_notes_only'); + const showTypeName = gridView.includeMedia ? t('random_note_include_media_files') : t('random_note_notes_only'); const showTypeSpan = modenameContainer.createEl('a', { text: showTypeName, cls: 'ge-sub-option' }); showTypeSpan.addEventListener('click', (evt) => { const menu = new Menu(); menu.addItem((item) => { item.setTitle(t('random_note_notes_only')) .setIcon('file-text') - .setChecked(!gridView.randomNoteIncludeMedia) + .setChecked(!gridView.includeMedia) .onClick(() => { - gridView.randomNoteIncludeMedia = false; + gridView.includeMedia = false; gridView.render(); }); }); menu.addItem((item) => { item.setTitle(t('random_note_include_media_files')) .setIcon('file-image') - .setChecked(gridView.randomNoteIncludeMedia) + .setChecked(gridView.includeMedia) .onClick(() => { - gridView.randomNoteIncludeMedia = true; + gridView.includeMedia = true; gridView.render(); }); }); @@ -710,7 +710,7 @@ export function renderModePath(gridView: GridView) { } break; } - } else if (gridView.searchQuery !== '' && gridView.searchAllFiles) { + } else if (gridView.searchQuery && !gridView.searchCurrentLocationOnly) { // 顯示全域搜尋名稱 modenameContainer.createEl('span', { text: `🔍 ${t('global_search')}`, diff --git a/src/settings.ts b/src/settings.ts index 31c48ee..d9ab652 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -70,7 +70,9 @@ export interface GallerySettings { quickAccessModeType: string; // View types used by "Open quick access view" command useQuickAccessAsNewTabMode: 'default' | 'folder' | 'mode'; // Use quick access (folder or mode) as a new tab view showNoteInGrid: boolean; // 是否預設在 grid container 中顯示筆記(不需要按 Alt 鍵) - + searchCurrentLocationOnly: boolean; // 是否只搜尋當前位置 + searchFilesNameOnly: boolean; // 是否只搜尋筆記名稱 + searchMediaFiles: boolean; // 是否搜尋媒體檔案 } // 預設設定 @@ -132,6 +134,9 @@ export const DEFAULT_SETTINGS: GallerySettings = { useQuickAccessAsNewTabMode: 'default', quickAccessModeType: 'all-files', // Default quick access view type showNoteInGrid: false, // 預設不在 grid container 中顯示筆記 + searchCurrentLocationOnly: false, // 預設搜尋所有筆記 + searchFilesNameOnly: false, // 預設不只搜尋筆記名稱 + searchMediaFiles: false, // 預設不搜尋媒體檔案 }; // 資料夾選擇器 @@ -151,7 +156,7 @@ class FolderSuggest extends AbstractInputSuggest { .map(folder => folder.path) .filter(path => path.toLowerCase().includes(lowerCaseInputStr)) .sort((a, b) => a.localeCompare(b)); - + if ('/'.includes(lowerCaseInputStr)) { if (!suggestions.includes('/')) { suggestions.unshift('/'); @@ -465,15 +470,15 @@ export class GridExplorerSettingTab extends PluginSettingTab { // 設定是否顯示所有檔案模式 new Setting(containerEl) - .setName(`📔 ${t('show_all_files_mode')}`) - .addToggle(toggle => { - toggle - .setValue(this.plugin.settings.showAllFilesMode) - .onChange(async (value) => { - this.plugin.settings.showAllFilesMode = value; - await this.plugin.saveSettings(); - }); - }); + .setName(`📔 ${t('show_all_files_mode')}`) + .addToggle(toggle => { + toggle + .setValue(this.plugin.settings.showAllFilesMode) + .onChange(async (value) => { + this.plugin.settings.showAllFilesMode = value; + await this.plugin.saveSettings(); + }); + }); // 最近檔案模式設定 const recentFilesSetting = new Setting(containerEl) @@ -563,16 +568,16 @@ export class GridExplorerSettingTab extends PluginSettingTab { // 重用現有的網格視圖 new Setting(containerEl) - .setName(t('reuse_existing_leaf')) - .setDesc(t('reuse_existing_leaf_desc')) - .addToggle(toggle => { - toggle - .setValue(this.plugin.settings.reuseExistingLeaf) - .onChange(async (value) => { - this.plugin.settings.reuseExistingLeaf = value; - await this.plugin.saveSettings(); - }); - }); + .setName(t('reuse_existing_leaf')) + .setDesc(t('reuse_existing_leaf_desc')) + .addToggle(toggle => { + toggle + .setValue(this.plugin.settings.reuseExistingLeaf) + .onChange(async (value) => { + this.plugin.settings.reuseExistingLeaf = value; + await this.plugin.saveSettings(); + }); + }); // 預設開啟位置設定 new Setting(containerEl) @@ -612,33 +617,33 @@ export class GridExplorerSettingTab extends PluginSettingTab { // 日期分隔器模式設定 new Setting(containerEl) - .setName(t('date_divider_mode')) - .setDesc(t('date_divider_mode_desc')) - .addDropdown(dropdown => { - dropdown - .addOption('none', t('date_divider_mode_none')) - .addOption('year', t('date_divider_mode_year')) - .addOption('month', t('date_divider_mode_month')) - .addOption('day', t('date_divider_mode_day')) - .setValue(this.plugin.settings.dateDividerMode) - .onChange(async (value) => { - this.plugin.settings.dateDividerMode = value; - await this.plugin.saveSettings(); - }); - }); + .setName(t('date_divider_mode')) + .setDesc(t('date_divider_mode_desc')) + .addDropdown(dropdown => { + dropdown + .addOption('none', t('date_divider_mode_none')) + .addOption('year', t('date_divider_mode_year')) + .addOption('month', t('date_divider_mode_month')) + .addOption('day', t('date_divider_mode_day')) + .setValue(this.plugin.settings.dateDividerMode) + .onChange(async (value) => { + this.plugin.settings.dateDividerMode = value; + await this.plugin.saveSettings(); + }); + }); // 隱藏資料夾 new Setting(containerEl) - .setName(t('show_folder')) - .setDesc(t('show_folder_desc')) - .addToggle(toggle => { - toggle - .setValue(this.plugin.settings.showFolder) - .onChange(async (value) => { - this.plugin.settings.showFolder = value; - await this.plugin.saveSettings(); - }); - }); + .setName(t('show_folder')) + .setDesc(t('show_folder_desc')) + .addToggle(toggle => { + toggle + .setValue(this.plugin.settings.showFolder) + .onChange(async (value) => { + this.plugin.settings.showFolder = value; + await this.plugin.saveSettings(); + }); + }); // 顯示圖片和影片設定 new Setting(containerEl) @@ -665,7 +670,7 @@ export class GridExplorerSettingTab extends PluginSettingTab { await this.plugin.saveSettings(); }); }); - + // 是否預設顯示筆記 new Setting(containerEl) .setName(t('show_note_in_grid')) @@ -677,82 +682,82 @@ export class GridExplorerSettingTab extends PluginSettingTab { this.plugin.settings.showNoteInGrid = value; await this.plugin.saveSettings(); }); - }); + }); // 筆記標題欄位名稱設定 new Setting(containerEl) - .setName(t('note_title_field')) - .setDesc(t('note_title_field_desc')) - .addText(text => text - .setPlaceholder('title') - .setValue(this.plugin.settings.noteTitleField) - .onChange(async (value) => { - this.plugin.settings.noteTitleField = value; - await this.plugin.saveSettings(false); - })); + .setName(t('note_title_field')) + .setDesc(t('note_title_field_desc')) + .addText(text => text + .setPlaceholder('title') + .setValue(this.plugin.settings.noteTitleField) + .onChange(async (value) => { + this.plugin.settings.noteTitleField = value; + await this.plugin.saveSettings(false); + })); // 筆記摘要欄位名稱設定 new Setting(containerEl) - .setName(t('note_summary_field')) - .setDesc(t('note_summary_field_desc')) - .addText(text => text - .setPlaceholder('summary') - .setValue(this.plugin.settings.noteSummaryField) - .onChange(async (value) => { - this.plugin.settings.noteSummaryField = value; - await this.plugin.saveSettings(false); - })); + .setName(t('note_summary_field')) + .setDesc(t('note_summary_field_desc')) + .addText(text => text + .setPlaceholder('summary') + .setValue(this.plugin.settings.noteSummaryField) + .onChange(async (value) => { + this.plugin.settings.noteSummaryField = value; + await this.plugin.saveSettings(false); + })); // 修改時間欄位名稱設定 new Setting(containerEl) - .setName(t('modified_date_field')) - .setDesc(t('modified_date_field_desc')) - .addText(text => text - .setPlaceholder('modified_date') - .setValue(this.plugin.settings.modifiedDateField) - .onChange(async (value) => { - this.plugin.settings.modifiedDateField = value; - await this.plugin.saveSettings(false); - })); + .setName(t('modified_date_field')) + .setDesc(t('modified_date_field_desc')) + .addText(text => text + .setPlaceholder('modified_date') + .setValue(this.plugin.settings.modifiedDateField) + .onChange(async (value) => { + this.plugin.settings.modifiedDateField = value; + await this.plugin.saveSettings(false); + })); // 建立時間欄位名稱設定 new Setting(containerEl) - .setName(t('created_date_field')) - .setDesc(t('created_date_field_desc')) - .addText(text => text - .setPlaceholder('created_date') - .setValue(this.plugin.settings.createdDateField) - .onChange(async (value) => { - this.plugin.settings.createdDateField = value; - await this.plugin.saveSettings(false); - })); + .setName(t('created_date_field')) + .setDesc(t('created_date_field_desc')) + .addText(text => text + .setPlaceholder('created_date') + .setValue(this.plugin.settings.createdDateField) + .onChange(async (value) => { + this.plugin.settings.createdDateField = value; + await this.plugin.saveSettings(false); + })); // 自訂文件副檔名設定 new Setting(containerEl) - .setName(t('custom_document_extensions')) - .setDesc(t('custom_document_extensions_desc')) - .addText(text => { - text - .setPlaceholder(t('custom_document_extensions_placeholder')) - .setValue(this.plugin.settings.customDocumentExtensions) - .onChange(async (value) => { - this.plugin.settings.customDocumentExtensions = value; - await this.plugin.saveSettings(); - }); - }); + .setName(t('custom_document_extensions')) + .setDesc(t('custom_document_extensions_desc')) + .addText(text => { + text + .setPlaceholder(t('custom_document_extensions_placeholder')) + .setValue(this.plugin.settings.customDocumentExtensions) + .onChange(async (value) => { + this.plugin.settings.customDocumentExtensions = value; + await this.plugin.saveSettings(); + }); + }); // 自訂資料夾圖示 new Setting(containerEl) - .setName(t('custom_folder_icon')) - .setDesc(t('custom_folder_icon_desc')) - .addText(text => { - text - .setValue(this.plugin.settings.customFolderIcon) - .onChange(async (value) => { - this.plugin.settings.customFolderIcon = value; - await this.plugin.saveSettings(); - }); - }); + .setName(t('custom_folder_icon')) + .setDesc(t('custom_folder_icon_desc')) + .addText(text => { + text + .setValue(this.plugin.settings.customFolderIcon) + .onChange(async (value) => { + this.plugin.settings.customFolderIcon = value; + await this.plugin.saveSettings(); + }); + }); // 檔案監控功能設定 new Setting(containerEl) @@ -793,8 +798,7 @@ export class GridExplorerSettingTab extends PluginSettingTab { }); }); - - + // 網格項目樣式設定標題 containerEl.createEl('h3', { text: t('grid_item_style_settings'), attr: { style: 'margin-top: 40px;' } }); @@ -814,16 +818,16 @@ export class GridExplorerSettingTab extends PluginSettingTab { // 顯示筆記標籤設定 new Setting(containerEl) - .setName(t('show_note_tags')) - .setDesc(t('show_note_tags_desc')) - .addToggle(toggle => { - toggle - .setValue(this.plugin.settings.showNoteTags) - .onChange(async (value) => { - this.plugin.settings.showNoteTags = value; - await this.plugin.saveSettings(); - }); - }); + .setName(t('show_note_tags')) + .setDesc(t('show_note_tags_desc')) + .addToggle(toggle => { + toggle + .setValue(this.plugin.settings.showNoteTags) + .onChange(async (value) => { + this.plugin.settings.showNoteTags = value; + await this.plugin.saveSettings(); + }); + }); // 網格項目寬度設定 const gridItemWidthSetting = new Setting(containerEl) @@ -892,7 +896,7 @@ export class GridExplorerSettingTab extends PluginSettingTab { // 直向卡片 - 網格項目寬度 const vGridItemWidthSetting = new Setting(containerEl) .setName(`${t('vertical_card')} ${t('grid_item_width')}`) - .setDesc(`${t('grid_item_width_desc')} (now: ${this.plugin.settings.verticalGridItemWidth}px)`) + .setDesc(`${t('grid_item_width_desc')} (now: ${this.plugin.settings.verticalGridItemWidth}px)`) .addSlider(slider => { slider.setLimits(100, 600, 10) .setValue(this.plugin.settings.verticalGridItemWidth) @@ -907,7 +911,7 @@ export class GridExplorerSettingTab extends PluginSettingTab { // 直向卡片 - 網格項目高度 const vGridItemHeightSetting = new Setting(containerEl) .setName(`${t('vertical_card')} ${t('grid_item_height')}`) - .setDesc(`${t('grid_item_height_desc')} (now: ${this.plugin.settings.verticalGridItemHeight}px)`) + .setDesc(`${t('grid_item_height_desc')} (now: ${this.plugin.settings.verticalGridItemHeight}px)`) .addSlider(slider => { slider.setLimits(0, 600, 10) .setValue(this.plugin.settings.verticalGridItemHeight) @@ -922,7 +926,7 @@ export class GridExplorerSettingTab extends PluginSettingTab { // 直向卡片 - 圖片區域高度 const vImageAreaHeightSetting = new Setting(containerEl) .setName(`${t('vertical_card')} ${t('image_area_height')}`) - .setDesc(`${t('image_area_height_desc')} (now: ${this.plugin.settings.verticalImageAreaHeight}px)`) + .setDesc(`${t('image_area_height_desc')} (now: ${this.plugin.settings.verticalImageAreaHeight}px)`) .addSlider(slider => { slider.setLimits(50, 400, 10) .setValue(this.plugin.settings.verticalImageAreaHeight) @@ -954,14 +958,14 @@ export class GridExplorerSettingTab extends PluginSettingTab { .setDesc(`${t('title_font_size_desc')} (now: ${this.plugin.settings.titleFontSize.toFixed(2)})`) .addSlider(slider => { slider - .setLimits(0.8, 1.5, 0.05) - .setValue(this.plugin.settings.titleFontSize) - .setDynamicTooltip() - .onChange(async (value) => { - titleFontSizeSetting.setDesc(`${t('title_font_size_desc')} (now: ${value.toFixed(2)})`); - this.plugin.settings.titleFontSize = value; - await this.plugin.saveSettings(); - }); + .setLimits(0.8, 1.5, 0.05) + .setValue(this.plugin.settings.titleFontSize) + .setDynamicTooltip() + .onChange(async (value) => { + titleFontSizeSetting.setDesc(`${t('title_font_size_desc')} (now: ${value.toFixed(2)})`); + this.plugin.settings.titleFontSize = value; + await this.plugin.saveSettings(); + }); }); // 標題支援多行顯示 @@ -995,15 +999,56 @@ export class GridExplorerSettingTab extends PluginSettingTab { // 是否在摘要中顯示程式碼區塊 new Setting(containerEl) - .setName(t('show_code_block_in_summary')) - .setDesc(t('show_code_block_in_summary_desc')) - .addToggle(toggle => toggle - .setValue(this.plugin.settings.showCodeBlocksInSummary) - .onChange(async (value) => { - this.plugin.settings.showCodeBlocksInSummary = value; - await this.plugin.saveSettings(); - })); + .setName(t('show_code_block_in_summary')) + .setDesc(t('show_code_block_in_summary_desc')) + .addToggle(toggle => toggle + .setValue(this.plugin.settings.showCodeBlocksInSummary) + .onChange(async (value) => { + this.plugin.settings.showCodeBlocksInSummary = value; + await this.plugin.saveSettings(); + })); + + // 搜尋設定區域 + containerEl.createEl('h3', { text: t('default_search_option'), attr: { style: 'margin-top: 40px;' } }); + + // 是否只搜尋當前位置 + new Setting(containerEl) + .setName(t('search_current_location_only')) + .addToggle(toggle => { + toggle + .setValue(this.plugin.settings.searchCurrentLocationOnly) + .onChange(async (value) => { + this.plugin.settings.searchCurrentLocationOnly = value; + await this.plugin.saveSettings(); + }); + }); + + // 是否只搜尋筆記名稱 + new Setting(containerEl) + .setName(t('search_files_name_only')) + .addToggle(toggle => { + toggle + .setValue(this.plugin.settings.searchFilesNameOnly) + .onChange(async (value) => { + this.plugin.settings.searchFilesNameOnly = value; + await this.plugin.saveSettings(); + }); + }); + + // 是否搜尋媒體檔案 + new Setting(containerEl) + .setName(t('search_media_files')) + .addToggle(toggle => { + toggle + .setValue(this.plugin.settings.searchMediaFiles) + .onChange(async (value) => { + this.plugin.settings.searchMediaFiles = value; + await this.plugin.saveSettings(); + }); + }); + + // 資料夾筆記設定區域 containerEl.createEl('h3', { text: t('folder_note_settings'), attr: { style: 'margin-top: 40px;' } }); @@ -1043,43 +1088,43 @@ export class GridExplorerSettingTab extends PluginSettingTab { // Quick Access View Setting new Setting(containerEl) - .setName(t('quick_access_mode_name')) - .setDesc(t('quick_access_mode_desc')) - .addDropdown(dropdown => { - for(let i = 0; i < this.plugin.settings.customModes.length; i++) { - dropdown.addOption(this.plugin.settings.customModes[i].internalName, `🧩 ${this.plugin.settings.customModes[i].displayName}`); - } - dropdown - .addOption('bookmarks', `📑 ${t('bookmarks_mode')}`) - .addOption('search', `🔍 ${t('search_results')}`) - .addOption('backlinks', `🔗 ${t('backlinks_mode')}`) - .addOption('outgoinglinks', `🔗 ${t('outgoinglinks_mode')}`) - .addOption('all-files', `📔 ${t('all_files_mode')}`) - .addOption('recent-files', `📅 ${t('recent_files_mode')}`) - .addOption('random-note', `🎲 ${t('random_note_mode')}`) - .addOption('tasks', `☑️ ${t('tasks_mode')}`) - .setValue(this.plugin.settings.quickAccessModeType) - .onChange(async (value: string) => { - this.plugin.settings.quickAccessModeType = value; - await this.plugin.saveSettings(false); - }); - }); + .setName(t('quick_access_mode_name')) + .setDesc(t('quick_access_mode_desc')) + .addDropdown(dropdown => { + for (let i = 0; i < this.plugin.settings.customModes.length; i++) { + dropdown.addOption(this.plugin.settings.customModes[i].internalName, `🧩 ${this.plugin.settings.customModes[i].displayName}`); + } + dropdown + .addOption('bookmarks', `📑 ${t('bookmarks_mode')}`) + .addOption('search', `🔍 ${t('search_results')}`) + .addOption('backlinks', `🔗 ${t('backlinks_mode')}`) + .addOption('outgoinglinks', `🔗 ${t('outgoinglinks_mode')}`) + .addOption('all-files', `📔 ${t('all_files_mode')}`) + .addOption('recent-files', `📅 ${t('recent_files_mode')}`) + .addOption('random-note', `🎲 ${t('random_note_mode')}`) + .addOption('tasks', `☑️ ${t('tasks_mode')}`) + .setValue(this.plugin.settings.quickAccessModeType) + .onChange(async (value: string) => { + this.plugin.settings.quickAccessModeType = value; + await this.plugin.saveSettings(false); + }); + }); // Use Quick Access as a new tab view new Setting(containerEl) - .setName(t('use_quick_access_as_new_tab_view')) - .setDesc(t('use_quick_access_as_new_tab_view_desc')) - .addDropdown(dropdown => { - dropdown - .addOption('default', t('default_new_tab')) - .addOption('folder', t('use_quick_access_folder')) - .addOption('mode', t('use_quick_access_mode')) - .setValue(this.plugin.settings.useQuickAccessAsNewTabMode) - .onChange(async (value: 'default' | 'folder' | 'mode') => { - this.plugin.settings.useQuickAccessAsNewTabMode = value; - await this.plugin.saveSettings(false); - }); - }); + .setName(t('use_quick_access_as_new_tab_view')) + .setDesc(t('use_quick_access_as_new_tab_view_desc')) + .addDropdown(dropdown => { + dropdown + .addOption('default', t('default_new_tab')) + .addOption('folder', t('use_quick_access_folder')) + .addOption('mode', t('use_quick_access_mode')) + .setValue(this.plugin.settings.useQuickAccessAsNewTabMode) + .onChange(async (value: 'default' | 'folder' | 'mode') => { + this.plugin.settings.useQuickAccessAsNewTabMode = value; + await this.plugin.saveSettings(false); + }); + }); // 忽略資料夾設定區域 containerEl.createEl('h3', { text: t('ignored_folders_settings'), attr: { style: 'margin-top: 40px;' } }); diff --git a/src/translations.ts b/src/translations.ts index 0f7dca8..95fab4e 100644 --- a/src/translations.ts +++ b/src/translations.ts @@ -1,8 +1,7 @@ -import { getLanguage } from 'obsidian'; interface Translations { 'zh-TW': { [key: string]: string }; - 'en': { [key: string]: string }; + 'en': { [key: string]: string }; 'zh': { [key: string]: string }; 'ja': { [key: string]: string }; 'ru': { [key: string]: string }; @@ -32,6 +31,7 @@ export const TRANSLATIONS: Translations = { 'no_backlinks': '沒有反向連結', 'back': '返回', 'search': '搜尋', + 'default_search_option': '預設搜尋選項', 'search_placeholder': '搜尋關鍵字', 'search_current_location_only': '僅搜尋目前位置', 'search_files_name_only': '僅搜尋檔名', @@ -111,7 +111,7 @@ export const TRANSLATIONS: Translations = { 'note_summary_field_desc': '指定 frontmatter 中用於筆記摘要的欄位名稱', 'modified_date_field': '"修改時間"欄位名稱', 'modified_date_field_desc': '指定 frontmatter 中用於筆記修改時間的欄位名稱 (支援多個欄位名稱,用逗號分隔)', - 'created_date_field': '"建立時間"欄位名稱', + 'created_date_field': '"建立時間"欄位名稱', 'created_date_field_desc': '指定 frontmatter 中用於筆記建立時間的欄位名稱 (支援多個欄位名稱,用逗號分隔)', 'grid_item_width': '網格項目寬度', 'grid_item_width_desc': '設定網格項目的寬度', @@ -144,7 +144,7 @@ export const TRANSLATIONS: Translations = { 'intercept_all_tag_clicks_desc': '啟用後會攔截所有標籤點擊事件,並在網格視圖中打開標籤', 'intercept_breadcrumb_clicks': '攔截筆記導航列點擊事件', 'intercept_breadcrumb_clicks_desc': '啟用後會攔截筆記導航列點擊事件,並在網格視圖中打開路徑', - 'reset_to_default' : '重置為預設值', + 'reset_to_default': '重置為預設值', 'settings_reset_notice': '設定值已重置為預設值', 'config_management': '設定檔管理', 'config_management_desc': '管理設定檔的重置、匯出和匯入', @@ -186,10 +186,10 @@ export const TRANSLATIONS: Translations = { 'all': '全部', 'default': '預設', 'hidden': '隱藏', - + // 隱藏頂部元素 'hide_header_elements': '隱藏頂部元素', - + // 預設開啟位置設定 'default_open_location': '預設開啟位置', 'default_open_location_desc': '設定網格視圖預設開啟的位置', @@ -230,6 +230,7 @@ export const TRANSLATIONS: Translations = { 'searching': '搜尋中...', 'no_files': '沒有找到任何檔案', 'filter_folders': '篩選資料夾...', + 'search_for': '搜尋', // 快捷方式選擇對話框 'create_shortcut': '建立捷徑', @@ -314,6 +315,7 @@ export const TRANSLATIONS: Translations = { 'no_backlinks': 'No backlinks', 'back': 'Back', 'search': 'Search', + 'default_search_option': 'Default search option', 'search_placeholder': 'Search keyword', 'search_current_location_only': 'Search current location only', 'search_files_name_only': 'Search files name only', @@ -393,7 +395,7 @@ export const TRANSLATIONS: Translations = { 'note_summary_field_desc': 'Set the field name in frontmatter to use for the note summary', 'modified_date_field': '"Modified date" field name', 'modified_date_field_desc': 'Set the field name in frontmatter to use for the modified date (support multiple field names, separated by commas)', - 'created_date_field': '"Created date" field name', + 'created_date_field': '"Created date" field name', 'created_date_field_desc': 'Set the field name in frontmatter to use for the created date (support multiple field names, separated by commas)', 'grid_item_width': 'Grid item width', 'grid_item_width_desc': 'Set the width of grid items', @@ -468,10 +470,10 @@ export const TRANSLATIONS: Translations = { 'all': 'All', 'default': 'Default', 'hidden': 'Hidden', - + // Hide header elements setting 'hide_header_elements': 'Hide header elements', - + // Default open location setting 'default_open_location': 'Default open location', 'default_open_location_desc': 'Set the default location to open the grid view', @@ -512,6 +514,7 @@ export const TRANSLATIONS: Translations = { 'searching': 'Searching...', 'no_files': 'No files found', 'filter_folders': 'Filter folders...', + 'search_for': 'Search for', // Shortcut Selection Dialog 'create_shortcut': 'Create Shortcut', @@ -520,7 +523,7 @@ export const TRANSLATIONS: Translations = { 'target_not_found': 'Target not found', 'shortcut_created': 'Shortcut created', 'failed_to_create_shortcut': 'Failed to create shortcut', - + // Folder Note Settings Dialog 'folder_note_settings': 'Folder Note Settings', 'folder_sort_type': 'Folder Sort Type', @@ -596,6 +599,7 @@ export const TRANSLATIONS: Translations = { 'no_backlinks': '没有反向链接', 'back': '返回', 'search': '搜索', + 'default_search_option': '默认搜索选项', 'search_placeholder': '搜索关键字', 'search_current_location_only': '仅搜索当前位置', 'search_files_name_only': '仅搜索文件名', @@ -695,7 +699,7 @@ export const TRANSLATIONS: Translations = { 'image_position': '图片位置', 'image_position_desc': '设置图片的位置', 'top': '顶部', - 'bottom': '底部', + 'bottom': '底部', 'multi_line_title': '标题支持多行显示', 'multi_line_title_desc': '设置是否允许标题多行显示', 'show_code_block_in_summary': '摘要中显示CodeBlock', @@ -748,10 +752,10 @@ export const TRANSLATIONS: Translations = { 'all': '全部', 'default': '默认', 'hidden': '隐藏', - + // 隐藏頂部元素 'hide_header_elements': '隱藏頂部元素', - + // 默认打开位置设置 'default_open_location': '默认打开位置', 'default_open_location_desc': '设置网格视图默认打开的位置', @@ -792,6 +796,7 @@ export const TRANSLATIONS: Translations = { 'searching': '搜索中...', 'no_files': '没有找到任何文件', 'filter_folders': '筛选文件夹...', + 'search_for': '搜索', // 快捷方式选择对话框 'create_shortcut': '创建快捷方式', @@ -800,7 +805,7 @@ export const TRANSLATIONS: Translations = { 'target_not_found': '目标未找到', 'shortcut_created': '快捷方式已创建', 'failed_to_create_shortcut': '创建快捷方式失败', - + // 文件夹笔记设置对话框 'folder_note_settings': '文件夹笔记设置', 'folder_sort_type': '文件夹排序方式', @@ -852,7 +857,7 @@ export const TRANSLATIONS: Translations = { // Quick Access Settings and Commands - 'quick_access_settings_title': '快速访问设置', + 'quick_access_settings_title': '快速访问设置', 'quick_access_folder_name': '快速访问文件夹', 'quick_access_folder_desc': '设置“打开快速访问文件夹”命令使用的文件夹', 'quick_access_mode_name': '快速访问模式', @@ -876,6 +881,7 @@ export const TRANSLATIONS: Translations = { 'no_backlinks': 'バックリンクなし', 'back': '戻る', 'search': '検索', + 'default_search_option': 'デフォルト検索オプション', 'search_placeholder': 'キーワード検索', 'search_current_location_only': '現在の場所のみ検索', 'search_files_name_only': 'ファイル名のみ検索', @@ -1028,10 +1034,10 @@ export const TRANSLATIONS: Translations = { 'all': 'すべて', 'default': 'デフォルト', 'hidden': '隠す', - + // 隠す頂部元素 'hide_header_elements': '頂部元素を隠す', - + // 開く場所設定 'default_open_location': 'デフォルトの開く場所', 'default_open_location_desc': 'グリッドビューを開くデフォルトの場所を設定', @@ -1072,6 +1078,7 @@ export const TRANSLATIONS: Translations = { 'searching': '検索中...', 'no_files': 'ファイルが見つかりません', 'filter_folders': 'フォルダをフィルタリング...', + 'search_for': '検索', // ショートカット選択ダイアログ 'create_shortcut': 'ショートカットを作成', @@ -1157,6 +1164,7 @@ export const TRANSLATIONS: Translations = { 'no_backlinks': 'Нет обратных ссылок', 'back': 'Назад', 'search': 'Поиск', + 'default_search_option': 'По умолчанию', 'search_placeholder': 'Ключевое слово для поиска', 'search_current_location_only': 'Искать только в текущем расположении', 'search_files_name_only': 'Искать только в названии файлов', @@ -1309,10 +1317,10 @@ export const TRANSLATIONS: Translations = { 'all': 'Все', 'default': 'По умолчанию', 'hidden': 'Скрытые', - + // Hide header elements setting 'hide_header_elements': 'Скрыть элементы заголовка', - + // Default open location setting 'default_open_location': 'Место открытия по умолчанию', 'default_open_location_desc': 'Установите место открытия сеточного вида по умолчанию', @@ -1353,6 +1361,7 @@ export const TRANSLATIONS: Translations = { 'searching': 'Поиск...', 'no_files': 'Файлы не найдены', 'filter_folders': 'Фильтровать папки...', + 'search_for': 'Поиск', // 'create_shortcut': 'Создать ярлик', @@ -1437,6 +1446,7 @@ export const TRANSLATIONS: Translations = { 'no_backlinks': 'Немає зворотних посилань', 'back': 'Назад', 'search': 'Пошук', + 'default_search_option': 'По умолчанию', 'search_placeholder': 'Ключове слово для пошуку', 'search_current_location_only': 'Шукати лише в поточному розташуванні', 'search_files_name_only': 'Шукати лише в назві файлів', @@ -1589,10 +1599,10 @@ export const TRANSLATIONS: Translations = { 'all': 'Всі', 'default': 'По умолчанию', 'hidden': 'Сховати', - + // Hide header elements setting 'hide_header_elements': 'Скрыть элементы заголовка', - + // Default open location setting 'default_open_location': 'Місце відкриття за замовчуванням', 'default_open_location_desc': 'Встановіть місце відкриття сіткового вигляду за замовчуванням', @@ -1633,6 +1643,7 @@ export const TRANSLATIONS: Translations = { 'searching': 'Пошук...', 'no_files': 'Файли не знайдено', 'filter_folders': 'Фільтрувати папки...', + 'search_for': 'Пошук', // Shortcut Selection Dialog 'create_shortcut': 'Створити ярлик', @@ -1641,7 +1652,7 @@ export const TRANSLATIONS: Translations = { 'target_not_found': 'Цель не знайдена', 'shortcut_created': 'Ярлик створений', 'failed_to_create_shortcut': 'Не вдалося створити ярлик', - + // Folder Note Settings Dialog 'folder_note_settings': 'Налаштування нотатки папки', 'folder_sort_type': 'Тип сортування папки', @@ -1692,7 +1703,7 @@ export const TRANSLATIONS: Translations = { 'display_minimized_desc': 'Показувати цю нотатку у мінімізованому режимі', // Quick Access Settings and Commands - + 'quick_access_settings_title': 'Налаштування Швидкого доступу', 'quick_access_folder_name': 'Папка швидкого доступу', 'quick_access_folder_desc': 'Встановіть папку, що використовується командою «Відкрити папку швидкого доступу»', diff --git a/versions.json b/versions.json index e24f233..36b4249 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,3 @@ { - "2.8.4": "1.1.0" + "2.8.5": "1.1.0" } \ No newline at end of file