From e213ad183e60d3c3beb406ce03156724a96a8553 Mon Sep 17 00:00:00 2001 From: bruno Date: Mon, 27 Jul 2026 15:06:24 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20support=20multi-format=20=E2=80=94=20im?= =?UTF-8?q?ages,=20CSV,=20JSON,=20TXT=20+=20fix=20PDF=20embed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PDF: + `; lucide.createIcons(); return; } + // Handle images + if (data.is_image) { + const imgUrl = `/api/file/${encodeURIComponent(data.vault)}/raw?path=${encodeURIComponent(data.path)}`; + area.innerHTML = ` +
+
+ ${escapeHtml(data.title)} + + +
+
+ ${data.html} +
+
`; + lucide.createIcons(); + return; + } + + // Handle CSV + if (data.is_csv) { + area.innerHTML = ` +
+
+ CSV — ${escapeHtml(data.title)} + +
+
${data.html}
+
`; + lucide.createIcons(); + return; + } + + // Handle JSON and plain text + if (data.is_json || data.extension === '.txt' || data.extension === '.log' || data.extension === '.yml' || data.extension === '.yaml' || data.extension === '.sh' || data.extension === '.py' || data.extension === '.js' || data.extension === '.toml' || data.extension === '.ini' || data.extension === '.cfg' || data.extension === '.conf' || data.extension === '.env') { + // Read raw content for plain text + fetch(`/api/file/${encodeURIComponent(data.vault)}/raw?path=${encodeURIComponent(data.path)}`) + .then(r => r.text()) + .then(text => { + const extClass = `lang-${data.extension.replace('.', '')}`; + area.innerHTML = ` +
+
+ ${escapeHtml(data.title)} + +
+
+
${escapeHtml(text)}
+
+
`; + lucide.createIcons(); + }) + .catch(() => { + area.innerHTML = `

Erreur lors du chargement du fichier.

`; + }); + return; + } + // Handle unsupported (binary) files if (data.unsupported) { const sizeStr = data.size_bytes diff --git a/frontend/style.css b/frontend/style.css index ae2d9f5..fcf8694 100644 --- a/frontend/style.css +++ b/frontend/style.css @@ -8539,6 +8539,97 @@ body.popup-mode .content-area { margin-left: 4px; } +/* ── Image Viewer ── */ +.image-viewer-body { + display: flex; + align-items: center; + justify-content: center; + min-height: 200px; + background: var(--surface1); + padding: 20px; +} +.image-viewer-body img { + border-radius: 4px; + box-shadow: 0 2px 12px rgba(0,0,0,0.15); +} + +/* ── Text / CSV Viewer ── */ +.text-viewer-container { + display: flex; + flex-direction: column; + height: 100%; +} +.file-toolbar { + display: flex; + align-items: center; + gap: 8px; + padding: 8px 16px; + background: var(--surface1); + border-bottom: 1px solid var(--border); + font-size: 0.85rem; + flex-shrink: 0; +} +.file-info { + flex: 1; + color: var(--text-dim); +} +.text-viewer-body { + flex: 1; + overflow: auto; + padding: 16px; + background: var(--surface2); +} +.text-viewer-body pre { + margin: 0; + font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace; + font-size: 0.85rem; + line-height: 1.5; + white-space: pre-wrap; +} +.text-viewer-body code { + color: var(--text); +} + +/* ── CSV Table ── */ +.csv-table-wrapper { + overflow: auto; + max-height: 70vh; +} +.csv-table { + width: 100%; + border-collapse: collapse; + font-size: 0.85rem; +} +.csv-table th { + background: var(--surface1); + color: var(--text-dim); + font-weight: 600; + padding: 8px 12px; + text-align: left; + border-bottom: 2px solid var(--border); + position: sticky; + top: 0; +} +.csv-table td { + padding: 6px 12px; + border-bottom: 1px solid var(--border-light, var(--border)); +} +.csv-table tr:hover td { + background: var(--surface1); +} + +/* ── JSON Viewer ── */ +.json-viewer { + font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace; + font-size: 0.85rem; + line-height: 1.5; + padding: 16px; + background: var(--surface2); + border-radius: 6px; + overflow: auto; + max-height: 70vh; +} + /* ── PaneManager — Split View ── */ .pane-grid { display: grid;