This commit is contained in:
Devon22 2026-05-17 11:45:29 +08:00
parent b1887f3ad7
commit 0e7e84a8fc
13 changed files with 55 additions and 30 deletions

View file

@ -1,6 +1,6 @@
import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";
import { builtinModules as builtins } from "module";
const banner =
`/*

View file

@ -1,7 +1,7 @@
{
"id": "gridexplorer",
"name": "GridExplorer",
"version": "3.2.2",
"version": "3.2.3",
"minAppVersion": "1.8.7",
"description": "Browse note files in a grid view.",
"author": "Devon22",

18
package-lock.json generated
View file

@ -1,18 +1,17 @@
{
"name": "gridexplorer",
"version": "3.2.2",
"version": "3.2.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "gridexplorer",
"version": "3.2.2",
"version": "3.2.3",
"license": "MIT",
"devDependencies": {
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "^8.59.3",
"@typescript-eslint/parser": "^8.59.3",
"builtin-modules": "3.3.0",
"esbuild": "0.17.3",
"eslint": "^10.3.0",
"eslint-plugin-obsidianmd": "^0.3.0",
@ -1253,19 +1252,6 @@
"concat-map": "0.0.1"
}
},
"node_modules/builtin-modules": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz",
"integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/call-bind": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.9.tgz",

View file

@ -1,6 +1,6 @@
{
"name": "gridexplorer",
"version": "3.2.2",
"version": "3.2.3",
"description": "Browse note files in a grid view.",
"main": "main.js",
"scripts": {
@ -15,7 +15,6 @@
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "^8.59.3",
"@typescript-eslint/parser": "^8.59.3",
"builtin-modules": "3.3.0",
"esbuild": "0.17.3",
"eslint": "^10.3.0",
"eslint-plugin-obsidianmd": "^0.3.0",

View file

@ -621,7 +621,7 @@ export class GridView extends ItemView {
if (filterRenderTimer !== null) {
window.clearTimeout(filterRenderTimer);
}
filterRenderTimer = window.setTimeout(renderFilteredFiles, 250);
filterRenderTimer = window.setTimeout(() => { void renderFilteredFiles(); }, 250);
};
let isComposingFilterText = false;
@ -981,7 +981,6 @@ export class GridView extends ItemView {
let outputValue: unknown = value;
if (calcExpr) {
try {
// eslint-disable-next-line @typescript-eslint/no-implied-eval
const fn = new Function('value', 'metadata', 'app', 'dv', `return (${calcExpr});`) as (value: string, metadata: FrontMatterCache | undefined, app: typeof this.app, dv: unknown) => unknown;
// 獲取 Dataview API
@ -1030,16 +1029,19 @@ export class GridView extends ItemView {
.replace(/```[\s\S]*?```\n/g, '')
.replace(/```[\s\S]*$/, '');
}
// 刪除註解及連結
contentWithoutMediaLinks = contentWithoutMediaLinks
.replace(/<!--[\s\S]*?-->/g, '')
.replace(/!?\[([^\]]*)\]\([^)]+\)|!?\[\[([^\]]+)\]\]/g, (_match: string, p1?: string, p2?: string) => {
const linkText = p1 || p2 || '';
if (!linkText) return '';
.replace(/!?\[([^\]]*)\]\([^)]+\)|!?\[\[([^\]]+)\]\]/g, (_match: string, p1?: string, p2?: string) => {
const rawLinkText = p1 || p2 || '';
if (!rawLinkText) return '';
const wikiLinkParts = p2 ? rawLinkText.split('|') : [];
const linkTarget = p2 ? wikiLinkParts[0] : rawLinkText;
const linkText = p2 && wikiLinkParts.length > 1 ? wikiLinkParts.slice(1).join('|') : rawLinkText;
// 獲取副檔名並檢查是否為圖片或影片
const extension = linkText.split('.').pop()?.toLowerCase() || '';
const extension = linkTarget.split('.').pop()?.toLowerCase() || '';
return (IMAGE_EXTENSIONS.has(extension) || VIDEO_EXTENSIONS.has(extension)) ? '' : linkText;
});
@ -1807,15 +1809,15 @@ export class GridView extends ItemView {
if (idx !== -1) {
lineNumber = content.substring(0, idx).split('\n').length - 1;
await leaf.openFile(file, { eState: { line: lineNumber } });
await this.openNoteFile(leaf, file, { eState: { line: lineNumber } });
(this.app as AppWithCommands).commands?.executeCommandById?.('editor:focus');
return;
}
// 若都找不到關鍵字,直接開檔
await leaf.openFile(file);
await this.openNoteFile(leaf, file);
})();
} else {
void leaf.openFile(file);
void this.openNoteFile(leaf, file);
}
}
}
@ -2171,6 +2173,15 @@ export class GridView extends ItemView {
});
}
// 開啟筆記檔案,必要時關閉目前的網格視圖
private async openNoteFile(leaf: WorkspaceLeaf, file: TFile, openState?: Parameters<WorkspaceLeaf['openFile']>[1]): Promise<void> {
await leaf.openFile(file, openState);
if (this.plugin.settings.closeGridViewOnOpenNote && leaf !== this.leaf) {
this.leaf.detach();
}
}
// 根據 openNoteLayout 設定獲取對應的 leaf
getLeafByMode(file?: TFile): WorkspaceLeaf {
const mode = this.plugin.settings.openNoteLayout;

View file

@ -88,6 +88,7 @@ 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 鍵)
closeGridViewOnOpenNote: boolean; // 當開啟筆記檔案時,關閉目前的網格視圖
openNoteLayout: 'default' | 'newTab' | 'split' | 'newWindow'; // 開啟筆記的方式
searchCurrentLocationOnly: boolean; // 是否只搜尋當前位置
searchFilesNameOnly: boolean; // 是否只搜尋筆記名稱
@ -155,6 +156,7 @@ export const DEFAULT_SETTINGS: GallerySettings = {
useQuickAccessAsNewTabMode: 'default',
quickAccessModeType: 'all-files', // Default quick access view type
showNoteInGrid: false, // 預設不在 grid container 中顯示筆記
closeGridViewOnOpenNote: false, // 預設開啟筆記檔案時不關閉目前的網格視圖
openNoteLayout: 'default', // 預設開啟筆記的方式
searchCurrentLocationOnly: false, // 預設搜尋所有筆記
searchFilesNameOnly: false, // 預設不只搜尋筆記名稱
@ -779,6 +781,19 @@ export class GridExplorerSettingTab extends PluginSettingTab {
});
});
// 開啟筆記檔案時關閉目前的網格視圖
new Setting(sectionEl)
.setName(t('close_grid_view_on_open_note'))
.setDesc(t('close_grid_view_on_open_note_desc'))
.addToggle(toggle => {
toggle
.setValue(this.plugin.settings.closeGridViewOnOpenNote)
.onChange(async (value) => {
this.plugin.settings.closeGridViewOnOpenNote = value;
await this.plugin.saveSettings();
});
});
// 設定開啟筆記的方式
new Setting(sectionEl)
.setName(t('open_note_layout'))

