diff --git a/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/EmailLayoutSidebarPanel.tsx b/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/EmailLayoutSidebarPanel.tsx index 9293a0e0..3c33fe5d 100644 --- a/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/EmailLayoutSidebarPanel.tsx +++ b/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/EmailLayoutSidebarPanel.tsx @@ -10,6 +10,7 @@ import BaseSidebarPanel from './helpers/BaseSidebarPanel'; import ColorInput, { NullableColorInput } from './helpers/inputs/ColorInput'; import { NullableFontFamily } from './helpers/inputs/FontFamily'; import SliderInput from './helpers/inputs/SliderInput'; +import TextInput from './helpers/inputs/TextInput'; type EmailLayoutSidebarFieldsProps = { data: EmailLayoutProps; @@ -66,6 +67,12 @@ export default function EmailLayoutSidebarFields({ data, setData }: EmailLayoutS defaultValue={data.textColor ?? '#262626'} onChange={(textColor) => updateData({ ...data, textColor })} /> + updateData({ ...data, previewText })} + /> ); } diff --git a/packages/editor-sample/src/documents/blocks/EmailLayout/EmailLayoutEditor.tsx b/packages/editor-sample/src/documents/blocks/EmailLayout/EmailLayoutEditor.tsx index 0b5002d1..9001049f 100644 --- a/packages/editor-sample/src/documents/blocks/EmailLayout/EmailLayoutEditor.tsx +++ b/packages/editor-sample/src/documents/blocks/EmailLayout/EmailLayoutEditor.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Fragment } from 'react'; import { useCurrentBlockId } from '../../editor/EditorBlock'; import { setDocument, setSelectedBlockId, useDocument } from '../../editor/EditorContext'; @@ -36,68 +36,78 @@ export default function EmailLayoutEditor(props: EmailLayoutProps) { const currentBlockId = useCurrentBlockId(); return ( -
{ - setSelectedBlockId(null); - }} - style={{ - backgroundColor: props.backdropColor ?? '#F5F5F5', - color: props.textColor ?? '#262626', - fontFamily: getFontFamily(props.fontFamily), - fontSize: '16px', - fontWeight: '400', - letterSpacing: '0.15008px', - lineHeight: '1.5', - margin: '0', - padding: '32px 0', - width: '100%', - minHeight: '100%', - }} - > - + {props.previewText && ( +
+ {props.previewText} +  ‌ Ì ‌  +
+ )} +
{ + setSelectedBlockId(null); + }} style={{ - margin: '0 auto', - maxWidth: '600px', - backgroundColor: props.canvasColor ?? '#FFFFFF', - borderRadius: props.borderRadius ?? undefined, - border: (() => { - const v = props.borderColor; - if (!v) { - return undefined; - } - return `1px solid ${v}`; - })(), + backgroundColor: props.backdropColor ?? '#F5F5F5', + color: props.textColor ?? '#262626', + fontFamily: getFontFamily(props.fontFamily), + fontSize: '16px', + fontWeight: '400', + letterSpacing: '0.15008px', + lineHeight: '1.5', + margin: '0', + padding: '32px 0', + width: '100%', + minHeight: '100%', }} - role="presentation" - cellSpacing="0" - cellPadding="0" - border={0} > -
- - + + +
- { - setDocument({ - [blockId]: block, - [currentBlockId]: { - type: 'EmailLayout', - data: { - ...document[currentBlockId].data, - childrenIds: childrenIds, + { + const v = props.borderColor; + if (!v) { + return undefined; + } + return `1px solid ${v}`; + })(), + }} + role="presentation" + cellSpacing="0" + cellPadding="0" + border={0} + > + + + - - -
+ { + setDocument({ + [blockId]: block, + [currentBlockId]: { + type: 'EmailLayout', + data: { + ...document[currentBlockId].data, + childrenIds: childrenIds, + }, }, - }, - }); - setSelectedBlockId(blockId); - }} - /> -
- + }); + setSelectedBlockId(blockId); + }} + /> +
+
+ ); } diff --git a/packages/editor-sample/src/documents/blocks/EmailLayout/EmailLayoutPropsSchema.tsx b/packages/editor-sample/src/documents/blocks/EmailLayout/EmailLayoutPropsSchema.tsx index 880f3ae8..642cf5fe 100644 --- a/packages/editor-sample/src/documents/blocks/EmailLayout/EmailLayoutPropsSchema.tsx +++ b/packages/editor-sample/src/documents/blocks/EmailLayout/EmailLayoutPropsSchema.tsx @@ -29,6 +29,7 @@ const EmailLayoutPropsSchema = z.object({ textColor: COLOR_SCHEMA, fontFamily: FONT_FAMILY_SCHEMA, childrenIds: z.array(z.string()).optional().nullable(), + previewText: z.string().optional().nullable(), }); export default EmailLayoutPropsSchema; diff --git a/packages/email-builder/src/blocks/EmailLayout/EmailLayoutPropsSchema.tsx b/packages/email-builder/src/blocks/EmailLayout/EmailLayoutPropsSchema.tsx index 439b6ba8..25154237 100644 --- a/packages/email-builder/src/blocks/EmailLayout/EmailLayoutPropsSchema.tsx +++ b/packages/email-builder/src/blocks/EmailLayout/EmailLayoutPropsSchema.tsx @@ -28,6 +28,7 @@ export const EmailLayoutPropsSchema = z.object({ canvasColor: COLOR_SCHEMA, textColor: COLOR_SCHEMA, fontFamily: FONT_FAMILY_SCHEMA, + previewText: z.string().optional().nullable(), childrenIds: z.array(z.string()).optional().nullable(), }); diff --git a/packages/email-builder/src/blocks/EmailLayout/EmailLayoutReader.tsx b/packages/email-builder/src/blocks/EmailLayout/EmailLayoutReader.tsx index f9f356cf..25d56491 100644 --- a/packages/email-builder/src/blocks/EmailLayout/EmailLayoutReader.tsx +++ b/packages/email-builder/src/blocks/EmailLayout/EmailLayoutReader.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Fragment } from 'react'; import { ReaderBlock } from '../../Reader/core'; @@ -38,46 +38,56 @@ function getBorder({ borderColor }: EmailLayoutProps) { export default function EmailLayoutReader(props: EmailLayoutProps) { const childrenIds = props.childrenIds ?? []; return ( -
- + {props.previewText && ( +
+ {props.previewText} +  ‌ ‌ ‌  +
+ )} +
-
- - - - -
- {childrenIds.map((childId) => ( - - ))} -
-
+ + + + + + +
+ {childrenIds.map((childId) => ( + + ))} +
+ + ); }