@unlayer/react-elements 0.1.21 → 0.2.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/README.md +65 -3
- package/dist/index.cjs +1416 -492
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +71 -11
- package/dist/index.d.ts +71 -11
- package/dist/index.js +1396 -492
- package/dist/index.js.map +1 -1
- package/package.json +11 -5
package/dist/index.d.cts
CHANGED
|
@@ -16,6 +16,8 @@ import { MenuValues } from '@unlayer/types/tools/menu';
|
|
|
16
16
|
export { MenuValues } from '@unlayer/types/tools/menu';
|
|
17
17
|
import { ParagraphValues } from '@unlayer/types/tools/paragraph';
|
|
18
18
|
export { ParagraphValues } from '@unlayer/types/tools/paragraph';
|
|
19
|
+
import { PageBreakValues } from '@unlayer/types/tools/page-break';
|
|
20
|
+
export { PageBreakValues } from '@unlayer/types/tools/page-break';
|
|
19
21
|
import { SocialValues } from '@unlayer/types/tools/social';
|
|
20
22
|
export { SocialValues } from '@unlayer/types/tools/social';
|
|
21
23
|
import { TableValues } from '@unlayer/types/tools/table';
|
|
@@ -140,6 +142,24 @@ interface DesignJSON {
|
|
|
140
142
|
body: DesignBody;
|
|
141
143
|
schemaVersion: number;
|
|
142
144
|
}
|
|
145
|
+
/** Phone settings use the same flat CSS inputs as desktop props. */
|
|
146
|
+
interface MobileProps {
|
|
147
|
+
padding?: number | string;
|
|
148
|
+
containerPadding?: number | string;
|
|
149
|
+
fontSize?: number | string;
|
|
150
|
+
lineHeight?: number | string;
|
|
151
|
+
textAlign?: TextAlign;
|
|
152
|
+
width?: number | string;
|
|
153
|
+
maxWidth?: number | string;
|
|
154
|
+
autoWidth?: boolean;
|
|
155
|
+
/** Column border on this device (per side, as the desktop `border`). */
|
|
156
|
+
border?: Partial<Record<`border${"Top" | "Right" | "Bottom" | "Left"}${"Width" | "Style" | "Color"}`, number | string>>;
|
|
157
|
+
}
|
|
158
|
+
interface DeviceProps {
|
|
159
|
+
mobile?: MobileProps;
|
|
160
|
+
hideOnMobile?: boolean;
|
|
161
|
+
hideOnDesktop?: boolean;
|
|
162
|
+
}
|
|
143
163
|
|
|
144
164
|
interface HeadConfig {
|
|
145
165
|
hasFeature?: (featureName: string) => boolean;
|
|
@@ -222,6 +242,7 @@ declare function htmlToTextJson(html: string): string;
|
|
|
222
242
|
* - Users can pass: { color: "red", backgroundColor: "blue" } OR { buttonColors: { color: "red" } }
|
|
223
243
|
* - TypeScript provides autocomplete for ALL properties (flat and nested)
|
|
224
244
|
*/
|
|
245
|
+
|
|
225
246
|
/**
|
|
226
247
|
* Type utility: Extracts all properties from nested objects
|
|
227
248
|
* This provides TypeScript autocomplete for flat props!
|
|
@@ -235,7 +256,7 @@ type FlattenObjectProps<T> = T extends object ? {
|
|
|
235
256
|
* Semantic props type for any component.
|
|
236
257
|
* Generic TChildren parameter allows each framework to supply its own child type.
|
|
237
258
|
*/
|
|
238
|
-
type SemanticProps$1<T, TChildren = any> = FlattenObjectProps<T> & {
|
|
259
|
+
type SemanticProps$1<T, TChildren = any> = Omit<FlattenObjectProps<T>, keyof DeviceProps> & DeviceProps & {
|
|
239
260
|
children?: TChildren;
|
|
240
261
|
values?: T;
|
|
241
262
|
/** HTML string with inline formatting for Paragraph (e.g. `'Hello <b>bold</b>'`) */
|
|
@@ -305,7 +326,7 @@ type ImageSrcInput = string | {
|
|
|
305
326
|
/**
|
|
306
327
|
* Base props that all item components support
|
|
307
328
|
*/
|
|
308
|
-
interface BaseItemComponentProps {
|
|
329
|
+
interface BaseItemComponentProps extends DeviceProps {
|
|
309
330
|
children?: React__default.ReactNode;
|
|
310
331
|
className?: string;
|
|
311
332
|
style?: React__default.CSSProperties;
|
|
@@ -330,7 +351,7 @@ interface BaseItemComponentProps {
|
|
|
330
351
|
/**
|
|
331
352
|
* Props type that combines base props with semantic props
|
|
332
353
|
*/
|
|
333
|
-
type ItemComponentProps<TSemanticProps> = BaseItemComponentProps & TSemanticProps
|
|
354
|
+
type ItemComponentProps<TSemanticProps> = BaseItemComponentProps & Omit<TSemanticProps, keyof DeviceProps>;
|
|
334
355
|
|
|
335
356
|
/**
|
|
336
357
|
* React Semantic Props
|
|
@@ -592,6 +613,15 @@ interface ParagraphProps extends ItemComponentProps<ParagraphSemanticProps> {
|
|
|
592
613
|
*/
|
|
593
614
|
declare const Paragraph: React$1.FC<ItemComponentProps<ParagraphSemanticProps>>;
|
|
594
615
|
|
|
616
|
+
type PageBreakProps = ItemComponentProps<SemanticProps<PageBreakValues>>;
|
|
617
|
+
/**
|
|
618
|
+
* PageBreak - Forces subsequent document content onto a new PDF page.
|
|
619
|
+
*
|
|
620
|
+
* Page breaks render only in document mode. In email and web output they are
|
|
621
|
+
* intentionally inert.
|
|
622
|
+
*/
|
|
623
|
+
declare const PageBreak: React$1.FC<ItemComponentProps<SemanticProps<PageBreakValues>>>;
|
|
624
|
+
|
|
595
625
|
type SocialSemanticProps = Omit<SemanticProps<SocialValues>, "iconSize" | "spacing"> & {
|
|
596
626
|
/** Social icons shorthand (array of {name, url}) */
|
|
597
627
|
icons?: SocialIcon[];
|
|
@@ -694,7 +724,7 @@ interface VideoProps extends ItemComponentProps<SemanticProps<VideoValues>> {
|
|
|
694
724
|
*/
|
|
695
725
|
declare const Video: React$1.FC<ItemComponentProps<VideoSemanticProps>>;
|
|
696
726
|
|
|
697
|
-
type RowProps = Omit<SemanticProps<RowValues>, "padding"> & {
|
|
727
|
+
type RowProps = Omit<SemanticProps<RowValues>, "padding" | keyof DeviceProps> & DeviceProps & {
|
|
698
728
|
children?: React__default.ReactNode;
|
|
699
729
|
layout?: ColumnLayout;
|
|
700
730
|
cells?: number[];
|
|
@@ -711,7 +741,7 @@ type RowProps = Omit<SemanticProps<RowValues>, "padding"> & {
|
|
|
711
741
|
};
|
|
712
742
|
declare const Row: React__default.FC<RowProps>;
|
|
713
743
|
|
|
714
|
-
type ColumnProps = Omit<SemanticProps<ColumnValues>, "padding" | "border" | "borderRadius"> & {
|
|
744
|
+
type ColumnProps = Omit<SemanticProps<ColumnValues>, "padding" | "border" | "borderRadius" | keyof DeviceProps> & Omit<DeviceProps, "hideOnMobile" | "hideOnDesktop"> & {
|
|
715
745
|
children?: React__default.ReactNode;
|
|
716
746
|
index?: number;
|
|
717
747
|
cells?: number[];
|
|
@@ -742,6 +772,17 @@ type BodyProps = Omit<SemanticProps<BodyValues>, "padding" | "borderRadius"> & {
|
|
|
742
772
|
config?: Partial<UnlayerConfig>;
|
|
743
773
|
/** Preview text shown in email client inboxes (email mode only) */
|
|
744
774
|
previewText?: string;
|
|
775
|
+
/** Document text direction, also kept in the design JSON. Renderer options can override it. */
|
|
776
|
+
textDirection?: string;
|
|
777
|
+
/** Language of the rendered document (for example, "ar"). */
|
|
778
|
+
lang?: string;
|
|
779
|
+
/**
|
|
780
|
+
* Web font stylesheets the content uses (e.g. a Google Fonts CSS URL).
|
|
781
|
+
* renderToHtml links them in the document head, with any `fonts` option.
|
|
782
|
+
*/
|
|
783
|
+
fonts?: Array<{
|
|
784
|
+
url: string;
|
|
785
|
+
}>;
|
|
745
786
|
/** Padding — a CSS string ("0 48px", "20px") or a number (px). */
|
|
746
787
|
padding?: SizeInput;
|
|
747
788
|
/** Corner radius — a number (→ px) or CSS string ("8px"). */
|
|
@@ -806,7 +847,12 @@ declare namespace Page {
|
|
|
806
847
|
var displayName: string;
|
|
807
848
|
}
|
|
808
849
|
|
|
809
|
-
type
|
|
850
|
+
type DocumentPageSize = "A3" | "A4" | "A5" | "Legal" | "Letter" | "Tabloid";
|
|
851
|
+
type DocumentOrientation = "portrait" | "landscape";
|
|
852
|
+
type DocumentProps = Omit<BodyProps, "mode" | "documentSize" | "documentOrientation" | "documentMargin"> & {
|
|
853
|
+
documentSize?: DocumentPageSize;
|
|
854
|
+
documentOrientation?: DocumentOrientation;
|
|
855
|
+
};
|
|
810
856
|
/**
|
|
811
857
|
* Document - Print-optimized rendering for PDF generation.
|
|
812
858
|
*
|
|
@@ -814,7 +860,12 @@ type DocumentProps = Omit<BodyProps, "mode">;
|
|
|
814
860
|
*
|
|
815
861
|
* @example
|
|
816
862
|
* ```tsx
|
|
817
|
-
* <Document
|
|
863
|
+
* <Document
|
|
864
|
+
* backgroundColor="#ffffff"
|
|
865
|
+
* contentWidth="700px"
|
|
866
|
+
* documentSize="A4"
|
|
867
|
+
* documentOrientation="portrait"
|
|
868
|
+
* >
|
|
818
869
|
* <Row><Column><Paragraph text="Hello" /></Column></Row>
|
|
819
870
|
* </Document>
|
|
820
871
|
* ```
|
|
@@ -835,6 +886,8 @@ declare function useUnlayerConfig(): UnlayerConfig;
|
|
|
835
886
|
* Options for renderToHtml — config overrides plus document-level extras.
|
|
836
887
|
*/
|
|
837
888
|
interface RenderToHtmlOptions extends Partial<UnlayerConfig> {
|
|
889
|
+
/** Document language; overrides the root's `lang` prop. */
|
|
890
|
+
lang?: string;
|
|
838
891
|
/** Document `<title>` */
|
|
839
892
|
title?: string;
|
|
840
893
|
/**
|
|
@@ -859,7 +912,11 @@ interface RenderToHtmlOptions extends Partial<UnlayerConfig> {
|
|
|
859
912
|
* Use {@link renderToHtmlParts} instead when your app owns the document
|
|
860
913
|
* shell and only needs the head/body chunks.
|
|
861
914
|
*
|
|
862
|
-
* @param element - A React element tree (e.g. `<Email><Row>...</Row></Email>`)
|
|
915
|
+
* @param element - A React element tree (e.g. `<Email><Row>...</Row></Email>`), or a
|
|
916
|
+
* template component that returns one (`<Welcome name="Ada" />`, also `memo`/`forwardRef`).
|
|
917
|
+
* A template is called in a render of its own to reach its root (its hooks work); a class
|
|
918
|
+
* component, or one that doesn't return an element, renders without its root's settings,
|
|
919
|
+
* with a warning.
|
|
863
920
|
* @param options - Config overrides (mode, cdnBaseUrl, etc.) plus `title` and `fonts`
|
|
864
921
|
* @returns Complete HTML document string
|
|
865
922
|
* @throws {Error} If rendering fails, with a helpful message
|
|
@@ -1095,8 +1152,11 @@ interface ElementsToolConfig {
|
|
|
1095
1152
|
/** Editor-only fields (label, icon, options, validator, ...) — ignored */
|
|
1096
1153
|
[editorOnly: string]: unknown;
|
|
1097
1154
|
}
|
|
1098
|
-
/**
|
|
1099
|
-
|
|
1155
|
+
/**
|
|
1156
|
+
* Props: the tool's values as flat props, plus a `values` escape hatch. Every prop is the tool's own, as in 0.1.22:
|
|
1157
|
+
* a `mobile` or `hideOnMobile` value isn't a device setting (`values._override` sets those).
|
|
1158
|
+
*/
|
|
1159
|
+
type ElementsToolProps = Omit<BaseItemComponentProps, keyof DeviceProps> & Record<string, any> & {
|
|
1100
1160
|
values?: Record<string, any>;
|
|
1101
1161
|
};
|
|
1102
1162
|
/**
|
|
@@ -1126,4 +1186,4 @@ declare function registerTool(tool: ElementsToolConfig): React__default.FC<Eleme
|
|
|
1126
1186
|
/** Alias of {@link registerTool}. */
|
|
1127
1187
|
declare const registerElementsTool: typeof registerTool;
|
|
1128
1188
|
|
|
1129
|
-
export { Body, type BorderInput, Button, type ButtonProps, Column, type ColumnLayout, ColumnLayouts, DEFAULT_CONFIG, type DesignBody, type DesignColumn, type DesignContent, type DesignJSON, type DesignRow, Divider, type DividerProps, Document, type DocumentProps, type ElementsToolConfig, type ElementsToolProps, Email, type EmailProps, type FontFamilyInput, type FontWeightInput, Heading, type HeadingLevel, type HeadingProps, type Href, Html, type HtmlParts, type HtmlProps, type Icons, Image, type ImageProps, type ImageSrcInput, type LinkStyle, Menu, type MenuItem, type MenuProps, Page, type PageProps, Paragraph, type ParagraphProps, type RenderToHtmlOptions, Row, type RowProps, type SizeInput, Social, type SocialIcon, type SocialProps, Table, type TableProps, type TextAlign, type TextStyleProps, type ToolExporter, type UnlayerConfig, UnlayerProvider, type UnlayerProviderProps, type ValidColumnLayout, Video, type VideoProps, type VideoSource, htmlToTextJson, registerElementsTool, registerTool, renderRowToJson, renderToHtml, renderToHtmlParts, renderToJson, renderToPlainText, useUnlayerConfig, validateColumnLayout };
|
|
1189
|
+
export { Body, type BorderInput, Button, type ButtonProps, Column, type ColumnLayout, ColumnLayouts, DEFAULT_CONFIG, type DesignBody, type DesignColumn, type DesignContent, type DesignJSON, type DesignRow, type DeviceProps, Divider, type DividerProps, Document, type DocumentOrientation, type DocumentPageSize, type DocumentProps, type ElementsToolConfig, type ElementsToolProps, Email, type EmailProps, type FontFamilyInput, type FontWeightInput, Heading, type HeadingLevel, type HeadingProps, type Href, Html, type HtmlParts, type HtmlProps, type Icons, Image, type ImageProps, type ImageSrcInput, type LinkStyle, Menu, type MenuItem, type MenuProps, type MobileProps, Page, PageBreak, type PageBreakProps, type PageProps, Paragraph, type ParagraphProps, type RenderToHtmlOptions, Row, type RowProps, type SizeInput, Social, type SocialIcon, type SocialProps, Table, type TableProps, type TextAlign, type TextStyleProps, type ToolExporter, type UnlayerConfig, UnlayerProvider, type UnlayerProviderProps, type ValidColumnLayout, Video, type VideoProps, type VideoSource, htmlToTextJson, registerElementsTool, registerTool, renderRowToJson, renderToHtml, renderToHtmlParts, renderToJson, renderToPlainText, useUnlayerConfig, validateColumnLayout };
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ import { MenuValues } from '@unlayer/types/tools/menu';
|
|
|
16
16
|
export { MenuValues } from '@unlayer/types/tools/menu';
|
|
17
17
|
import { ParagraphValues } from '@unlayer/types/tools/paragraph';
|
|
18
18
|
export { ParagraphValues } from '@unlayer/types/tools/paragraph';
|
|
19
|
+
import { PageBreakValues } from '@unlayer/types/tools/page-break';
|
|
20
|
+
export { PageBreakValues } from '@unlayer/types/tools/page-break';
|
|
19
21
|
import { SocialValues } from '@unlayer/types/tools/social';
|
|
20
22
|
export { SocialValues } from '@unlayer/types/tools/social';
|
|
21
23
|
import { TableValues } from '@unlayer/types/tools/table';
|
|
@@ -140,6 +142,24 @@ interface DesignJSON {
|
|
|
140
142
|
body: DesignBody;
|
|
141
143
|
schemaVersion: number;
|
|
142
144
|
}
|
|
145
|
+
/** Phone settings use the same flat CSS inputs as desktop props. */
|
|
146
|
+
interface MobileProps {
|
|
147
|
+
padding?: number | string;
|
|
148
|
+
containerPadding?: number | string;
|
|
149
|
+
fontSize?: number | string;
|
|
150
|
+
lineHeight?: number | string;
|
|
151
|
+
textAlign?: TextAlign;
|
|
152
|
+
width?: number | string;
|
|
153
|
+
maxWidth?: number | string;
|
|
154
|
+
autoWidth?: boolean;
|
|
155
|
+
/** Column border on this device (per side, as the desktop `border`). */
|
|
156
|
+
border?: Partial<Record<`border${"Top" | "Right" | "Bottom" | "Left"}${"Width" | "Style" | "Color"}`, number | string>>;
|
|
157
|
+
}
|
|
158
|
+
interface DeviceProps {
|
|
159
|
+
mobile?: MobileProps;
|
|
160
|
+
hideOnMobile?: boolean;
|
|
161
|
+
hideOnDesktop?: boolean;
|
|
162
|
+
}
|
|
143
163
|
|
|
144
164
|
interface HeadConfig {
|
|
145
165
|
hasFeature?: (featureName: string) => boolean;
|
|
@@ -222,6 +242,7 @@ declare function htmlToTextJson(html: string): string;
|
|
|
222
242
|
* - Users can pass: { color: "red", backgroundColor: "blue" } OR { buttonColors: { color: "red" } }
|
|
223
243
|
* - TypeScript provides autocomplete for ALL properties (flat and nested)
|
|
224
244
|
*/
|
|
245
|
+
|
|
225
246
|
/**
|
|
226
247
|
* Type utility: Extracts all properties from nested objects
|
|
227
248
|
* This provides TypeScript autocomplete for flat props!
|
|
@@ -235,7 +256,7 @@ type FlattenObjectProps<T> = T extends object ? {
|
|
|
235
256
|
* Semantic props type for any component.
|
|
236
257
|
* Generic TChildren parameter allows each framework to supply its own child type.
|
|
237
258
|
*/
|
|
238
|
-
type SemanticProps$1<T, TChildren = any> = FlattenObjectProps<T> & {
|
|
259
|
+
type SemanticProps$1<T, TChildren = any> = Omit<FlattenObjectProps<T>, keyof DeviceProps> & DeviceProps & {
|
|
239
260
|
children?: TChildren;
|
|
240
261
|
values?: T;
|
|
241
262
|
/** HTML string with inline formatting for Paragraph (e.g. `'Hello <b>bold</b>'`) */
|
|
@@ -305,7 +326,7 @@ type ImageSrcInput = string | {
|
|
|
305
326
|
/**
|
|
306
327
|
* Base props that all item components support
|
|
307
328
|
*/
|
|
308
|
-
interface BaseItemComponentProps {
|
|
329
|
+
interface BaseItemComponentProps extends DeviceProps {
|
|
309
330
|
children?: React__default.ReactNode;
|
|
310
331
|
className?: string;
|
|
311
332
|
style?: React__default.CSSProperties;
|
|
@@ -330,7 +351,7 @@ interface BaseItemComponentProps {
|
|
|
330
351
|
/**
|
|
331
352
|
* Props type that combines base props with semantic props
|
|
332
353
|
*/
|
|
333
|
-
type ItemComponentProps<TSemanticProps> = BaseItemComponentProps & TSemanticProps
|
|
354
|
+
type ItemComponentProps<TSemanticProps> = BaseItemComponentProps & Omit<TSemanticProps, keyof DeviceProps>;
|
|
334
355
|
|
|
335
356
|
/**
|
|
336
357
|
* React Semantic Props
|
|
@@ -592,6 +613,15 @@ interface ParagraphProps extends ItemComponentProps<ParagraphSemanticProps> {
|
|
|
592
613
|
*/
|
|
593
614
|
declare const Paragraph: React$1.FC<ItemComponentProps<ParagraphSemanticProps>>;
|
|
594
615
|
|
|
616
|
+
type PageBreakProps = ItemComponentProps<SemanticProps<PageBreakValues>>;
|
|
617
|
+
/**
|
|
618
|
+
* PageBreak - Forces subsequent document content onto a new PDF page.
|
|
619
|
+
*
|
|
620
|
+
* Page breaks render only in document mode. In email and web output they are
|
|
621
|
+
* intentionally inert.
|
|
622
|
+
*/
|
|
623
|
+
declare const PageBreak: React$1.FC<ItemComponentProps<SemanticProps<PageBreakValues>>>;
|
|
624
|
+
|
|
595
625
|
type SocialSemanticProps = Omit<SemanticProps<SocialValues>, "iconSize" | "spacing"> & {
|
|
596
626
|
/** Social icons shorthand (array of {name, url}) */
|
|
597
627
|
icons?: SocialIcon[];
|
|
@@ -694,7 +724,7 @@ interface VideoProps extends ItemComponentProps<SemanticProps<VideoValues>> {
|
|
|
694
724
|
*/
|
|
695
725
|
declare const Video: React$1.FC<ItemComponentProps<VideoSemanticProps>>;
|
|
696
726
|
|
|
697
|
-
type RowProps = Omit<SemanticProps<RowValues>, "padding"> & {
|
|
727
|
+
type RowProps = Omit<SemanticProps<RowValues>, "padding" | keyof DeviceProps> & DeviceProps & {
|
|
698
728
|
children?: React__default.ReactNode;
|
|
699
729
|
layout?: ColumnLayout;
|
|
700
730
|
cells?: number[];
|
|
@@ -711,7 +741,7 @@ type RowProps = Omit<SemanticProps<RowValues>, "padding"> & {
|
|
|
711
741
|
};
|
|
712
742
|
declare const Row: React__default.FC<RowProps>;
|
|
713
743
|
|
|
714
|
-
type ColumnProps = Omit<SemanticProps<ColumnValues>, "padding" | "border" | "borderRadius"> & {
|
|
744
|
+
type ColumnProps = Omit<SemanticProps<ColumnValues>, "padding" | "border" | "borderRadius" | keyof DeviceProps> & Omit<DeviceProps, "hideOnMobile" | "hideOnDesktop"> & {
|
|
715
745
|
children?: React__default.ReactNode;
|
|
716
746
|
index?: number;
|
|
717
747
|
cells?: number[];
|
|
@@ -742,6 +772,17 @@ type BodyProps = Omit<SemanticProps<BodyValues>, "padding" | "borderRadius"> & {
|
|
|
742
772
|
config?: Partial<UnlayerConfig>;
|
|
743
773
|
/** Preview text shown in email client inboxes (email mode only) */
|
|
744
774
|
previewText?: string;
|
|
775
|
+
/** Document text direction, also kept in the design JSON. Renderer options can override it. */
|
|
776
|
+
textDirection?: string;
|
|
777
|
+
/** Language of the rendered document (for example, "ar"). */
|
|
778
|
+
lang?: string;
|
|
779
|
+
/**
|
|
780
|
+
* Web font stylesheets the content uses (e.g. a Google Fonts CSS URL).
|
|
781
|
+
* renderToHtml links them in the document head, with any `fonts` option.
|
|
782
|
+
*/
|
|
783
|
+
fonts?: Array<{
|
|
784
|
+
url: string;
|
|
785
|
+
}>;
|
|
745
786
|
/** Padding — a CSS string ("0 48px", "20px") or a number (px). */
|
|
746
787
|
padding?: SizeInput;
|
|
747
788
|
/** Corner radius — a number (→ px) or CSS string ("8px"). */
|
|
@@ -806,7 +847,12 @@ declare namespace Page {
|
|
|
806
847
|
var displayName: string;
|
|
807
848
|
}
|
|
808
849
|
|
|
809
|
-
type
|
|
850
|
+
type DocumentPageSize = "A3" | "A4" | "A5" | "Legal" | "Letter" | "Tabloid";
|
|
851
|
+
type DocumentOrientation = "portrait" | "landscape";
|
|
852
|
+
type DocumentProps = Omit<BodyProps, "mode" | "documentSize" | "documentOrientation" | "documentMargin"> & {
|
|
853
|
+
documentSize?: DocumentPageSize;
|
|
854
|
+
documentOrientation?: DocumentOrientation;
|
|
855
|
+
};
|
|
810
856
|
/**
|
|
811
857
|
* Document - Print-optimized rendering for PDF generation.
|
|
812
858
|
*
|
|
@@ -814,7 +860,12 @@ type DocumentProps = Omit<BodyProps, "mode">;
|
|
|
814
860
|
*
|
|
815
861
|
* @example
|
|
816
862
|
* ```tsx
|
|
817
|
-
* <Document
|
|
863
|
+
* <Document
|
|
864
|
+
* backgroundColor="#ffffff"
|
|
865
|
+
* contentWidth="700px"
|
|
866
|
+
* documentSize="A4"
|
|
867
|
+
* documentOrientation="portrait"
|
|
868
|
+
* >
|
|
818
869
|
* <Row><Column><Paragraph text="Hello" /></Column></Row>
|
|
819
870
|
* </Document>
|
|
820
871
|
* ```
|
|
@@ -835,6 +886,8 @@ declare function useUnlayerConfig(): UnlayerConfig;
|
|
|
835
886
|
* Options for renderToHtml — config overrides plus document-level extras.
|
|
836
887
|
*/
|
|
837
888
|
interface RenderToHtmlOptions extends Partial<UnlayerConfig> {
|
|
889
|
+
/** Document language; overrides the root's `lang` prop. */
|
|
890
|
+
lang?: string;
|
|
838
891
|
/** Document `<title>` */
|
|
839
892
|
title?: string;
|
|
840
893
|
/**
|
|
@@ -859,7 +912,11 @@ interface RenderToHtmlOptions extends Partial<UnlayerConfig> {
|
|
|
859
912
|
* Use {@link renderToHtmlParts} instead when your app owns the document
|
|
860
913
|
* shell and only needs the head/body chunks.
|
|
861
914
|
*
|
|
862
|
-
* @param element - A React element tree (e.g. `<Email><Row>...</Row></Email>`)
|
|
915
|
+
* @param element - A React element tree (e.g. `<Email><Row>...</Row></Email>`), or a
|
|
916
|
+
* template component that returns one (`<Welcome name="Ada" />`, also `memo`/`forwardRef`).
|
|
917
|
+
* A template is called in a render of its own to reach its root (its hooks work); a class
|
|
918
|
+
* component, or one that doesn't return an element, renders without its root's settings,
|
|
919
|
+
* with a warning.
|
|
863
920
|
* @param options - Config overrides (mode, cdnBaseUrl, etc.) plus `title` and `fonts`
|
|
864
921
|
* @returns Complete HTML document string
|
|
865
922
|
* @throws {Error} If rendering fails, with a helpful message
|
|
@@ -1095,8 +1152,11 @@ interface ElementsToolConfig {
|
|
|
1095
1152
|
/** Editor-only fields (label, icon, options, validator, ...) — ignored */
|
|
1096
1153
|
[editorOnly: string]: unknown;
|
|
1097
1154
|
}
|
|
1098
|
-
/**
|
|
1099
|
-
|
|
1155
|
+
/**
|
|
1156
|
+
* Props: the tool's values as flat props, plus a `values` escape hatch. Every prop is the tool's own, as in 0.1.22:
|
|
1157
|
+
* a `mobile` or `hideOnMobile` value isn't a device setting (`values._override` sets those).
|
|
1158
|
+
*/
|
|
1159
|
+
type ElementsToolProps = Omit<BaseItemComponentProps, keyof DeviceProps> & Record<string, any> & {
|
|
1100
1160
|
values?: Record<string, any>;
|
|
1101
1161
|
};
|
|
1102
1162
|
/**
|
|
@@ -1126,4 +1186,4 @@ declare function registerTool(tool: ElementsToolConfig): React__default.FC<Eleme
|
|
|
1126
1186
|
/** Alias of {@link registerTool}. */
|
|
1127
1187
|
declare const registerElementsTool: typeof registerTool;
|
|
1128
1188
|
|
|
1129
|
-
export { Body, type BorderInput, Button, type ButtonProps, Column, type ColumnLayout, ColumnLayouts, DEFAULT_CONFIG, type DesignBody, type DesignColumn, type DesignContent, type DesignJSON, type DesignRow, Divider, type DividerProps, Document, type DocumentProps, type ElementsToolConfig, type ElementsToolProps, Email, type EmailProps, type FontFamilyInput, type FontWeightInput, Heading, type HeadingLevel, type HeadingProps, type Href, Html, type HtmlParts, type HtmlProps, type Icons, Image, type ImageProps, type ImageSrcInput, type LinkStyle, Menu, type MenuItem, type MenuProps, Page, type PageProps, Paragraph, type ParagraphProps, type RenderToHtmlOptions, Row, type RowProps, type SizeInput, Social, type SocialIcon, type SocialProps, Table, type TableProps, type TextAlign, type TextStyleProps, type ToolExporter, type UnlayerConfig, UnlayerProvider, type UnlayerProviderProps, type ValidColumnLayout, Video, type VideoProps, type VideoSource, htmlToTextJson, registerElementsTool, registerTool, renderRowToJson, renderToHtml, renderToHtmlParts, renderToJson, renderToPlainText, useUnlayerConfig, validateColumnLayout };
|
|
1189
|
+
export { Body, type BorderInput, Button, type ButtonProps, Column, type ColumnLayout, ColumnLayouts, DEFAULT_CONFIG, type DesignBody, type DesignColumn, type DesignContent, type DesignJSON, type DesignRow, type DeviceProps, Divider, type DividerProps, Document, type DocumentOrientation, type DocumentPageSize, type DocumentProps, type ElementsToolConfig, type ElementsToolProps, Email, type EmailProps, type FontFamilyInput, type FontWeightInput, Heading, type HeadingLevel, type HeadingProps, type Href, Html, type HtmlParts, type HtmlProps, type Icons, Image, type ImageProps, type ImageSrcInput, type LinkStyle, Menu, type MenuItem, type MenuProps, type MobileProps, Page, PageBreak, type PageBreakProps, type PageProps, Paragraph, type ParagraphProps, type RenderToHtmlOptions, Row, type RowProps, type SizeInput, Social, type SocialIcon, type SocialProps, Table, type TableProps, type TextAlign, type TextStyleProps, type ToolExporter, type UnlayerConfig, UnlayerProvider, type UnlayerProviderProps, type ValidColumnLayout, Video, type VideoProps, type VideoSource, htmlToTextJson, registerElementsTool, registerTool, renderRowToJson, renderToHtml, renderToHtmlParts, renderToJson, renderToPlainText, useUnlayerConfig, validateColumnLayout };
|