pagepilot-visual-editor 1.0.8 → 1.0.9

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.
@@ -0,0 +1,107 @@
1
+ import { TReaderDocument } from './email-builder-core';
2
+ import { TemplateFormField } from './editor-sample/documents/editor/templateVariables';
3
+ interface BaseRenderOptions {
4
+ /** Root block id inside the document. Defaults to `"root"`. */
5
+ rootBlockId?: string;
6
+ injectElementIds?: boolean;
7
+ minifyCss?: boolean;
8
+ includePageCSS?: boolean;
9
+ lang?: string;
10
+ skipLink?: any;
11
+ accessibilityTools?: any;
12
+ injectTabsScrollSyncScript?: boolean;
13
+ injectCarouselScript?: boolean;
14
+ injectFontAssets?: boolean;
15
+ seo?: any;
16
+ headHtml?: string;
17
+ bodyBottomHtml?: string;
18
+ isBanner?: boolean;
19
+ }
20
+ interface ApiCommonOptions extends BaseRenderOptions {
21
+ /** API root, e.g. "https://pagepilot.fabbuilder.com/api". */
22
+ baseUrl: string;
23
+ /** Tenant id used in `/tenant/${tenantId}/…` paths. Optional for global templates. */
24
+ tenantId?: string;
25
+ /** Optional service-account bearer token. */
26
+ authToken?: string;
27
+ /** Optional custom fetch. Defaults to global `fetch`. */
28
+ fetchFn?: typeof fetch;
29
+ }
30
+ export interface RenderToStaticHtmlSyncOptions extends BaseRenderOptions {
31
+ pageId?: undefined;
32
+ templateId?: undefined;
33
+ baseUrl?: undefined;
34
+ tenantId?: undefined;
35
+ authToken?: undefined;
36
+ variables?: undefined;
37
+ }
38
+ export interface RenderToStaticHtmlPageOptions extends ApiCommonOptions {
39
+ /** Page id (`_id`) to fetch and render. */
40
+ pageId: string;
41
+ templateId?: undefined;
42
+ /** Required for the tenant-scoped page endpoint. */
43
+ tenantId: string;
44
+ /**
45
+ * Wrap concatenated section fragments in a `<!doctype html>` shell —
46
+ * matches Shell.tsx's Save Changes / Publish output. Defaults to `true`.
47
+ */
48
+ wrapInDocumentShell?: boolean;
49
+ variables?: undefined;
50
+ }
51
+ export interface RenderToStaticHtmlTemplateOptions extends ApiCommonOptions {
52
+ /** Template id (`_id`) to fetch. */
53
+ templateId: string;
54
+ pageId?: undefined;
55
+ /**
56
+ * Variable overrides. Two shapes accepted:
57
+ *
58
+ * 1. Flat map keyed by `formField.id` — values stringified before
59
+ * substitution:
60
+ * variables: { fname: 'Ishaan', ctaText: 'Book Now' }
61
+ *
62
+ * 2. Array of TemplateFormField-shaped objects — same shape the API
63
+ * stores under `configuration.formFields`. Every field is merged
64
+ * by `id` into the template's existing fields (values, itemFields,
65
+ * sourceBlockId, rowIds, etc. all override):
66
+ * variables: [
67
+ * { id: 'ctaText', name: 'CTA Text', type: 'text', value: 'Book Now' },
68
+ * { id: 'fabFaqs', type: 'array', value: [ … row overrides … ] },
69
+ * ]
70
+ *
71
+ * Ids that don't exist on the template's `formFields` are appended as
72
+ * text-type fields (flat-map case) or as full field entries (array case)
73
+ * so a `{{fname}}` token in the template still substitutes.
74
+ */
75
+ variables?: Record<string, string | number | boolean | null | undefined> | Array<Partial<TemplateFormField>>;
76
+ /**
77
+ * When `true`, fetch from the public `/global-template/${templateId}`
78
+ * endpoint (no tenant, no auth). When `false` (the default), fetch from
79
+ * the tenant-scoped `/tenant/${tenantId}/template/${templateId}`.
80
+ */
81
+ isGlobal?: boolean;
82
+ }
83
+ export type RenderToStaticHtmlOptions = RenderToStaticHtmlSyncOptions | RenderToStaticHtmlPageOptions | RenderToStaticHtmlTemplateOptions;
84
+ /**
85
+ * Render a document configuration to HTML.
86
+ *
87
+ * @example Sync (no API):
88
+ * const generatedHtml = renderToStaticHtml(CONFIGURATION, { rootBlockId: 'root' });
89
+ *
90
+ * @example Page from API (async):
91
+ * const generatedHtml = await renderToStaticHtml(CONFIGURATION, {
92
+ * rootBlockId: 'root',
93
+ * pageId, baseUrl, tenantId, authToken,
94
+ * });
95
+ *
96
+ * @example Template from API with variable substitution (async):
97
+ * const generatedHtml = await renderToStaticHtml({}, {
98
+ * rootBlockId: 'root',
99
+ * templateId, baseUrl, tenantId, authToken,
100
+ * variables: { fname: 'Ishaan' },
101
+ * isGlobal: false, // true → /global-template/:templateId
102
+ * });
103
+ */
104
+ export declare function renderToStaticHtml(CONFIGURATION: TReaderDocument | any, options: RenderToStaticHtmlSyncOptions): string;
105
+ export declare function renderToStaticHtml(CONFIGURATION: TReaderDocument | any | null | undefined, options: RenderToStaticHtmlPageOptions): Promise<string>;
106
+ export declare function renderToStaticHtml(CONFIGURATION: TReaderDocument | any | null | undefined, options: RenderToStaticHtmlTemplateOptions): Promise<string>;
107
+ export default renderToStaticHtml;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pagepilot-visual-editor",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Standalone visual editor — drop <PagePilotEditor> into any React app and get Style/Layout/Inspect/Layers panels, drag-and-drop blocks, undo/redo, dirty-tracked save, multi-section pages, and light/dark themes",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",