@dbx-tools/ui-mastra 0.1.24 → 0.3.1
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/package.json +7 -7
- package/src/react/export-menu.tsx +1 -2
- package/src/support/export.ts +9 -12
package/package.json
CHANGED
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
"shiki": "^3.0.0",
|
|
27
27
|
"sql-formatter": "^15.6.9",
|
|
28
28
|
"streamdown": "^2.5.0",
|
|
29
|
-
"@dbx-tools/shared-core": "0.1
|
|
30
|
-
"@dbx-tools/shared-genie": "0.1
|
|
31
|
-
"@dbx-tools/shared-
|
|
32
|
-
"@dbx-tools/shared-
|
|
33
|
-
"@dbx-tools/ui-appkit": "0.1
|
|
34
|
-
"@dbx-tools/ui-branding": "0.1
|
|
29
|
+
"@dbx-tools/shared-core": "0.3.1",
|
|
30
|
+
"@dbx-tools/shared-genie": "0.3.1",
|
|
31
|
+
"@dbx-tools/shared-model": "0.3.1",
|
|
32
|
+
"@dbx-tools/shared-mastra": "0.3.1",
|
|
33
|
+
"@dbx-tools/ui-appkit": "0.3.1",
|
|
34
|
+
"@dbx-tools/ui-branding": "0.3.1"
|
|
35
35
|
},
|
|
36
36
|
"main": "index.ts",
|
|
37
37
|
"license": "UNLICENSED",
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"version": "0.1
|
|
41
|
+
"version": "0.3.1",
|
|
42
42
|
"types": "index.ts",
|
|
43
43
|
"type": "module",
|
|
44
44
|
"exports": {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
TooltipContent,
|
|
9
9
|
TooltipTrigger,
|
|
10
10
|
} from "@dbx-tools/ui-appkit/react";
|
|
11
|
-
import { DownloadIcon, FileTextIcon
|
|
11
|
+
import { DownloadIcon, FileTextIcon } from "lucide-react";
|
|
12
12
|
import type { ExportFormat } from "../support/export";
|
|
13
13
|
|
|
14
14
|
// Shared export affordance: a download button that opens a small menu of
|
|
@@ -22,7 +22,6 @@ const FORMATS: ReadonlyArray<{
|
|
|
22
22
|
Icon: typeof DownloadIcon;
|
|
23
23
|
}> = [
|
|
24
24
|
{ format: "pdf", label: "PDF", Icon: DownloadIcon },
|
|
25
|
-
{ format: "print", label: "Print", Icon: PrinterIcon },
|
|
26
25
|
{ format: "markdown", label: "Markdown", Icon: FileTextIcon },
|
|
27
26
|
];
|
|
28
27
|
|
package/src/support/export.ts
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
* - `"pdf"` - a print-ready HTML document rendered in a hidden iframe
|
|
9
9
|
* with the browser's print dialog triggered, so the user
|
|
10
10
|
* saves a real PDF ("Save as PDF") with no popup tab.
|
|
11
|
-
* - `"print"` - the same document routed to a paper printer.
|
|
12
11
|
* - `"markdown"` - a `.md` file download.
|
|
13
12
|
*
|
|
14
13
|
* The document can be brand-styled (logo, colors, font) via the optional
|
|
@@ -37,10 +36,9 @@ import { normalizeChartOption } from "./chart-option";
|
|
|
37
36
|
* Output formats {@link exportChat} can produce.
|
|
38
37
|
* - `"pdf"` - Save-as-PDF via a hidden print iframe (dialog defaults to
|
|
39
38
|
* "Save as PDF"); no new tab.
|
|
40
|
-
* - `"print"` - same rendered document + print dialog, for a paper printer.
|
|
41
39
|
* - `"markdown"` - a `.md` file download.
|
|
42
40
|
*/
|
|
43
|
-
export type ExportFormat = "pdf" | "
|
|
41
|
+
export type ExportFormat = "pdf" | "markdown";
|
|
44
42
|
|
|
45
43
|
/**
|
|
46
44
|
* Optional brand styling for the exported document. Plain data (no React /
|
|
@@ -102,14 +100,13 @@ const CHART_HEIGHT_PX = 380;
|
|
|
102
100
|
const PRINT_SETTLE_MS = 300;
|
|
103
101
|
|
|
104
102
|
/**
|
|
105
|
-
* Export `messages` as a PDF
|
|
103
|
+
* Export `messages` as a PDF or a Markdown file.
|
|
106
104
|
*
|
|
107
|
-
* `"pdf"`
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* export - charts included - still lands.
|
|
105
|
+
* `"pdf"` renders a branded, self-contained HTML document and drives it
|
|
106
|
+
* through a hidden `<iframe>` + `print()` - so the browser's print dialog
|
|
107
|
+
* (defaulting to "Save as PDF") opens directly, with no popup tab. If the
|
|
108
|
+
* iframe path can't run (e.g. no DOM body), the document is downloaded as a
|
|
109
|
+
* self-contained `.html` file so the export - charts included - still lands.
|
|
113
110
|
*/
|
|
114
111
|
export async function exportChat(options: ExportChatOptions): Promise<void> {
|
|
115
112
|
const { messages, format, resolver } = options;
|
|
@@ -123,8 +120,8 @@ export async function exportChat(options: ExportChatOptions): Promise<void> {
|
|
|
123
120
|
return;
|
|
124
121
|
}
|
|
125
122
|
|
|
126
|
-
// pdf
|
|
127
|
-
//
|
|
123
|
+
// pdf: build the branded document, then print it from a hidden iframe so
|
|
124
|
+
// the Save-as-PDF dialog opens without a stray tab.
|
|
128
125
|
const html = await buildHtmlDocument(messages, resolver, title, userLabel, options.brand);
|
|
129
126
|
printViaHiddenIframe(html, `${stem}.html`);
|
|
130
127
|
}
|