View file

@ -76,6 +76,8 @@ export default {
'show_video_thumbnails_desc': 'Display thumbnails for videos in the grid view, shows a play icon when disabled.',
'show_note_in_grid': 'Show note in grid',
'show_note_in_grid_desc': 'Display note in grid container when clicked. If disabled, use right-click menu to open.',
'close_grid_view_on_open_note': 'Close current grid view when opening a note file',
'close_grid_view_on_open_note_desc': 'When enabled, opening a note file from the grid view closes the current grid view.',
'open_note_layout': 'Open note layout',
'open_note_layout_desc': 'Set how notes are opened in the grid view',
'open_note_layout_default': 'Default',

View file

@ -75,6 +75,8 @@ export default {
'show_video_thumbnails_desc': 'グリッドビューで動画のサムネイルを表示する、無効の場合は再生アイコンを表示',
'show_note_in_grid': 'グリッドビューでノートを表示',
'show_note_in_grid_desc': 'グリッドビューでノートを表示する、無効の場合は右鍵メニューを使用して開く',
'close_grid_view_on_open_note': 'ノートファイルを開くときに現在のグリッドビューを閉じる',
'close_grid_view_on_open_note_desc': '有効にすると、グリッドビューからノートファイルを開いたときに現在のグリッドビューを閉じます',
'open_note_layout': 'ノートを開く',
'open_note_layout_desc': 'グリッドビューでノートを開く方法を設定します',
'open_note_layout_default': 'デフォルト',

View file

@ -76,6 +76,8 @@ export default {
'show_video_thumbnails_desc': '그리드 뷰에서 비디오 썸네일 표시, 비활성화 시 재생 아이콘 표시',
'show_note_in_grid': '그리드에 노트 표시',
'show_note_in_grid_desc': '클릭 시 그리드 컨테이너에 노트 표시. 비활성화 시 우클릭 메뉴로 열기',
'close_grid_view_on_open_note': '노트 파일을 열 때 현재 그리드 뷰 닫기',
'close_grid_view_on_open_note_desc': '활성화하면 그리드 뷰에서 노트 파일을 열 때 현재 그리드 뷰를 닫습니다',
'open_note_layout': '노트 열기 레이아웃',
'open_note_layout_desc': '그리드 뷰에서 노트를 여는 방법 설정',
'open_note_layout_default': '기본값',

View file

@ -75,6 +75,8 @@ export default {
'show_video_thumbnails_desc': 'Отображать миниатюры для видео в сеточном виде, показывает значок воспроизведения, если отключено',
'show_note_in_grid': 'Показывать заметки в сеточном виде',
'show_note_in_grid_desc': 'Показывать заметки в сеточном виде при нажатии. Если отключено, нужно открывать через контекстное меню',
'close_grid_view_on_open_note': 'Закрывать текущий сеточный вид при открытии файла заметки',
'close_grid_view_on_open_note_desc': 'Если включено, при открытии файла заметки из сеточного вида текущий сеточный вид будет закрыт',
'open_note_layout': 'Открыть заметку',
'open_note_layout_desc': 'Установите способ открытия заметок в виде сетки',
'open_note_layout_default': 'По умолчанию',

View file

@ -75,6 +75,8 @@ export default {
'show_video_thumbnails_desc': 'Відображати мініатюри для відео в сітковому вигляді, показує іконку відтворення, якщо вимкнено',
'show_note_in_grid': 'Показувати нотатки в сітці',
'show_note_in_grid_desc': 'Відображати нотатки в сітковому контейнері при натисканні. Якщо вимкнено, використовуйте контекстне меню для відкриття',
'close_grid_view_on_open_note': 'Закривати поточний сітковий вигляд під час відкриття файла нотатки',
'close_grid_view_on_open_note_desc': 'Якщо увімкнено, відкриття файла нотатки з сіткового вигляду закриє поточний сітковий вигляд',
'open_note_layout': 'Відкрити нотатку',
'open_note_layout_desc': 'Встановіть, як відкриваються нотатки в сітковому вигляді',
'open_note_layout_default': 'За замовчуванням',

View file

@ -76,6 +76,8 @@ export default {
'show_video_thumbnails_desc': '在網格視圖中顯示影片的縮圖,關閉時將顯示播放圖示',
'show_note_in_grid': '在網格視圖中顯示筆記',
'show_note_in_grid_desc': '啟用後,點擊筆記會直接在網格中顯示內容,不啟用則需要使用右鍵選單打開',
'close_grid_view_on_open_note': '當開啟筆記檔案時,關閉目前的網格視圖',
'close_grid_view_on_open_note_desc': '啟用後,從網格視圖開啟筆記檔案時會關閉目前的網格視圖',
'open_note_layout': '開啟筆記的方式',
'open_note_layout_desc': '設定開啟筆記的方式',
'open_note_layout_default': '預設',

View file

@ -75,6 +75,8 @@ export default {
'show_video_thumbnails_desc': '在网格视图中显示视频的缩略图,关闭时将显示播放图标',
'show_note_in_grid': '在网格视图中显示笔记',
'show_note_in_grid_desc': '在网格视图中显示笔记,关闭时使用右键菜单打开',
'close_grid_view_on_open_note': '打开笔记文件时关闭当前网格视图',
'close_grid_view_on_open_note_desc': '启用后,从网格视图打开笔记文件时会关闭当前网格视图',
'open_note_layout': '打开笔记布局',
'open_note_layout_desc': '设置在网格视图中打开笔记的方式',
'open_note_layout_default': '默认',