fix: slash commands clean /command + cache-bust Forge iframe
CI / lint (push) Failing after 5s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / security (push) Successful in -3s

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:
2026-06-10 08:59:58 -04:00
parent 89b0a5a024
commit 8cf7b55747
3 changed files with 34 additions and 3 deletions
+1 -1
View File
@@ -3301,7 +3301,7 @@
bodyEl.innerHTML = ""; bodyEl.innerHTML = "";
var iframe = document.createElement("iframe"); var iframe = document.createElement("iframe");
iframe.id = "forge-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;"; iframe.style.cssText = "width:100%;height:82vh;border:none;display:block;";
bodyEl.appendChild(iframe); bodyEl.appendChild(iframe);
modal.classList.add("active"); modal.classList.add("active");
+7
View File
@@ -784,6 +784,13 @@ body { font-family: var(--sans); background: var(--bg); color: var(--text); heig
function getVisibleSlash() { return slashItems.filter(function(i) { return i.style.display !== 'none'; }); } function getVisibleSlash() { return slashItems.filter(function(i) { return i.style.display !== 'none'; }); }
function selectSlashAction(action) { function selectSlashAction(action) {
// Clean up the /command text from the current line
var line = getLine();
var m = line.text.match(/^\/\S*\s*/);
if (m) {
ta.value = val().substring(0, line.start) + val().substring(line.start + m[0].length);
setPos(line.start);
}
hideSlash(); hideSlash();
// Handle QI-specific actions // Handle QI-specific actions
if (action && action.indexOf('mermaid-') === 0) { if (action && action.indexOf('mermaid-') === 0) {
+26 -2
View File
@@ -9,6 +9,7 @@ import { initDashboardTabs } from './sync.js';
import { renderMermaidBlocks } from './mermaid-viewer.js'; import { renderMermaidBlocks } from './mermaid-viewer.js';
import { DashboardStatsWidget, DashboardRecentWidget, DashboardBookmarkWidget, DashboardSharedWidget, DashboardConflictsWidget } from './dashboard.js'; import { DashboardStatsWidget, DashboardRecentWidget, DashboardBookmarkWidget, DashboardSharedWidget, DashboardConflictsWidget } from './dashboard.js';
import { openShareDialog } from './config.js'; import { openShareDialog } from './config.js';
import { cacheViewedFile, getCachedFile } from './offline.js';
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Outline/TOC Manager // Outline/TOC Manager
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -336,9 +337,32 @@ export async function openFile(vaultName, filePath) {
try { try {
const url = `/api/file/${encodeURIComponent(vaultName)}?path=${encodeURIComponent(filePath)}`; const url = `/api/file/${encodeURIComponent(vaultName)}?path=${encodeURIComponent(filePath)}`;
const data = await api(url); 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); renderFile(data);
} catch (err) { } 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"; bodyEl.style.overflow = "hidden";
var iframe = document.createElement("iframe"); var iframe = document.createElement("iframe");
iframe.id = "forge-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;"; iframe.style.cssText = "width:100%;height:82vh;border:none;display:block;";
bodyEl.appendChild(iframe); bodyEl.appendChild(iframe);
modal.classList.add("active"); modal.classList.add("active");