@signiphi/pdf-compose 0.1.0-beta.1 → 0.1.0-beta.10
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/README.md +265 -0
- package/dist/components/DocumentGenerator.d.ts +3 -0
- package/dist/components/DocumentGenerator.d.ts.map +1 -0
- package/dist/components/EditorPanel.d.ts +15 -0
- package/dist/components/EditorPanel.d.ts.map +1 -0
- package/dist/components/EditorToolbar.d.ts +11 -0
- package/dist/components/EditorToolbar.d.ts.map +1 -0
- package/dist/components/ErrorBoundary.d.ts +18 -0
- package/dist/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/FieldEditPopover.d.ts +12 -0
- package/dist/components/FieldEditPopover.d.ts.map +1 -0
- package/dist/components/FieldInsertPopover.d.ts +12 -0
- package/dist/components/FieldInsertPopover.d.ts.map +1 -0
- package/dist/components/FieldNodeView.d.ts +3 -0
- package/dist/components/FieldNodeView.d.ts.map +1 -0
- package/dist/components/FieldOverlay.d.ts +9 -0
- package/dist/components/FieldOverlay.d.ts.map +1 -0
- package/dist/components/GeneratePanel.d.ts +15 -0
- package/dist/components/GeneratePanel.d.ts.map +1 -0
- package/dist/components/PreviewPanel.d.ts +12 -0
- package/dist/components/PreviewPanel.d.ts.map +1 -0
- package/dist/components/VariableEditPopover.d.ts +12 -0
- package/dist/components/VariableEditPopover.d.ts.map +1 -0
- package/dist/components/VariableInsertPopover.d.ts +13 -0
- package/dist/components/VariableInsertPopover.d.ts.map +1 -0
- package/dist/components/VariableNodeView.d.ts +3 -0
- package/dist/components/VariableNodeView.d.ts.map +1 -0
- package/dist/components/WatermarkNodeView.d.ts +3 -0
- package/dist/components/WatermarkNodeView.d.ts.map +1 -0
- package/dist/contexts/ThemeContext.d.ts +19 -0
- package/dist/contexts/ThemeContext.d.ts.map +1 -0
- package/dist/extensions/columns-node.d.ts +4 -0
- package/dist/extensions/columns-node.d.ts.map +1 -0
- package/dist/extensions/field-node.d.ts +31 -0
- package/dist/extensions/field-node.d.ts.map +1 -0
- package/dist/extensions/panel-node.d.ts +3 -0
- package/dist/extensions/panel-node.d.ts.map +1 -0
- package/dist/extensions/repeat-node.d.ts +3 -0
- package/dist/extensions/repeat-node.d.ts.map +1 -0
- package/dist/extensions/subtotals-node.d.ts +3 -0
- package/dist/extensions/subtotals-node.d.ts.map +1 -0
- package/dist/extensions/variable-node.d.ts +18 -0
- package/dist/extensions/variable-node.d.ts.map +1 -0
- package/dist/extensions/watermark-node.d.ts +3 -0
- package/dist/extensions/watermark-node.d.ts.map +1 -0
- package/dist/hooks/useDocumentGenerator.d.ts +46 -0
- package/dist/hooks/useDocumentGenerator.d.ts.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3081 -562
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3068 -565
- package/dist/index.mjs.map +1 -1
- package/dist/lib/ui/button.d.ts +12 -0
- package/dist/lib/ui/button.d.ts.map +1 -0
- package/dist/lib/ui/index.d.ts +10 -0
- package/dist/lib/ui/index.d.ts.map +1 -0
- package/dist/lib/ui/input.d.ts +6 -0
- package/dist/lib/ui/input.d.ts.map +1 -0
- package/dist/lib/ui/label.d.ts +8 -0
- package/dist/lib/ui/label.d.ts.map +1 -0
- package/dist/lib/ui/popover.d.ts +8 -0
- package/dist/lib/ui/popover.d.ts.map +1 -0
- package/dist/lib/ui/select.d.ts +14 -0
- package/dist/lib/ui/select.d.ts.map +1 -0
- package/dist/lib/ui/toggle-group.d.ts +13 -0
- package/dist/lib/ui/toggle-group.d.ts.map +1 -0
- package/dist/lib/ui/tooltip.d.ts +8 -0
- package/dist/lib/ui/tooltip.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/styles/index.css +349 -194
- package/dist/styles/index.d.ts +1 -0
- package/dist/types/index.d.ts +204 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/error-helpers.d.ts +27 -0
- package/dist/utils/error-helpers.d.ts.map +1 -0
- package/dist/utils/field-helpers.d.ts +31 -0
- package/dist/utils/field-helpers.d.ts.map +1 -0
- package/dist/utils/markdown-parser.d.ts +6 -0
- package/dist/utils/markdown-parser.d.ts.map +1 -0
- package/dist/utils/markdown-validator.d.ts +13 -0
- package/dist/utils/markdown-validator.d.ts.map +1 -0
- package/dist/utils/markdown-writer.d.ts +6 -0
- package/dist/utils/markdown-writer.d.ts.map +1 -0
- package/dist/utils/pdf-generator.d.ts +77 -0
- package/dist/utils/pdf-generator.d.ts.map +1 -0
- package/dist/utils/pdf-metadata.d.ts +58 -0
- package/dist/utils/pdf-metadata.d.ts.map +1 -0
- package/dist/utils/pdf-preview.d.ts +7 -0
- package/dist/utils/pdf-preview.d.ts.map +1 -0
- package/dist/utils/template-pipeline.d.ts +39 -0
- package/dist/utils/template-pipeline.d.ts.map +1 -0
- package/dist/utils/theme-helpers.d.ts +21 -0
- package/dist/utils/theme-helpers.d.ts.map +1 -0
- package/dist/utils/variable-helpers.d.ts +74 -0
- package/dist/utils/variable-helpers.d.ts.map +1 -0
- package/dist/utils/xml-template-parser.d.ts +9 -0
- package/dist/utils/xml-template-parser.d.ts.map +1 -0
- package/package.json +16 -6
- package/src/styles/index.css +140 -68
- package/src/styles/index.d.ts +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { JSONContent } from '@tiptap/core';
|
|
2
|
+
/**
|
|
3
|
+
* Acknowledgement for form fields — matching @signiphi/document-prepare
|
|
4
|
+
*/
|
|
5
|
+
export interface Acknowledgement {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Form field types — same values as @signiphi/document-prepare for compatibility
|
|
12
|
+
*/
|
|
13
|
+
export declare enum FormFieldType {
|
|
14
|
+
TEXT = "text",
|
|
15
|
+
SIGNATURE = "signature",
|
|
16
|
+
INITIALS = "initials",
|
|
17
|
+
DATE = "date",
|
|
18
|
+
CHECKBOX = "checkbox",
|
|
19
|
+
RADIO = "radio",
|
|
20
|
+
DROPDOWN = "dropdown",
|
|
21
|
+
TEXT_LABEL = "text_label"
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Position and dimensions of a form field on a PDF page
|
|
25
|
+
*/
|
|
26
|
+
export interface FormFieldPosition {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
page: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Field as it exists in the editor — no position (computed during PDF generation)
|
|
35
|
+
*/
|
|
36
|
+
export interface DocumentGeneratorField {
|
|
37
|
+
fieldId: string;
|
|
38
|
+
type: FormFieldType;
|
|
39
|
+
name: string;
|
|
40
|
+
label: string;
|
|
41
|
+
required: boolean;
|
|
42
|
+
options?: string[];
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
fontSize?: number;
|
|
45
|
+
defaultValue?: string;
|
|
46
|
+
multiline?: boolean;
|
|
47
|
+
maxLength?: number;
|
|
48
|
+
acknowledgements?: Acknowledgement[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Full document model for save/load
|
|
52
|
+
*/
|
|
53
|
+
export interface GeneratedDocument {
|
|
54
|
+
title: string;
|
|
55
|
+
markdown: string;
|
|
56
|
+
editorContent: JSONContent;
|
|
57
|
+
fields: DocumentGeneratorField[];
|
|
58
|
+
createdAt: string;
|
|
59
|
+
updatedAt: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Field with computed position for PDF embedding.
|
|
63
|
+
* Compatible with @signiphi/document-prepare's FormField interface.
|
|
64
|
+
*/
|
|
65
|
+
export interface FormFieldForExport {
|
|
66
|
+
id: string;
|
|
67
|
+
fieldId: string;
|
|
68
|
+
type: FormFieldType;
|
|
69
|
+
name: string;
|
|
70
|
+
label: string;
|
|
71
|
+
position: FormFieldPosition;
|
|
72
|
+
required: boolean;
|
|
73
|
+
options?: string[];
|
|
74
|
+
placeholder?: string;
|
|
75
|
+
fontSize?: number;
|
|
76
|
+
defaultValue?: string;
|
|
77
|
+
multiline?: boolean;
|
|
78
|
+
maxLength?: number;
|
|
79
|
+
acknowledgements?: Acknowledgement[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Export result — same shape as document-prepare's PreparedDocument
|
|
83
|
+
*/
|
|
84
|
+
export interface DocumentGeneratorExportResult {
|
|
85
|
+
pdfBlob: Blob;
|
|
86
|
+
fields: FormFieldForExport[];
|
|
87
|
+
markdown: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Predefined variable available for insertion (e.g. from API print data)
|
|
91
|
+
*/
|
|
92
|
+
export interface PredefinedVariable {
|
|
93
|
+
varName: string;
|
|
94
|
+
varLabel?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Template variable as it exists in the editor
|
|
98
|
+
*/
|
|
99
|
+
export interface DocumentGeneratorVariable {
|
|
100
|
+
varName: string;
|
|
101
|
+
varLabel: string;
|
|
102
|
+
varDefault: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Variable values mapping: varName → user-supplied value
|
|
106
|
+
*/
|
|
107
|
+
export type VariableValues = Record<string, string>;
|
|
108
|
+
/**
|
|
109
|
+
* Reusable template produced by Phase 1 (parseXmlTemplate).
|
|
110
|
+
* Contains everything needed to generate a data-bound PDF in Phase 2.
|
|
111
|
+
*/
|
|
112
|
+
export interface DocumentTemplate {
|
|
113
|
+
markdown: string;
|
|
114
|
+
variables: DocumentGeneratorVariable[];
|
|
115
|
+
reportName: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* PDF page information with rendered image
|
|
119
|
+
*/
|
|
120
|
+
export interface PdfPage {
|
|
121
|
+
pageNumber: number;
|
|
122
|
+
width: number;
|
|
123
|
+
height: number;
|
|
124
|
+
imageUrl: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Theme mode options
|
|
128
|
+
*/
|
|
129
|
+
export type ThemeMode = 'light' | 'dark' | 'auto';
|
|
130
|
+
/**
|
|
131
|
+
* Advanced theme configuration
|
|
132
|
+
*/
|
|
133
|
+
export interface ThemeConfig {
|
|
134
|
+
primary?: string;
|
|
135
|
+
primaryForeground?: string;
|
|
136
|
+
background?: string;
|
|
137
|
+
foreground?: string;
|
|
138
|
+
secondary?: string;
|
|
139
|
+
secondaryForeground?: string;
|
|
140
|
+
muted?: string;
|
|
141
|
+
mutedForeground?: string;
|
|
142
|
+
accent?: string;
|
|
143
|
+
accentForeground?: string;
|
|
144
|
+
border?: string;
|
|
145
|
+
input?: string;
|
|
146
|
+
ring?: string;
|
|
147
|
+
card?: string;
|
|
148
|
+
cardForeground?: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* DocumentGenerator component props
|
|
152
|
+
*/
|
|
153
|
+
export interface DocumentGeneratorProps {
|
|
154
|
+
/** Initial markdown content with field tokens */
|
|
155
|
+
initialMarkdown?: string;
|
|
156
|
+
/** Initial TipTap JSON content (takes precedence over initialMarkdown) */
|
|
157
|
+
initialContent?: JSONContent;
|
|
158
|
+
/** Called whenever the content changes (debounced) */
|
|
159
|
+
onChange?: (data: {
|
|
160
|
+
markdown: string;
|
|
161
|
+
content: JSONContent;
|
|
162
|
+
fields: DocumentGeneratorField[];
|
|
163
|
+
variables: DocumentGeneratorVariable[];
|
|
164
|
+
}) => void;
|
|
165
|
+
/** Called when user triggers export */
|
|
166
|
+
onExport?: (result: DocumentGeneratorExportResult) => void;
|
|
167
|
+
/** Whether the component is in read-only mode */
|
|
168
|
+
readOnly?: boolean;
|
|
169
|
+
/** Custom class name */
|
|
170
|
+
className?: string;
|
|
171
|
+
/** Theme color (hex) */
|
|
172
|
+
themeColor?: string;
|
|
173
|
+
/** Theme mode */
|
|
174
|
+
themeMode?: ThemeMode;
|
|
175
|
+
/** Advanced theme configuration */
|
|
176
|
+
themeConfig?: ThemeConfig;
|
|
177
|
+
/** Whether to show the preview panel. Default: true */
|
|
178
|
+
showPreview?: boolean;
|
|
179
|
+
/** Placeholder text for the editor */
|
|
180
|
+
placeholder?: string;
|
|
181
|
+
/** Custom export button text. Default: 'Export Document' */
|
|
182
|
+
exportButtonText?: string;
|
|
183
|
+
/** Whether to show the toolbar. Default: true */
|
|
184
|
+
showToolbar?: boolean;
|
|
185
|
+
/** Whether to show the Generate tab. Default: true */
|
|
186
|
+
showGenerateTab?: boolean;
|
|
187
|
+
/** Called when user generates PDF(s) from the Generate tab */
|
|
188
|
+
onGeneratePdf?: (blob: Blob, fileName: string) => void;
|
|
189
|
+
/** Pre-filled bulk data for the Generate tab (array of variable-value objects) */
|
|
190
|
+
initialBulkData?: Record<string, string>[];
|
|
191
|
+
/** Default active tab. Default: 'editor' */
|
|
192
|
+
defaultTab?: 'editor' | 'generate';
|
|
193
|
+
/** Initial variable values to pre-fill in the Generate tab */
|
|
194
|
+
initialVariableValues?: Record<string, string>;
|
|
195
|
+
/** Predefined variable names available for insertion (e.g. from API print data) */
|
|
196
|
+
predefinedVariables?: PredefinedVariable[];
|
|
197
|
+
/** Custom filename for exported PDF (without extension). Default: 'document' */
|
|
198
|
+
exportFileName?: string;
|
|
199
|
+
/** Template mode: hides .md import, disables bulk mode, and locks variables provided via initialVariableValues. */
|
|
200
|
+
templateMode?: boolean;
|
|
201
|
+
/** Called when user clicks "Save Template". When set, replaces the Export dropdown with a single save button. */
|
|
202
|
+
onSaveTemplate?: (markdown: string) => void | Promise<void>;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;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,MAAM,CAAC;IACnB,wBAAwB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB;IACjB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,mCAAmC;IACnC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,uDAAuD;IACvD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iDAAiD;IACjD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sDAAsD;IACtD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,8DAA8D;IAC9D,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,kFAAkF;IAClF,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC3C,4CAA4C;IAC5C,UAAU,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IACnC,8DAA8D;IAC9D,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,mFAAmF;IACnF,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC3C,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mHAAmH;IACnH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iHAAiH;IACjH,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract a human-readable message from an unknown caught error.
|
|
3
|
+
* Always returns a string — never throws.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getErrorMessage(error: unknown): string;
|
|
6
|
+
/**
|
|
7
|
+
* Format a contextual error: prefix + extracted message.
|
|
8
|
+
* Example: formatError('Preview generation failed', err)
|
|
9
|
+
* => "Preview generation failed: The PDF document is corrupted"
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatError(context: string, error: unknown): string;
|
|
12
|
+
export type JsonParseResult = {
|
|
13
|
+
valid: true;
|
|
14
|
+
data: unknown;
|
|
15
|
+
} | {
|
|
16
|
+
valid: false;
|
|
17
|
+
message: string;
|
|
18
|
+
line: number;
|
|
19
|
+
col: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Parse JSON with precise error messages including line/col and a context snippet.
|
|
23
|
+
* Uses native JSON.parse with cross-browser position extraction
|
|
24
|
+
* (inspired by json-parse-better-errors).
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseJsonWithDetails(input: string): JsonParseResult;
|
|
27
|
+
//# sourceMappingURL=error-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/error-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQtD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAGnE;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC9B;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AA6EjE;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CA8BnE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FormFieldType, type DocumentGeneratorField } from '../types';
|
|
2
|
+
import type { FieldNodeAttributes } from '../extensions/field-node';
|
|
3
|
+
import type { JSONContent } from '@tiptap/core';
|
|
4
|
+
/**
|
|
5
|
+
* Default field dimensions in PDF points for each field type
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default field dimensions matching document-prepare (PdfViewerWithFields.tsx:423-441)
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_FIELD_DIMENSIONS: Record<FormFieldType, {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Generate a unique field name from type and timestamp (matches document-prepare pattern)
|
|
16
|
+
*/
|
|
17
|
+
export declare function generateFieldName(type: FormFieldType): string;
|
|
18
|
+
/**
|
|
19
|
+
* Create default field node attributes for a given type.
|
|
20
|
+
* Smart defaults per type match document-prepare's PdfViewerWithFields.tsx:474-495
|
|
21
|
+
*/
|
|
22
|
+
export declare function createFieldAttrs(type: FormFieldType, overrides?: Partial<FieldNodeAttributes>): FieldNodeAttributes;
|
|
23
|
+
/**
|
|
24
|
+
* Extract all DocumentGeneratorField instances from TipTap JSON content
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractFieldsFromContent(content: JSONContent): DocumentGeneratorField[];
|
|
27
|
+
/**
|
|
28
|
+
* Get all existing field names from content
|
|
29
|
+
*/
|
|
30
|
+
export declare function getExistingFieldNames(content: JSONContent): string[];
|
|
31
|
+
//# sourceMappingURL=field-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/field-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAwB,KAAK,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAC5F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;GAEG;AACH;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,aAAa,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAS7F,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAE7D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,aAAa,EACnB,SAAS,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACvC,mBAAmB,CAqCrB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,sBAAsB,EAAE,CAiCvF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,EAAE,CAEpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-parser.d.ts","sourceRoot":"","sources":["../../src/utils/markdown-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAkqBhD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAI9D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DocumentGeneratorField, DocumentGeneratorVariable } from '../types';
|
|
2
|
+
export interface MarkdownValidationResult {
|
|
3
|
+
valid: boolean;
|
|
4
|
+
errors: string[];
|
|
5
|
+
warnings: string[];
|
|
6
|
+
variables: DocumentGeneratorVariable[];
|
|
7
|
+
fields: DocumentGeneratorField[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Validate markdown content for well-formed field and variable tokens.
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateMarkdown(markdown: string): MarkdownValidationResult;
|
|
13
|
+
//# sourceMappingURL=markdown-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-validator.d.ts","sourceRoot":"","sources":["../../src/utils/markdown-validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAKlF,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,yBAAyB,EAAE,CAAC;IACvC,MAAM,EAAE,sBAAsB,EAAE,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,wBAAwB,CA6I3E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-writer.d.ts","sourceRoot":"","sources":["../../src/utils/markdown-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA8RhD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAMzD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Color } from 'pdf-lib';
|
|
2
|
+
import type { JSONContent } from '@tiptap/core';
|
|
3
|
+
import { type FormFieldPosition, type DocumentGeneratorField } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Optional brand colors for the PDF renderer (hex strings, e.g. "#161848").
|
|
6
|
+
* Every value is optional; omitted values fall back to the classic gray/black
|
|
7
|
+
* output, so existing consumers are unaffected.
|
|
8
|
+
*/
|
|
9
|
+
export interface PdfTheme {
|
|
10
|
+
/** Table-header fill, panel dark-header fill, horizontal rules, page-header text. */
|
|
11
|
+
primaryColor?: string;
|
|
12
|
+
/** Rule under the repeating page header. */
|
|
13
|
+
accentColor?: string;
|
|
14
|
+
/** Table and panel border lines. */
|
|
15
|
+
borderColor?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Repeating page-header text, drawn inside the top margin of every page. */
|
|
18
|
+
export interface PdfPageHeader {
|
|
19
|
+
/** Bold, primary-colored, left-aligned (e.g. marina name). */
|
|
20
|
+
left?: string;
|
|
21
|
+
/** Small gray, right-aligned (e.g. document title / number). */
|
|
22
|
+
right?: string;
|
|
23
|
+
/** Skip page 1 — for documents whose body already opens with a letterhead. */
|
|
24
|
+
skipFirstPage?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Repeating page-footer text, drawn next to the existing page number. */
|
|
27
|
+
export interface PdfPageFooter {
|
|
28
|
+
/** Small gray, left-aligned (e.g. contact line). */
|
|
29
|
+
left?: string;
|
|
30
|
+
}
|
|
31
|
+
interface ResolvedTheme {
|
|
32
|
+
tableHeaderBg: Color;
|
|
33
|
+
tableHeaderText: Color;
|
|
34
|
+
tableBorder: Color;
|
|
35
|
+
panelDarkHeaderBg: Color;
|
|
36
|
+
panelDarkHeaderText: Color;
|
|
37
|
+
panelBorder: Color;
|
|
38
|
+
rule: Color;
|
|
39
|
+
pageHeaderText: Color;
|
|
40
|
+
pageHeaderRule: Color;
|
|
41
|
+
}
|
|
42
|
+
/** Resolve a caller theme onto the classic defaults (exported for tests). */
|
|
43
|
+
export declare function resolveTheme(theme?: PdfTheme): ResolvedTheme;
|
|
44
|
+
export interface PdfGenerationResult {
|
|
45
|
+
pdfBytes: Uint8Array<ArrayBuffer>;
|
|
46
|
+
fieldPositions: Map<string, FormFieldPosition>;
|
|
47
|
+
/** Non-fatal warnings about fields that failed to create */
|
|
48
|
+
fieldWarnings?: string[];
|
|
49
|
+
/** Non-fatal warnings about images that failed to load/embed */
|
|
50
|
+
imageWarnings?: string[];
|
|
51
|
+
}
|
|
52
|
+
export interface PdfGenerationOptions {
|
|
53
|
+
/** Draw visual placeholder boxes for fields in the PDF (default: false) */
|
|
54
|
+
drawFieldPlaceholders?: boolean;
|
|
55
|
+
/** Add interactive PDF form fields at field positions (default: false) */
|
|
56
|
+
embedFormFields?: boolean;
|
|
57
|
+
/** Fields data for form field creation (required when embedFormFields is true) */
|
|
58
|
+
fields?: DocumentGeneratorField[];
|
|
59
|
+
/** Brand colors; omitted values keep the classic gray/black output */
|
|
60
|
+
theme?: PdfTheme;
|
|
61
|
+
/** Repeating page header (drawn in the top margin of every page) */
|
|
62
|
+
header?: PdfPageHeader;
|
|
63
|
+
/** Repeating page footer (drawn next to the page number) */
|
|
64
|
+
footer?: PdfPageFooter;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Generate a PDF from TipTap JSON content.
|
|
68
|
+
*
|
|
69
|
+
* For preview: call with defaults (no placeholders, no form fields) — field positions
|
|
70
|
+
* are still tracked so React overlays can render on top of the PDF image.
|
|
71
|
+
*
|
|
72
|
+
* For export: call with { embedFormFields: true } to bake interactive form fields
|
|
73
|
+
* into the PDF for downstream consumption (e.g. pdf-signer).
|
|
74
|
+
*/
|
|
75
|
+
export declare function generatePdfFromContent(content: JSONContent, options?: PdfGenerationOptions): Promise<PdfGenerationResult>;
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=pdf-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-generator.d.ts","sourceRoot":"","sources":["../../src/utils/pdf-generator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAiB,KAAK,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAe9F;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,6EAA6E;AAC7E,MAAM,WAAW,aAAa;IAC5B,8DA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CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAyH9B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF Metadata Utilities
|
|
3
|
+
* Functions for storing and retrieving Signiphi metadata in PDF documents.
|
|
4
|
+
* Matches the format used by @signiphi/document-prepare and read by @signiphi/pdf-signer.
|
|
5
|
+
*/
|
|
6
|
+
import type { PDFDocument, PDFName as PDFNameType, PDFString as PDFStringType } from 'pdf-lib';
|
|
7
|
+
import type { Acknowledgement } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Initialize PDF classes from the pdf-lib module.
|
|
10
|
+
* Must be called before using setSigniphiMetadata.
|
|
11
|
+
*/
|
|
12
|
+
export declare function initPdfMetadata(pdfLibModule: {
|
|
13
|
+
PDFName: typeof PDFNameType;
|
|
14
|
+
PDFString: typeof PDFStringType;
|
|
15
|
+
}): void;
|
|
16
|
+
/**
|
|
17
|
+
* Metadata for a single form field
|
|
18
|
+
*/
|
|
19
|
+
export interface FieldMetadata {
|
|
20
|
+
fieldId?: string;
|
|
21
|
+
label?: string;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
acknowledgements?: Acknowledgement[];
|
|
24
|
+
required?: boolean;
|
|
25
|
+
options?: string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Complete metadata structure stored in PDF — compatible with document-prepare & pdf-signer
|
|
29
|
+
*/
|
|
30
|
+
export interface SigniphiMetadata {
|
|
31
|
+
version: string;
|
|
32
|
+
fields: Record<string, FieldMetadata>;
|
|
33
|
+
fieldIdIndex?: Record<string, string>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Stores Signiphi metadata in the PDF's document information dictionary.
|
|
37
|
+
*/
|
|
38
|
+
export declare function setSigniphiMetadata(pdfDoc: PDFDocument, metadata: SigniphiMetadata): void;
|
|
39
|
+
/**
|
|
40
|
+
* Input field shape for building metadata (subset of DocumentGeneratorField)
|
|
41
|
+
*/
|
|
42
|
+
interface MetadataFieldInput {
|
|
43
|
+
fieldId: string;
|
|
44
|
+
name: string;
|
|
45
|
+
label?: string;
|
|
46
|
+
placeholder?: string;
|
|
47
|
+
acknowledgements?: Acknowledgement[];
|
|
48
|
+
required?: boolean;
|
|
49
|
+
options?: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Builds a metadata object from form fields.
|
|
53
|
+
* @param fields - Array of fields to extract metadata from
|
|
54
|
+
* @param actualFieldNames - Mapping of base field name → actual PDF field name (with suffixes)
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildMetadataObject(fields: MetadataFieldInput[], actualFieldNames?: Map<string, string>): SigniphiMetadata;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=pdf-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-metadata.d.ts","sourceRoot":"","sources":["../../src/utils/pdf-metadata.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,IAAI,WAAW,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAOhD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,OAAO,EAAE,OAAO,WAAW,CAAC;IAAC,SAAS,EAAE,OAAO,aAAa,CAAA;CAAE,GAAG,IAAI,CAGpH;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAkBzF;AAED;;GAEG;AACH,UAAU,kBAAkB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,kBAAkB,EAAE,EAC5B,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACrC,gBAAgB,CA+BlB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PdfPage } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Convert PDF bytes to page images using pdfjs-dist for the preview panel.
|
|
4
|
+
* Dynamically imports pdfjs-dist to avoid SSR issues.
|
|
5
|
+
*/
|
|
6
|
+
export declare function pdfToImages(pdfBytes: Uint8Array, scale?: number): Promise<PdfPage[]>;
|
|
7
|
+
//# sourceMappingURL=pdf-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-preview.d.ts","sourceRoot":"","sources":["../../src/utils/pdf-preview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,UAAU,EACpB,KAAK,GAAE,MAAU,GAChB,OAAO,CAAC,OAAO,EAAE,CAAC,CAyEpB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { JSONContent } from '@tiptap/core';
|
|
2
|
+
import type { PdfTheme, PdfPageHeader, PdfPageFooter } from './pdf-generator';
|
|
3
|
+
export interface HeadlessPdfResult {
|
|
4
|
+
pdfBytes: Uint8Array<ArrayBuffer>;
|
|
5
|
+
/** Non-fatal warnings about images that failed to load/embed */
|
|
6
|
+
imageWarnings?: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Presentation options for headless generation. All optional — omitting them
|
|
10
|
+
* reproduces the classic output exactly (backward compatible).
|
|
11
|
+
*/
|
|
12
|
+
export interface HeadlessPdfOptions {
|
|
13
|
+
/** Brand colors (table headers, panel headers, rules) */
|
|
14
|
+
theme?: PdfTheme;
|
|
15
|
+
/** Repeating page header (top margin of every page) */
|
|
16
|
+
header?: PdfPageHeader;
|
|
17
|
+
/** Repeating page footer (next to the page number) */
|
|
18
|
+
footer?: PdfPageFooter;
|
|
19
|
+
/** Draw visual placeholder boxes for fields (default: false) */
|
|
20
|
+
drawFieldPlaceholders?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generate a PDF from TipTap JSON content with variable values applied.
|
|
24
|
+
*
|
|
25
|
+
* Pipeline: expand repeats -> expand block variables -> suppress zeros ->
|
|
26
|
+
* replace variables -> render PDF.
|
|
27
|
+
* Pure function — no React, no DOM, no editor instance required.
|
|
28
|
+
*/
|
|
29
|
+
export declare function generatePdfFromTiptap(content: JSONContent, values: Record<string, string>, options?: HeadlessPdfOptions): Promise<HeadlessPdfResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Generate a PDF from extended markdown with variable values applied.
|
|
32
|
+
*
|
|
33
|
+
* This is the Phase 2 headless entry point:
|
|
34
|
+
* markdown template + data values -> PDF bytes
|
|
35
|
+
*
|
|
36
|
+
* Pure function — no React, no DOM, no editor instance required.
|
|
37
|
+
*/
|
|
38
|
+
export declare function generatePdfFromMarkdown(markdown: string, values: Record<string, string>, options?: HeadlessPdfOptions): Promise<HeadlessPdfResult>;
|
|
39
|
+
//# sourceMappingURL=template-pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-pipeline.d.ts","sourceRoot":"","sources":["../../src/utils/template-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG9E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IAClC,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,uDAAuD;IACvD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,sDAAsD;IACtD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,gEAAgE;IAChE,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CAkB5B;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CAG5B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare function parseThemeColor(color: string): string;
|
|
2
|
+
export declare function getContrastColor(backgroundColor: string): string;
|
|
3
|
+
export declare function applyThemeColor(element: HTMLElement, color: string, config?: {
|
|
4
|
+
primaryForeground?: string;
|
|
5
|
+
background?: string;
|
|
6
|
+
foreground?: string;
|
|
7
|
+
secondary?: string;
|
|
8
|
+
secondaryForeground?: string;
|
|
9
|
+
muted?: string;
|
|
10
|
+
mutedForeground?: string;
|
|
11
|
+
accent?: string;
|
|
12
|
+
accentForeground?: string;
|
|
13
|
+
border?: string;
|
|
14
|
+
input?: string;
|
|
15
|
+
ring?: string;
|
|
16
|
+
card?: string;
|
|
17
|
+
cardForeground?: string;
|
|
18
|
+
}): void;
|
|
19
|
+
export declare function detectSystemTheme(): 'light' | 'dark';
|
|
20
|
+
export declare function getEffectiveThemeMode(themeMode?: 'light' | 'dark' | 'auto'): 'light' | 'dark';
|
|
21
|
+
//# sourceMappingURL=theme-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/theme-helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAerD;AAED,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAoBhE;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE;IACP,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GACA,IAAI,CAeN;AAED,wBAAgB,iBAAiB,IAAI,OAAO,GAAG,MAAM,CASpD;AAED,wBAAgB,qBAAqB,CAAC,SAAS,GAAE,OAAO,GAAG,MAAM,GAAG,MAAe,GAAG,OAAO,GAAG,MAAM,CAKrG"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { JSONContent } from '@tiptap/core';
|
|
2
|
+
import type { DocumentGeneratorVariable } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Extract all unique variables from TipTap content.
|
|
5
|
+
* Deduplicates by varName (same name = same variable).
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractVariablesFromContent(content: JSONContent): DocumentGeneratorVariable[];
|
|
8
|
+
/**
|
|
9
|
+
* Replace variable nodes in TipTap content with plain text nodes.
|
|
10
|
+
* Returns a new content tree (does not mutate the input).
|
|
11
|
+
*/
|
|
12
|
+
export declare function replaceVariablesInContent(content: JSONContent, values: Record<string, string>): JSONContent;
|
|
13
|
+
/**
|
|
14
|
+
* Expand block-level variables into parsed markdown blocks.
|
|
15
|
+
*
|
|
16
|
+
* A variable renders as a *block* (its value parsed as extended markdown and
|
|
17
|
+
* spliced in as block nodes — headings, tables, lists, etc.) when it is the
|
|
18
|
+
* sole content of a paragraph AND either:
|
|
19
|
+
* - the token carries `block:true`, or
|
|
20
|
+
* - the resolved value contains a newline (auto-detect — a multi-line value
|
|
21
|
+
* can never render meaningfully as inline text).
|
|
22
|
+
*
|
|
23
|
+
* Variables mixed inline with other content always stay plain-text
|
|
24
|
+
* substitutions. An empty block value removes the paragraph entirely so
|
|
25
|
+
* optional sections (checklists, inspections) collapse without a gap.
|
|
26
|
+
*
|
|
27
|
+
* Safety rails:
|
|
28
|
+
* - Form-field and watermark tokens inside *values* are stripped — fields
|
|
29
|
+
* and document-wide watermarks may only come from the template, never
|
|
30
|
+
* from data (a description containing `{{field|type:signature|...}}`
|
|
31
|
+
* must not inject a signable field; `:::watermark{text:PAID}` must not
|
|
32
|
+
* stamp every page).
|
|
33
|
+
* - Inside table cells, expansion only happens when every parsed block is a
|
|
34
|
+
* paragraph or heading (the cell renderer can't draw nested tables/lists —
|
|
35
|
+
* splicing them there would silently drop content).
|
|
36
|
+
*
|
|
37
|
+
* Call this AFTER expandRepeatContent and BEFORE suppressZeroContent /
|
|
38
|
+
* replaceVariablesInContent.
|
|
39
|
+
*/
|
|
40
|
+
export declare function expandBlockVariables(content: JSONContent, values: Record<string, string>): JSONContent;
|
|
41
|
+
/**
|
|
42
|
+
* Auto-generate a snake_case variable name from a label.
|
|
43
|
+
*/
|
|
44
|
+
export declare function labelToVarName(label: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a variable value is zero-like (empty, zero, or formatted zero).
|
|
47
|
+
* Matches: "", " ", "0", "0.00", "$0.00", "-0.00", etc.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isZeroLike(value: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Walk TipTap content tree and remove table rows or paragraphs
|
|
52
|
+
* that contain a variableNode with suppressZero='true' whose
|
|
53
|
+
* resolved value is zero-like.
|
|
54
|
+
*
|
|
55
|
+
* Call this BEFORE replaceVariablesInContent so the variable nodes
|
|
56
|
+
* still carry their attrs (varName, suppressZero).
|
|
57
|
+
*/
|
|
58
|
+
export declare function suppressZeroContent(content: JSONContent, values: Record<string, string>): JSONContent;
|
|
59
|
+
/**
|
|
60
|
+
* Expand `repeatBlock` nodes by cloning their inner content for each item
|
|
61
|
+
* in the data array. Variable names inside the repeat are remapped from
|
|
62
|
+
* `operation_X` → `{dataKey}_{index}_{X}`.
|
|
63
|
+
*
|
|
64
|
+
* The data array is stored as a JSON string in `values[dataKey]`.
|
|
65
|
+
* Returns the expanded content tree and an enriched values dict with
|
|
66
|
+
* flattened indexed keys (e.g. `operations_0_opcode`, `operations_1_opcode`).
|
|
67
|
+
*
|
|
68
|
+
* Call this BEFORE suppressZeroContent / replaceVariablesInContent.
|
|
69
|
+
*/
|
|
70
|
+
export declare function expandRepeatContent(content: JSONContent, values: Record<string, string>): {
|
|
71
|
+
content: JSONContent;
|
|
72
|
+
values: Record<string, string>;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=variable-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/variable-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAG1D;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,WAAW,GAAG,yBAAyB,EAAE,CAuB7F;AAeD;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,WAAW,CA+Bb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,WAAW,CAsDb;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKpD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAIjD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,WAAW,CAgDb;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B;IAAE,OAAO,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CA+F1D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DocumentGeneratorVariable } from '../types';
|
|
2
|
+
export interface XmlTemplateParseResult {
|
|
3
|
+
markdown: string;
|
|
4
|
+
variables: DocumentGeneratorVariable[];
|
|
5
|
+
reportName: string;
|
|
6
|
+
warnings: string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function parseXmlTemplate(xmlString: string): XmlTemplateParseResult;
|
|
9
|
+
//# sourceMappingURL=xml-template-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xml-template-parser.d.ts","sourceRoot":"","sources":["../../src/utils/xml-template-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAG1D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,yBAAyB,EAAE,CAAC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AA21BD,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,sBAAsB,CAwI1E"}
|