refac
This commit is contained in:
@@ -103,6 +103,13 @@
|
|||||||
$: isNotebook = getExt(selectedFile) === 'ipynb';
|
$: isNotebook = getExt(selectedFile) === 'ipynb';
|
||||||
$: isCode = isCodeFile(selectedFile);
|
$: isCode = isCodeFile(selectedFile);
|
||||||
$: csvDelimiter = getExt(selectedFile) === 'tsv' ? '\t' : ',';
|
$: csvDelimiter = getExt(selectedFile) === 'tsv' ? '\t' : ',';
|
||||||
|
|
||||||
|
// For HTML files on system terminals (proxy URL), use path-based serving
|
||||||
|
// so the iframe can resolve relative CSS/JS/image references via cookie auth.
|
||||||
|
$: serveUrl =
|
||||||
|
isHtml && selectedFile && baseUrl && baseUrl.includes('/api/v1/terminals/')
|
||||||
|
? `${baseUrl}/files/serve/${selectedFile.replace(/^\//, '')}`
|
||||||
|
: null;
|
||||||
$: renderedHtml =
|
$: renderedHtml =
|
||||||
isMarkdown && fileContent
|
isMarkdown && fileContent
|
||||||
? DOMPurify.sanitize(marked.parse(fileContent, { async: false }) as string)
|
? DOMPurify.sanitize(marked.parse(fileContent, { async: false }) as string)
|
||||||
@@ -386,7 +393,19 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{:else if fileContent !== null}
|
{:else if fileContent !== null}
|
||||||
{#if isHtml && !showRaw}
|
{#if isHtml && !showRaw && serveUrl}
|
||||||
|
{#if overlay}
|
||||||
|
<div class="absolute top-0 left-0 right-0 bottom-0 z-10"></div>
|
||||||
|
{/if}
|
||||||
|
<iframe
|
||||||
|
src={serveUrl}
|
||||||
|
sandbox="allow-scripts allow-same-origin allow-downloads{($settings?.iframeSandboxAllowForms ?? false)
|
||||||
|
? ' allow-forms'
|
||||||
|
: ''}"
|
||||||
|
class="w-full h-full border-none bg-white"
|
||||||
|
title="HTML Preview"
|
||||||
|
/>
|
||||||
|
{:else if isHtml && !showRaw}
|
||||||
{#if overlay}
|
{#if overlay}
|
||||||
<div class="absolute top-0 left-0 right-0 bottom-0 z-10"></div>
|
<div class="absolute top-0 left-0 right-0 bottom-0 z-10"></div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user