Skip to content

Commit e9ea1e2

Browse files
committed
improvement: additional print configuration, fix race conditions in export to pdf
1 parent 9af83cc commit e9ea1e2

File tree

25 files changed

+724
-295
lines changed

25 files changed

+724
-295
lines changed

‎frontend/src/components/data-table/TableActions.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ export const TableActions = <TData,>({
107107
};
108108

109109
return (
110-
<div className="flex items-center shrink-0 pt-1 no-print">
110+
<div className="flex items-center shrink-0 pt-1">
111111
{onSearchQueryChange && enableSearch && (
112112
<Tooltip content="Search">
113113
<Button
114114
variant="text"
115115
size="xs"
116-
className="mb-0"
116+
className="mb-0 print:hidden"
117117
onClick={() => setIsSearchEnabled(!isSearchEnabled)}
118118
>
119119
<SearchIcon className="w-4 h-4 text-muted-foreground" />
@@ -125,7 +125,7 @@ export const TableActions = <TData,>({
125125
<Button
126126
variant="text"
127127
size="xs"
128-
className="mb-0"
128+
className="mb-0 print:hidden"
129129
onClick={toggleDisplayHeader}
130130
>
131131
<ChartSplineIcon className="w-4 h-4 text-muted-foreground" />
@@ -140,6 +140,7 @@ export const TableActions = <TData,>({
140140
variant="text"
141141
size="xs"
142142
onClick={() => togglePanel("row-viewer")}
143+
className="print:hidden"
143144
>
144145
<PanelRightIcon
145146
className={cn(
@@ -156,6 +157,7 @@ export const TableActions = <TData,>({
156157
variant="text"
157158
size="xs"
158159
onClick={() => togglePanel("column-explorer")}
160+
className="print:hidden"
159161
>
160162
<ChartColumnStacked
161163
className={cn(

‎frontend/src/components/data-table/download-actions.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ export const DownloadAs: React.FC<DownloadActionProps> = (props) => {
8787
const { locale } = useLocale();
8888

8989
const button = (
90-
<Button data-testid="download-as-button" size="xs" variant="link">
90+
<Button
91+
data-testid="download-as-button"
92+
size="xs"
93+
variant="link"
94+
className="print:hidden"
95+
>
9196
Download <ChevronDownIcon className="w-3 h-3 ml-1" />
9297
</Button>
9398
);
@@ -146,7 +151,7 @@ export const DownloadAs: React.FC<DownloadActionProps> = (props) => {
146151
return (
147152
<DropdownMenu modal={false}>
148153
<DropdownMenuTrigger asChild={true}>{button}</DropdownMenuTrigger>
149-
<DropdownMenuContent side="bottom" className="no-print">
154+
<DropdownMenuContent side="bottom" className="print:hidden">
150155
{options.map((option) => (
151156
<DropdownMenuItem
152157
key={option.label}

‎frontend/src/components/data-table/pagination.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const DataTablePagination = <TData,>({
6565
<span>{prettyNumber(selected, locale)} selected</span>
6666
<Button
6767
size="xs"
68-
data-testid="select-all-button"
68+
data-testid="select-all-button print:hidden"
6969
variant="link"
7070
className="h-4"
7171
onMouseDown={Events.preventFocus}
@@ -89,7 +89,7 @@ export const DataTablePagination = <TData,>({
8989
<span>{prettyNumber(selected, locale)} selected</span>
9090
<Button
9191
size="xs"
92-
data-testid="clear-selection-button"
92+
data-testid="clear-selection-button print:hidden"
9393
variant="link"
9494
className="h-4"
9595
onMouseDown={Events.preventFocus}
@@ -139,7 +139,7 @@ export const DataTablePagination = <TData,>({
139139

140140
const renderPageSizeSelector = () => {
141141
return (
142-
<div className="flex items-center gap-1 text-xs whitespace-nowrap mr-1">
142+
<div className="flex items-center gap-1 text-xs whitespace-nowrap mr-1 print:hidden">
143143
<Select
144144
value={pageSize.toString()}
145145
onValueChange={(value) => table.setPageSize(Number(value))}
@@ -173,7 +173,7 @@ export const DataTablePagination = <TData,>({
173173
{showPageSizeSelector && renderPageSizeSelector()}
174174
</div>
175175

176-
<div className="flex items-end space-x-2">
176+
<div className="flex items-end space-x-2 print:hidden">
177177
<Button
178178
size="xs"
179179
variant="outline"

‎frontend/src/components/debug/indicator.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const TailwindIndicator = () => {
55
}
66

77
return (
8-
<div className="fixed bottom-10 right-0 z-50 flex items-center justify-center bg-gray-800 py-[2px] px-1 font-mono text-[10px] text-white font-semibold">
8+
<div className="fixed bottom-10 right-0 z-50 flex items-center justify-center bg-gray-800 py-[2px] px-1 font-mono text-[10px] text-white font-semibold print:hidden">
99
<div className="block sm:hidden">xs</div>
1010
<div className="hidden sm:block md:hidden lg:hidden xl:hidden 2xl:hidden">
1111
sm

‎frontend/src/components/editor/actions/useNotebookActions.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import { createShareableLink } from "@/core/wasm/share";
7070
import { isWasm } from "@/core/wasm/utils";
7171
import { copyToClipboard } from "@/utils/copy";
7272
import {
73+
ADD_PRINTING_CLASS,
7374
downloadAsPDF,
7475
downloadBlob,
7576
downloadHTMLAsImage,
@@ -219,6 +220,8 @@ export function useNotebookActions() {
219220
await downloadHTMLAsImage({
220221
element: app,
221222
filename: document.title,
223+
// Add body.printing ONLY when converting the whole notebook to a screenshot
224+
prepare: ADD_PRINTING_CLASS,
222225
});
223226
},
224227
},
@@ -241,8 +244,7 @@ export function useNotebookActions() {
241244

242245
const downloadPDF = async (progress: ProgressState) => {
243246
await updateCellOutputsWithScreenshots({
244-
takeScreenshots: () =>
245-
takeScreenshots({ progress, snappy: false }),
247+
takeScreenshots: () => takeScreenshots({ progress }),
246248
updateCellOutputs,
247249
});
248250
await downloadAsPDF({

‎frontend/src/components/editor/chrome/panels/context-aware-panel/context-aware-panel.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export const ContextAwarePanel: React.FC = () => {
123123
<>
124124
<PanelResizeHandle
125125
onDragging={handleDragging}
126-
className="resize-handle border-border z-20 no-print border-l"
126+
className="resize-handle border-border z-20 print:hidden border-l"
127127
/>
128128
<Panel defaultSize={20} minSize={15} maxSize={80}>
129129
{renderBody()}

‎frontend/src/components/editor/chrome/wrapper/app-chrome.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {
227227
<PanelResizeHandle
228228
onDragging={handleDragging}
229229
className={cn(
230-
"border-border no-print z-10",
230+
"border-border print:hidden z-10",
231231
isSidebarOpen ? "resize-handle" : "resize-handle-collapsed",
232232
"vertical",
233233
)}
@@ -238,7 +238,7 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {
238238
<PanelResizeHandle
239239
onDragging={handleDragging}
240240
className={cn(
241-
"border-border no-print z-20",
241+
"border-border print:hidden z-20",
242242
isDeveloperPanelOpen ? "resize-handle" : "resize-handle-collapsed",
243243
"horizontal",
244244
)}
@@ -382,7 +382,7 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {
382382
collapsedSize={0}
383383
collapsible={true}
384384
className={cn(
385-
"dark:bg-(--slate-1) no-print print:hidden hide-on-fullscreen",
385+
"dark:bg-(--slate-1) print:hidden hide-on-fullscreen",
386386
isSidebarOpen && "border-r border-l border-(--slate-7)",
387387
)}
388388
minSize={10}
@@ -427,7 +427,7 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {
427427
collapsedSize={0}
428428
collapsible={true}
429429
className={cn(
430-
"dark:bg-(--slate-1) no-print print:hidden hide-on-fullscreen",
430+
"dark:bg-(--slate-1) print:hidden hide-on-fullscreen",
431431
isDeveloperPanelOpen && "border-t",
432432
)}
433433
minSize={10}

‎frontend/src/components/editor/chrome/wrapper/footer.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const Footer: React.FC = () => {
5757
});
5858

5959
return (
60-
<footer className="h-10 py-1 gap-1 bg-background flex items-center text-muted-foreground text-md pl-2 pr-1 border-t border-border select-none no-print text-sm z-50 print:hidden hide-on-fullscreen overflow-x-auto overflow-y-hidden scrollbar-thin">
60+
<footer className="h-10 py-1 gap-1 bg-background flex items-center text-muted-foreground text-md pl-2 pr-1 border-t border-border select-none print:hidden text-sm z-50 print:hidden hide-on-fullscreen overflow-x-auto overflow-y-hidden scrollbar-thin">
6161
<FooterItem
6262
className="h-full"
6363
tooltip={

‎frontend/src/components/editor/chrome/wrapper/sidebar.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const Sidebar: React.FC = () => {
115115
]);
116116

117117
return (
118-
<div className="h-full pt-4 pb-1 px-1 flex flex-col items-start text-muted-foreground text-md select-none no-print text-sm z-50 dark:bg-background print:hidden hide-on-fullscreen">
118+
<div className="h-full pt-4 pb-1 px-1 flex flex-col items-start text-muted-foreground text-md select-none print:hidden text-sm z-50 dark:bg-background print:hidden hide-on-fullscreen">
119119
<ReorderableList<PanelDescriptor>
120120
value={sidebarItems}
121121
setValue={handleSetSidebarItems}

‎frontend/src/components/editor/controls/Controls.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ const StopControlButton = ({
212212
};
213213

214214
const topRightControls =
215-
"absolute top-3 right-5 m-0 flex items-center gap-2 min-h-[28px] no-print pointer-events-auto z-30 print:hidden";
215+
"absolute top-3 right-5 m-0 flex items-center gap-2 min-h-[28px] print:hidden pointer-events-auto z-30 print:hidden";
216216

217217
const bottomRightControls =
218-
"absolute bottom-5 right-5 flex flex-col gap-2 items-center no-print pointer-events-auto z-30 print:hidden";
218+
"absolute bottom-5 right-5 flex flex-col gap-2 items-center print:hidden pointer-events-auto z-30 print:hidden";

0 commit comments

Comments
 (0)