mirror of
https://github.com/devon22/obsidian-gridexplorer.git
synced 2026-07-22 05:38:16 +00:00
3.4.16
This commit is contained in:
parent
9602dc2c75
commit
f448ffb986
5 changed files with 28 additions and 19 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "gridexplorer",
|
||||
"name": "GridExplorer",
|
||||
"version": "3.4.15",
|
||||
"version": "3.4.16",
|
||||
"minAppVersion": "1.8.7",
|
||||
"description": "Browse and organize note files visually in a flexible grid layout.",
|
||||
"author": "Devon22",
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "gridexplorer",
|
||||
"version": "3.4.15",
|
||||
"version": "3.4.16",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "gridexplorer",
|
||||
"version": "3.4.15",
|
||||
"version": "3.4.16",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"jszip": "^3.10.1"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "gridexplorer",
|
||||
"version": "3.4.15",
|
||||
"version": "3.4.16",
|
||||
"description": "Browse and organize note files visually in a flexible grid layout.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -320,6 +320,11 @@ export class GridPreviewManager {
|
|||
this.view.noteViewContainer = this.view.containerEl.createDiv('ge-note-view-container');
|
||||
const noteViewContainer = this.view.noteViewContainer;
|
||||
|
||||
// 立即設定狀態,確保在非同步渲染期間也能正常響應關閉或跳轉
|
||||
this.view.isShowingNote = true;
|
||||
this.view.previewedFile = file;
|
||||
this.view.app.workspace.trigger('ge-preview-file-change', file, this.view);
|
||||
|
||||
// 頂部列 (左右區塊)
|
||||
const topBar = noteViewContainer.createDiv('ge-note-top-bar');
|
||||
const leftBar = topBar.createDiv('ge-note-top-left');
|
||||
|
|
@ -688,6 +693,7 @@ export class GridPreviewManager {
|
|||
try {
|
||||
// 讀取筆記內容
|
||||
const content = await this.view.app.vault.read(file);
|
||||
if (!this.view.isShowingNote || this.view.previewedFile !== file) return;
|
||||
|
||||
// 使用 Obsidian 的 MarkdownRenderer 渲染內容
|
||||
await MarkdownRenderer.render(
|
||||
|
|
@ -697,6 +703,7 @@ export class GridPreviewManager {
|
|||
file.path,
|
||||
this.previewComponent!
|
||||
);
|
||||
if (!this.view.isShowingNote || this.view.previewedFile !== file) return;
|
||||
|
||||
// 加上自訂屬性 data-source-path
|
||||
noteContentArea
|
||||
|
|
@ -735,16 +742,10 @@ export class GridPreviewManager {
|
|||
|
||||
// 渲染反向連結與出站連結區塊
|
||||
await this.renderLinksSection(file, noteContent);
|
||||
|
||||
if (!this.view.isShowingNote || this.view.previewedFile !== file) return;
|
||||
|
||||
// 註冊行動裝置滑動手勢
|
||||
this.registerPreviewTouchEvents(noteViewContainer, scrollContainer, () => this.hideNoteInGrid());
|
||||
|
||||
// 設定狀態
|
||||
this.view.isShowingNote = true;
|
||||
this.view.previewedFile = file;
|
||||
// 廣播事件,讓其他 GridView(例如側邊欄的反向連結模式)可以跟著更新
|
||||
this.view.app.workspace.trigger('ge-preview-file-change', file, this.view);
|
||||
}
|
||||
|
||||
// 隱藏筆記顯示
|
||||
|
|
@ -769,6 +770,10 @@ export class GridPreviewManager {
|
|||
}
|
||||
|
||||
if (this.view.noteViewContainer) {
|
||||
// 中斷所有正在下載的圖片,釋放瀏覽器連線池給下一次載入
|
||||
this.view.noteViewContainer
|
||||
.querySelectorAll<HTMLImageElement>('img')
|
||||
.forEach((img) => { img.removeAttribute('src'); });
|
||||
this.view.noteViewContainer.remove();
|
||||
this.view.noteViewContainer = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1262,15 +1262,19 @@ export class GridView extends ItemView {
|
|||
// 刪除註解及連結
|
||||
contentWithoutMediaLinks = contentWithoutMediaLinks
|
||||
.replace(/<!--[\s\S]*?-->/g, '')
|
||||
.replace(/!?\[([^\]]*)\]\([^)]+\)|!?\[\[([^\]]+)\]\]/g, (_match: string, p1?: string, p2?: string) => {
|
||||
const rawLinkText = p1 || p2 || '';
|
||||
if (!rawLinkText) return '';
|
||||
.replace(/(?:!?\[([^\]]*)\]\(([^)]+)\))|(?:!?\[\[([^\]]+)\]\])/g, (_match: string, p1?: string, p2?: string, p3?: string) => {
|
||||
if (p3) {
|
||||
// WikiLink
|
||||
const wikiLinkParts = p3.split('|');
|
||||
const linkTarget = wikiLinkParts[0];
|
||||
const linkText = wikiLinkParts.length > 1 ? wikiLinkParts.slice(1).join('|') : p3;
|
||||
const extension = linkTarget.split('.').pop()?.toLowerCase() || '';
|
||||
return (IMAGE_EXTENSIONS.has(extension) || VIDEO_EXTENSIONS.has(extension)) ? '' : linkText;
|
||||
}
|
||||
|
||||
const wikiLinkParts = p2 ? rawLinkText.split('|') : [];
|
||||
const linkTarget = p2 ? wikiLinkParts[0] : rawLinkText;
|
||||
const linkText = p2 && wikiLinkParts.length > 1 ? wikiLinkParts.slice(1).join('|') : rawLinkText;
|
||||
|
||||
// 獲取副檔名並檢查是否為圖片或影片
|
||||
// Standard Markdown link/image
|
||||
const linkText = p1 || '';
|
||||
const linkTarget = (p2 || '').split('?')[0];
|
||||
const extension = linkTarget.split('.').pop()?.toLowerCase() || '';
|
||||
return (IMAGE_EXTENSIONS.has(extension) || VIDEO_EXTENSIONS.has(extension)) ? '' : linkText;
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue