Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(web): render HTML and PDF files in the file viewer #9143

Mergedjuliusmarmingemerged 2 commits intot3code/open-outside-workspace-files fromrefs/pull/9143/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 120 additions and 20 deletions.

x
0 of 2 viewed, 2 left
109 additions and 17 deletionsapps/web/src/components/files/FilePreviewPanel.tsxModified
View file
@@ -91,6 +91,7 @@
​
const FILE_EXPLORER_STORAGE_KEY = "t3code.fileExplorerOpen";
const RENDER_MARKDOWN_STORAGE_KEY = "t3code.renderMarkdown";
+const RENDER_BROWSER_FILE_STORAGE_KEY = "t3code.renderBrowserFile";
const FILE_SAVE_DEBOUNCE_MS = 500;
const FILE_LINK_REVEAL_ATTRIBUTE = "data-file-link-reveal";
const FILE_LINK_REVEAL_UNSAFE_CSS = `
@@ -196,6 +197,69 @@
​
+const isPdfPreviewFile = (path: string): boolean => /\.pdf$/i.test(path.split(/[?#]/, 1)[0] ?? "");
Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)
+​
+/**
+ * Renders an HTML or PDF file in place from its signed asset URL. HTML runs in
+ * a sandboxed frame with an opaque origin, so a page cannot reach the app's
+ * session or storage. A file inside the workspace may load sibling assets; a
+ * host file outside it is served on its own.
+ */
+function WorkspaceBrowserPreview(props: {
+ readonly environmentId: EnvironmentId;
+ readonly threadRef: ScopedThreadRef;
+ readonly absolutePath: string;
+ readonly workspaceRoot: string;
+ readonly title: string;
+ readonly workspaceMutationId: string | null;
+}) {