@signiphi/pdf-compose 0.1.0-beta.3 → 0.1.0-beta.5

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/index.js CHANGED
@@ -2587,7 +2587,11 @@ async function generatePdfFromTiptap(content, values) {
2587
2587
  const { content: expanded, values: enrichedValues } = expandRepeatContent(content, values);
2588
2588
  const suppressed = suppressZeroContent(expanded, enrichedValues);
2589
2589
  const replaced = replaceVariablesInContent(suppressed, enrichedValues);
2590
- const result = await generatePdfFromContent(replaced);
2590
+ const fields = extractFieldsFromContent(replaced);
2591
+ const result = await generatePdfFromContent(replaced, {
2592
+ embedFormFields: fields.length > 0,
2593
+ fields
2594
+ });
2591
2595
  return { pdfBytes: result.pdfBytes };
2592
2596
  }
2593
2597
  async function generatePdfFromMarkdown(markdown, values) {
@@ -5953,6 +5957,7 @@ function DocumentGeneratorInner({
5953
5957
  const editorWrapperRef = React12.useRef(null);
5954
5958
  const [editorCollapsed, setEditorCollapsed] = React12.useState(false);
5955
5959
  const [mdExportError, setMdExportError] = React12.useState(null);
5960
+ const [isSaving, setIsSaving] = React12.useState(false);
5956
5961
  const [exportSuccess, setExportSuccess] = React12.useState(null);
5957
5962
  React12.useEffect(() => {
5958
5963
  const handler = (e) => {
@@ -6024,7 +6029,7 @@ function DocumentGeneratorInner({
6024
6029
  setExportSuccess("Document exported successfully");
6025
6030
  }
6026
6031
  }, [exportDocument, onExport]);
6027
- const handleSaveTemplate = React12.useCallback(() => {
6032
+ const handleSaveTemplate = React12.useCallback(async () => {
6028
6033
  const md = exportMarkdown();
6029
6034
  if (!md.trim()) {
6030
6035
  setMdExportError("Editor content is empty");
@@ -6036,8 +6041,14 @@ function DocumentGeneratorInner({
6036
6041
  return;
6037
6042
  }
6038
6043
  setMdExportError(null);
6039
- onSaveTemplate?.(md);
6040
- setExportSuccess("Template saved");
6044
+ setIsSaving(true);
6045
+ try {
6046
+ await onSaveTemplate?.(md);
6047
+ setExportSuccess("Template saved");
6048
+ } catch {
6049
+ } finally {
6050
+ setIsSaving(false);
6051
+ }
6041
6052
  }, [exportMarkdown, onSaveTemplate]);
6042
6053
  const handleExportMarkdown = React12.useCallback(() => {
6043
6054
  const md = exportMarkdown();
@@ -6177,11 +6188,11 @@ function DocumentGeneratorInner({
6177
6188
  Button,
6178
6189
  {
6179
6190
  onClick: handleSaveTemplate,
6180
- disabled: !editor || !markdown.trim(),
6191
+ disabled: isSaving || !editor || !markdown.trim(),
6181
6192
  className: "h-10 px-4 font-semibold bg-primary hover:bg-primary/90 text-primary-foreground shadow-sm hover:shadow-md transition-all duration-200 text-sm",
6182
6193
  children: [
6183
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { size: 16 }),
6184
- exportButtonText || "Save Template"
6194
+ isSaving ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { size: 16 }),
6195
+ isSaving ? "Saving..." : exportButtonText || "Save Template"
6185
6196
  ]
6186
6197
  }
6187
6198
  ) : /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [