fix: slash commands clean /command + cache-bust Forge iframe
Bug 1: selectSlashAction now strips /command text before executing. Bug 2: Forge URL includes _ts=Date.now() to prevent cache.
This commit is contained in:
+26
-2
@@ -9,6 +9,7 @@ import { initDashboardTabs } from './sync.js';
|
||||
import { renderMermaidBlocks } from './mermaid-viewer.js';
|
||||
import { DashboardStatsWidget, DashboardRecentWidget, DashboardBookmarkWidget, DashboardSharedWidget, DashboardConflictsWidget } from './dashboard.js';
|
||||
import { openShareDialog } from './config.js';
|
||||
import { cacheViewedFile, getCachedFile } from './offline.js';
|
||||
// ---------------------------------------------------------------------------
|
||||
// Outline/TOC Manager
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -336,9 +337,32 @@ export async function openFile(vaultName, filePath) {
|
||||
try {
|
||||
const url = `/api/file/${encodeURIComponent(vaultName)}?path=${encodeURIComponent(filePath)}`;
|
||||
const data = await api(url);
|
||||
// Cache the file for offline use
|
||||
if (data && !data.unsupported && data.content) {
|
||||
cacheViewedFile(vaultName, filePath, data.content, data.modified);
|
||||
}
|
||||
renderFile(data);
|
||||
} catch (err) {
|
||||
area.innerHTML = '<div class="welcome"><p style="color:var(--text-muted)">Impossible de charger le fichier.</p></div>';
|
||||
// Try IndexedDB fallback
|
||||
console.log('[Viewer] Network failed, trying offline cache:', err);
|
||||
const cached = await getCachedFile(vaultName, filePath);
|
||||
if (cached && cached.content) {
|
||||
const fakeData = {
|
||||
vault: vaultName,
|
||||
path: filePath,
|
||||
title: filePath.split('/').pop().replace(/\.md$/, ''),
|
||||
content: cached.content,
|
||||
html: null,
|
||||
raw_size: cached.content.length,
|
||||
modified: cached.modified || '',
|
||||
tags: [],
|
||||
offline: true
|
||||
};
|
||||
renderFile(fakeData);
|
||||
showToast('Fichier charge depuis le cache hors-ligne', 'info');
|
||||
} else {
|
||||
area.innerHTML = '<div class="welcome"><p style="color:var(--text-muted)">Impossible de charger le fichier — vous etes hors-ligne et ce fichier n\'est pas en cache.</p></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,7 +531,7 @@ export function renderFile(data) {
|
||||
bodyEl.style.overflow = "hidden";
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.id = "forge-iframe";
|
||||
iframe.src = "/editor-poc?vault=" + encodeURIComponent(data.vault) + "&path=" + encodeURIComponent(data.path);
|
||||
iframe.src = "/editor-poc?vault=" + encodeURIComponent(data.vault) + "&path=" + encodeURIComponent(data.path) + "&_ts=" + Date.now();
|
||||
iframe.style.cssText = "width:100%;height:82vh;border:none;display:block;";
|
||||
bodyEl.appendChild(iframe);
|
||||
modal.classList.add("active");
|
||||
|
||||
Reference in New Issue
Block a user