Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

improvement: add Download as HTML (no code) (#2502)

Myles Scolnickf16726e83b24
diff --git a/frontend/src/components/editor/actions/useNotebookActions.tsx b/frontend/src/components/editor/actions/useNotebookActions.tsx
index d22947aac7..8c30e0e956 100644
--- a/frontend/src/components/editor/actions/useNotebookActions.tsx
+++ b/frontend/src/components/editor/actions/useNotebookActions.tsx
@@ -142,7 +142,22 @@ export function useNotebookActions() {
});
return;
}
- await downloadAsHTML({ filename });
+ await downloadAsHTML({ filename, includeCode: true });
+ },
+ },
+ {
+ icon: <FolderDownIcon size={14} strokeWidth={1.5} />,
+ label: "Download as HTML (exclude code)",
+ handle: async () => {
+ if (!filename) {
+ toast({
+ variant: "danger",
+ title: "Error",
+ description: "Notebooks must be named to be exported.",
+ });
+ return;
+ }
+ await downloadAsHTML({ filename, includeCode: false });
},
},
{
diff --git a/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx b/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx
index 30b10b93e8..fa24a153f9 100644
--- a/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx
+++ b/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx
@@ -144,7 +144,7 @@ const ActionButtons: React.FC<{
if (!app) {
return;
}
- await downloadAsHTML({ filename: document.title });
+ await downloadAsHTML({ filename: document.title, includeCode: true });
};
return (
diff --git a/frontend/src/core/static/download-html.ts b/frontend/src/core/static/download-html.ts
index 9271d086bb..100ffe6e8a 100644
--- a/frontend/src/core/static/download-html.ts
+++ b/frontend/src/core/static/download-html.ts
@@ -8,11 +8,14 @@ import { Filenames } from "@/utils/filenames";
/**
* Downloads the current notebook as an HTML file.
*/
-export async function downloadAsHTML(opts: { filename: string }) {
- const { filename } = opts;
+export async function downloadAsHTML(opts: {
+ filename: string;
+ includeCode: boolean;
+}) {
+ const { filename, includeCode } = opts;
const html = await exportAsHTML({
download: true,
- includeCode: true,
+ includeCode: includeCode,
files: VirtualFileTracker.INSTANCE.filenames(),
});
const filenameWithoutPath = Paths.basename(filename) ?? "notebook.py";