Spaces:
Running
Running
Improve frontend image and Mermaid rendering
Browse filesFiles changed (3)
216 unmodified lines217218219220220221222223216 unmodified lines raise HTTPException(status_code=403, detail="workspace file path is outside the workspace") from exc if not resolved.is_file(): raise HTTPException(status_code=404, detail="workspace file does not exist") if resolved.suffix.lower() not in {".png", ".jpg", ".jpeg", ".gif", ".webp", ".bmp"}: if resolved.suffix.lower() not in {".png", ".jpg", ".jpeg", ".gif", ".webp", ".bmp", ".svg"}: raise HTTPException(status_code=415, detail="only workspace image files can be displayed inline") return resolved
466 unmodified lines4674684694704714724734744 unmodified lines47948048148248348448548640 unmodified lines52752852953053153253353453575 unmodified lines611612613614615616617618619620621622623624625626466 unmodified lines}
.message-body { min-width: 0; max-width: 100%; padding: 14px 16px;}
4 unmodified lines}
.event-body-inner { min-width: 0; max-width: 100%; padding: 14px 16px;}
40 unmodified lines}
.markdown-body { min-width: 0; max-width: 100%; overflow-wrap: anywhere; line-height: 1.6; word-break: break-word;}75 unmodified lines
.markdown-body img { display: block; width: auto; max-width: 100%; height: auto; margin: 0.65rem 0; border-radius: 14px; object-fit: contain;}
.mermaid-chart { max-width: 100%; margin: 0.85rem 0; overflow-x: auto;}197 unmodified lines19819920020120220320420520620720820921021121227 unmodified lines24024124223424324424524624724824925015 unmodified lines266267268256269270271272273197 unmodified lines return template.innerHTML; }
function normalizeMarkdownImageDestinations(text) { return String(text || "").replace(/!\[([^\]\n]*)\]\(([^)\n]+)\)/g, function (match, alt, target) { var src = String(target || "").trim(); if (!src || src[0] === "<" || !/\s/.test(src) || isRemoteOrInlineImageSrc(src)) return match; if (/[<>]/.test(src)) return match; return ""; }); }
function unwrapFullMarkdownFence(text) { var source = String(text || "").trim(); var match = /^(```|~~~)[ \t]*(markdown|md|gfm)[^\n]*\n([\s\S]*?)\n\1[ \t]*$/i.exec(source);27 unmodified lines console.warn("Mermaid initialization failed.", e); return; } container.querySelectorAll(".markdown-body pre code.language-mermaid").forEach(function (code) { container.querySelectorAll(".markdown-body pre code").forEach(function (code) { var className = String(code.className || "").toLowerCase(); if (!className.split(/\s+/).some(function (name) { return name === "language-mermaid" || name === "lang-mermaid" || name === "language-mmd" || name === "lang-mmd"; })) return; var pre = code.closest("pre"); if (!pre) return; var source = code.textContent || "";15 unmodified lines return "<pre>" + escapeHtml(text) + "</pre>"; } try { var protectedMath = protectMathSegments(unwrapFullMarkdownFence(text)); var normalizedText = normalizeMarkdownImageDestinations(unwrapFullMarkdownFence(text)); var protectedMath = protectMathSegments(normalizedText); var rawHtml = window.marked.parse(protectedMath.text, { gfm: true, breaks: false, async: false }); rawHtml = rewriteWorkspaceImageSources(rawHtml); var safeHtml = window.DOMPurify.sanitize(rawHtml, { USE_PROFILES: { html: true } });frontend/local_server.py+1-1
frontend/static/app.css+10
frontend/static/app.js+16-2