@bambamboole/pdf-ua-template-builder 0.3.1 → 0.4.0
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/api/pdfUaApi.d.ts +10 -0
- package/dist/html-editor/HtmlCodeEditor.d.ts +4 -0
- package/dist/html-editor/HtmlEditor.d.ts +22 -0
- package/dist/html-editor/HtmlEditorContext.d.ts +25 -0
- package/dist/html-editor/HtmlPreview.d.ts +4 -0
- package/dist/html-editor/defaultHtml.d.ts +2 -0
- package/dist/html-editor/useHtmlPreview.d.ts +13 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +851 -655
- package/dist/index.js.map +1 -1
- package/dist/render/previewChrome.d.ts +19 -0
- package/dist/style.css +1 -1
- package/package.json +2 -1
package/dist/api/pdfUaApi.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
import { FileAttachment } from '../types/generated/template';
|
|
1
2
|
import { RenderOptions, Template, TemplateData, TemplateSchemaResponse } from '../types/template';
|
|
2
3
|
interface RenderTemplateRequest {
|
|
3
4
|
template: Template;
|
|
4
5
|
data?: TemplateData;
|
|
5
6
|
options?: RenderOptions;
|
|
6
7
|
}
|
|
8
|
+
export interface ConvertHtmlRequest {
|
|
9
|
+
/** Raw HTML document to convert to a PDF/UA document. */
|
|
10
|
+
html: string;
|
|
11
|
+
/** Base URL used to resolve relative asset references in the HTML. */
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
/** Files to embed in the produced PDF/A-3 document. */
|
|
14
|
+
attachments?: FileAttachment[];
|
|
15
|
+
}
|
|
7
16
|
export declare function resolveDefaultApiUrl(configuredApiUrl?: string): string;
|
|
8
17
|
export declare function fetchTemplateSchema(baseUrl: string): Promise<TemplateSchemaResponse>;
|
|
9
18
|
export declare function renderTemplatePdf(baseUrl: string, request: RenderTemplateRequest): Promise<Blob>;
|
|
19
|
+
export declare function renderHtmlPdf(baseUrl: string, request: ConvertHtmlRequest): Promise<Blob>;
|
|
10
20
|
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface HtmlEditorProps {
|
|
2
|
+
/** Base URL of a running pdf-ua-api instance. Defaults to "" (relative URLs / proxy). */
|
|
3
|
+
apiUrl?: string;
|
|
4
|
+
/** Base URL used to resolve relative asset references in the HTML. */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/** HTML seeded into the editor on first render. Defaults to a small accessible document. */
|
|
7
|
+
initialHtml?: string;
|
|
8
|
+
/** Fires on every edit with the current HTML text. */
|
|
9
|
+
onChange?: (html: string) => void;
|
|
10
|
+
/** Fires after a successful render with the produced PDF blob. */
|
|
11
|
+
onRendered?: (pdf: Blob) => void;
|
|
12
|
+
/** Optional className appended to the root element. */
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* All-in-one preset: a raw-HTML editor and a rendered-PDF preview side by side.
|
|
17
|
+
* The preview is produced by the backend `POST /convert` (HTML → PDF/UA) endpoint.
|
|
18
|
+
*
|
|
19
|
+
* For custom layouts, compose directly with `HtmlEditorProvider`, `HtmlCodeEditor`,
|
|
20
|
+
* and `HtmlPreview`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function HtmlEditor({ apiUrl, baseUrl, initialHtml, onChange, onRendered, className, }?: HtmlEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface HtmlEditorProviderProps {
|
|
3
|
+
/** Base URL of a running pdf-ua-api instance. Defaults to "" (relative URLs / proxy). */
|
|
4
|
+
apiUrl?: string;
|
|
5
|
+
/** Base URL used to resolve relative asset references in the HTML. */
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
/** HTML seeded into the editor on first render. Defaults to a small accessible document. */
|
|
8
|
+
initialHtml?: string;
|
|
9
|
+
/** Fires on every edit with the current HTML text. */
|
|
10
|
+
onChange?: (html: string) => void;
|
|
11
|
+
/** Fires after a successful render with the produced PDF blob. */
|
|
12
|
+
onRendered?: (pdf: Blob) => void;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export interface HtmlEditorContextValue {
|
|
16
|
+
html: string;
|
|
17
|
+
setHtml: (html: string) => void;
|
|
18
|
+
pdfUrl: string | null;
|
|
19
|
+
pdfLoading: boolean;
|
|
20
|
+
error: string | null;
|
|
21
|
+
renderPdf: () => void;
|
|
22
|
+
renderDisabled: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function useHtmlEditor(): HtmlEditorContextValue;
|
|
25
|
+
export declare function HtmlEditorProvider({ apiUrl: apiUrlProp, baseUrl, initialHtml, onChange, onRendered, children, }: HtmlEditorProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Seed document for the HTML editor: a small, accessible page that renders cleanly to PDF/UA. */
|
|
2
|
+
export declare const DEFAULT_HTML = "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <title>Untitled document</title>\n <style>\n body {\n font-family: system-ui, sans-serif;\n margin: 2rem;\n color: #1a1a1a;\n line-height: 1.5;\n }\n h1 {\n font-size: 1.75rem;\n margin-bottom: 0.5rem;\n }\n </style>\n </head>\n <body>\n <h1>Hello, PDF/UA</h1>\n <p>Edit this HTML and render it to preview the accessible PDF.</p>\n </body>\n</html>\n";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface UseHtmlPreviewOptions {
|
|
2
|
+
apiUrl: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
onRendered?: (pdf: Blob) => void;
|
|
5
|
+
}
|
|
6
|
+
interface HtmlPreview {
|
|
7
|
+
pdfUrl: string | null;
|
|
8
|
+
loading: boolean;
|
|
9
|
+
error: string | null;
|
|
10
|
+
render: (html: string) => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare function useHtmlPreview({ apiUrl, baseUrl, onRendered }: UseHtmlPreviewOptions): HtmlPreview;
|
|
13
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,15 @@ export { CodeEditor } from './editor/CodeEditor';
|
|
|
18
18
|
export type { CodeEditorProps } from './editor/CodeEditor';
|
|
19
19
|
export { TemplateEditorProvider, useTemplateEditor, } from './editor/TemplateEditorContext';
|
|
20
20
|
export type { TemplateEditorProviderProps, TemplateEditorContextValue, } from './editor/TemplateEditorContext';
|
|
21
|
-
export {
|
|
21
|
+
export { HtmlEditor } from './html-editor/HtmlEditor';
|
|
22
|
+
export type { HtmlEditorProps } from './html-editor/HtmlEditor';
|
|
23
|
+
export { HtmlCodeEditor } from './html-editor/HtmlCodeEditor';
|
|
24
|
+
export type { HtmlCodeEditorProps } from './html-editor/HtmlCodeEditor';
|
|
25
|
+
export { HtmlPreview } from './html-editor/HtmlPreview';
|
|
26
|
+
export type { HtmlPreviewProps } from './html-editor/HtmlPreview';
|
|
27
|
+
export { HtmlEditorProvider, useHtmlEditor } from './html-editor/HtmlEditorContext';
|
|
28
|
+
export type { HtmlEditorProviderProps, HtmlEditorContextValue, } from './html-editor/HtmlEditorContext';
|
|
29
|
+
export { fetchTemplateSchema, renderTemplatePdf, renderHtmlPdf, resolveDefaultApiUrl, } from './api/pdfUaApi';
|
|
30
|
+
export type { ConvertHtmlRequest } from './api/pdfUaApi';
|
|
22
31
|
export type { TemplateData, TemplateSchemaResponse } from './types/template';
|
|
23
32
|
export type { Align, Block, HeadingBlock, ImageBlock, KeyValueBlock, Orientation, PageConfig, PageFormat, PageSize, Row, SpacerBlock, TableBlock, Template, TextBlock, } from './types/generated/template';
|