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.

fix: dont show slides PDF when not viewing as slides (#8561)

Akshay Agrawal192df17458be
diff --git a/frontend/src/components/editor/actions/useNotebookActions.tsx b/frontend/src/components/editor/actions/useNotebookActions.tsx
index 6ed3652998..dcdd413cb3 100644
--- a/frontend/src/components/editor/actions/useNotebookActions.tsx
+++ b/frontend/src/components/editor/actions/useNotebookActions.tsx
@@ -184,6 +184,21 @@ export function useNotebookActions() {
await withLoadingToast(title, runDownload);
};
+ const handleDocumentPDF = async () => {
+ if (serverSidePdfEnabled) {
+ await downloadServerSidePDF({
+ preset: "document",
+ title: "Downloading Document PDF...",
+ });
+ return;
+ }
+ const beforeprint = new Event("export-beforeprint");
+ const afterprint = new Event("export-afterprint");
+ window.dispatchEvent(beforeprint);
+ setTimeout(() => window.print(), 0);
+ setTimeout(() => window.dispatchEvent(afterprint), 0);
+ };
+
const actions: ActionButton[] = [
{
icon: <DownloadIcon size={14} strokeWidth={1.5} />,
@@ -261,49 +276,38 @@ export function useNotebookActions() {
});
},
},
- {
- divider: true,
- icon: <FileIcon size={14} strokeWidth={1.5} />,
- label: "Download as PDF",
- handle: NOOP_HANDLER,
- dropdown: [
- {
+ isSlidesLayout
+ ? {
+ divider: true,
icon: <FileIcon size={14} strokeWidth={1.5} />,
- label: "Document Layout",
- rightElement: renderRecommendedElement(!isSlidesLayout),
- handle: async () => {
- if (serverSidePdfEnabled) {
- await downloadServerSidePDF({
- preset: "document",
- title: "Downloading Document PDF...",
- });
- return;
- }
-
- const beforeprint = new Event("export-beforeprint");
- const afterprint = new Event("export-afterprint");
- function print() {
- window.dispatchEvent(beforeprint);
- setTimeout(() => window.print(), 0);
- setTimeout(() => window.dispatchEvent(afterprint), 0);
- }
- print();
- },
- },
- {
+ label: "Download as PDF",
+ handle: NOOP_HANDLER,
+ dropdown: [
+ {
+ icon: <FileIcon size={14} strokeWidth={1.5} />,
+ label: "Document Layout",
+ handle: handleDocumentPDF,
+ },
+ {
+ icon: <FileIcon size={14} strokeWidth={1.5} />,
+ label: "Slides Layout",
+ rightElement: renderRecommendedElement(true),
+ hidden: !serverSidePdfEnabled,
+ handle: async () => {
+ await downloadServerSidePDF({
+ preset: "slides",
+ title: "Downloading Slides PDF...",
+ });
+ },
+ },
+ ],
+ }
+ : {
+ divider: true,
icon: <FileIcon size={14} strokeWidth={1.5} />,
- label: "Slides Layout",
- rightElement: renderRecommendedElement(isSlidesLayout),
- hidden: !serverSidePdfEnabled,
- handle: async () => {
- await downloadServerSidePDF({
- preset: "slides",
- title: "Downloading Slides PDF...",
- });
- },
+ label: "Download as PDF",
+ handle: handleDocumentPDF,
},
- ],
- },
],
},