@marimo-team/islands 0.19.7-dev1 → 0.19.7-dev15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +3570 -3496
- package/dist/style.css +1 -1
- package/package.json +5 -5
- package/src/components/ai/__tests__/ai-utils.test.ts +20 -20
- package/src/components/ai/ai-model-dropdown.tsx +8 -10
- package/src/components/ai/ai-utils.ts +11 -9
- package/src/components/app-config/__tests__/get-dirty-values.test.ts +47 -1
- package/src/components/app-config/ai-config.tsx +20 -54
- package/src/components/app-config/state.ts +11 -1
- package/src/components/app-config/user-config-form.tsx +73 -3
- package/src/components/chat/chat-panel.tsx +5 -1
- package/src/components/editor/chrome/panels/dependency-graph-panel.tsx +46 -10
- package/src/core/export/hooks.ts +1 -1
- package/src/plugins/impl/plotly/PlotlyPlugin.tsx +11 -66
- package/src/plugins/impl/plotly/__tests__/usePlotlyLayout.test.ts +113 -0
- package/src/plugins/impl/plotly/usePlotlyLayout.ts +163 -0
- package/src/utils/__tests__/download.test.tsx +67 -13
- package/src/utils/download.ts +24 -8
package/src/utils/download.ts
CHANGED
|
@@ -59,34 +59,51 @@ function releaseBodyPrinting() {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
/**
|
|
63
63
|
* Prepare a cell element for screenshot capture.
|
|
64
|
-
*
|
|
64
|
+
*
|
|
65
|
+
* @param element - The cell output element to prepare
|
|
66
|
+
* @param enablePrintMode - When true, adds a 'printing' class to the body.
|
|
67
|
+
* This can cause layout shifts that cause the page to scroll.
|
|
68
|
+
* @returns A cleanup function to restore the element's original state
|
|
65
69
|
*/
|
|
66
|
-
function prepareCellElementForScreenshot(
|
|
70
|
+
function prepareCellElementForScreenshot(
|
|
71
|
+
element: HTMLElement,
|
|
72
|
+
enablePrintMode: boolean,
|
|
73
|
+
) {
|
|
67
74
|
element.classList.add("printing-output");
|
|
68
|
-
|
|
75
|
+
if (enablePrintMode) {
|
|
76
|
+
acquireBodyPrinting();
|
|
77
|
+
}
|
|
69
78
|
const originalOverflow = element.style.overflow;
|
|
70
79
|
element.style.overflow = "auto";
|
|
71
80
|
|
|
72
81
|
return () => {
|
|
73
82
|
element.classList.remove("printing-output");
|
|
74
|
-
|
|
83
|
+
if (enablePrintMode) {
|
|
84
|
+
releaseBodyPrinting();
|
|
85
|
+
}
|
|
75
86
|
element.style.overflow = originalOverflow;
|
|
76
87
|
};
|
|
77
88
|
}
|
|
78
89
|
|
|
79
90
|
/**
|
|
80
91
|
* Capture a cell output as a PNG data URL.
|
|
92
|
+
*
|
|
93
|
+
* @param cellId - The ID of the cell to capture
|
|
94
|
+
* @param enablePrintMode - When true, enables print mode which adds a 'printing' class to the body.
|
|
95
|
+
* This can cause layout shifts that cause the page to scroll.
|
|
96
|
+
* @returns The PNG as a data URL, or undefined if the cell element wasn't found
|
|
81
97
|
*/
|
|
82
98
|
export async function getImageDataUrlForCell(
|
|
83
99
|
cellId: CellId,
|
|
100
|
+
enablePrintMode = true,
|
|
84
101
|
): Promise<string | undefined> {
|
|
85
102
|
const element = findElementForCell(cellId);
|
|
86
103
|
if (!element) {
|
|
87
104
|
return;
|
|
88
105
|
}
|
|
89
|
-
const cleanup = prepareCellElementForScreenshot(element);
|
|
106
|
+
const cleanup = prepareCellElementForScreenshot(element, enablePrintMode);
|
|
90
107
|
|
|
91
108
|
try {
|
|
92
109
|
return await toPng(element);
|
|
@@ -110,7 +127,7 @@ export async function downloadCellOutputAsImage(
|
|
|
110
127
|
await downloadHTMLAsImage({
|
|
111
128
|
element,
|
|
112
129
|
filename,
|
|
113
|
-
prepare: prepareCellElementForScreenshot,
|
|
130
|
+
prepare: () => prepareCellElementForScreenshot(element, true),
|
|
114
131
|
});
|
|
115
132
|
}
|
|
116
133
|
|
|
@@ -127,7 +144,6 @@ export async function downloadHTMLAsImage(opts: {
|
|
|
127
144
|
|
|
128
145
|
let cleanup: (() => void) | undefined;
|
|
129
146
|
if (prepare) {
|
|
130
|
-
// Let the prepare function handle adding classes (e.g., body.printing)
|
|
131
147
|
cleanup = prepare(element);
|
|
132
148
|
} else {
|
|
133
149
|
// When no prepare function is provided (e.g., downloading full notebook),
|