A free and open-source block-based email template builder.
TypeScript amazonsesdeveloper-toolsemailemail-editoremail-marketingemail-templateemail-template-builderemailapiemailjshtml-email-editorno-codenocode-email-editoropen-source-email-buildersendgridtransactional-emailswysiwyg-email-editorwysiwyg-html-editor
Updating image-block defaults and setting up sidebar links. (#38)
cohitred93e31740021
diff --git a/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/helpers/inputs/TextAlignInput.tsx b/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/helpers/inputs/TextAlignInput.tsxindex 92e0939..4b4e241 100644--- a/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/helpers/inputs/TextAlignInput.tsx+++ b/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/input-panels/helpers/inputs/TextAlignInput.tsx@@ -19,7 +19,7 @@ export default function TextAlignInput({ label, defaultValue, onChange }: Props)defaultValue={value}onChange={(value) => {setValue(value);- onChange(value === 'left' ? null : value);+ onChange(value);}}><ToggleButton value="left">diff --git a/packages/editor-sample/src/App/InspectorDrawer/index.tsx b/packages/editor-sample/src/App/InspectorDrawer/index.tsxindex 508557f..144b93f 100644--- a/packages/editor-sample/src/App/InspectorDrawer/index.tsx+++ b/packages/editor-sample/src/App/InspectorDrawer/index.tsx@@ -39,7 +39,9 @@ export default function InspectorDrawer() {</Tabs></Box></Box>- <Box sx={{ height: 'calc(100% - 49px)', overflow: 'auto' }}>{renderCurrentSidebarPanel()}</Box>+ <Box sx={{ width: INSPECTOR_DRAWER_WIDTH, height: 'calc(100% - 49px)', overflow: 'auto' }}>+ {renderCurrentSidebarPanel()}+ </Box></Drawer>);}diff --git a/packages/editor-sample/src/App/SamplesDrawer/SidebarButton.tsx b/packages/editor-sample/src/App/SamplesDrawer/SidebarButton.tsxnew file mode 100644index 0000000..1e160f3--- /dev/null+++ b/packages/editor-sample/src/App/SamplesDrawer/SidebarButton.tsx@@ -0,0 +1,11 @@+import React from 'react';++import { Button } from '@mui/material';++export default function SidebarButton({ href, children }: { href: string; children: JSX.Element | string }) {+ return (+ <Button size="small" href={href}>+ {children}+ </Button>+ );+}diff --git a/packages/editor-sample/src/App/SamplesDrawer/index.tsx b/packages/editor-sample/src/App/SamplesDrawer/index.tsxindex 7f23a70..bd566f1 100644--- a/packages/editor-sample/src/App/SamplesDrawer/index.tsx+++ b/packages/editor-sample/src/App/SamplesDrawer/index.tsx@@ -4,6 +4,7 @@ import { Box, Button, Drawer, Link, Stack, Typography } from '@mui/material';import { useSamplesDrawerOpen } from '../../documents/editor/EditorContext';+import SidebarButton from './SidebarButton';import logo from './waypoint.svg';export const SAMPLES_DRAWER_WIDTH = 240;@@ -11,10 +12,6 @@ export const SAMPLES_DRAWER_WIDTH = 240;export default function SamplesDrawer() {const samplesDrawerOpen = useSamplesDrawerOpen();- const select = (val: string) => {- window.location.hash = `#sample/${val}`;- };-return (<Drawervariant="persistent"@@ -35,30 +32,14 @@ export default function SamplesDrawer() {EmailBuilder.js</Button><Stack alignItems="flex-start">- <Button size="small" onClick={() => select('empty')}>- Empty- </Button>- <Button size="small" onClick={() => select('one-time-password')}>- One-time passcode (OTP)- </Button>- <Button size="small" onClick={() => select('reset-password')}>- Reset password- </Button>- <Button size="small" onClick={() => select('order-ecomerce')}>- E-commerce receipt- </Button>- <Button size="small" onClick={() => select('subscription-receipt')}>- Subscription receipt- </Button>- <Button size="small" onClick={() => select('reservation-reminder')}>- Reservation reminder- </Button>- <Button size="small" onClick={() => select('post-metrics-report')}>- Post metrics- </Button>- <Button size="small" onClick={() => select('respond-to-message')}>- Respond to message- </Button>+ <SidebarButton href="#">Empty</SidebarButton>+ <SidebarButton href="#sample/one-time-password">One-time passcode (OTP)</SidebarButton>+ <SidebarButton href="#sample/reset-password">Reset password</SidebarButton>+ <SidebarButton href="#sample/order-ecomerce">E-commerce receipt</SidebarButton>+ <SidebarButton href="#sample/subscription-receipt">Subscription receipt</SidebarButton>+ <SidebarButton href="#sample/reservation-reminder">Reservation reminder</SidebarButton>+ <SidebarButton href="#sample/post-metrics-report">Post metrics</SidebarButton>+ <SidebarButton href="#sample/respond-to-message">Respond to message</SidebarButton></Stack></Stack><Stack spacing={2} px={0.75} py={3}>diff --git a/packages/editor-sample/src/App/TemplatePanel/HtmlPanel.tsx b/packages/editor-sample/src/App/TemplatePanel/HtmlPanel.tsxindex 41d4a81..4a5fd83 100644--- a/packages/editor-sample/src/App/TemplatePanel/HtmlPanel.tsx+++ b/packages/editor-sample/src/App/TemplatePanel/HtmlPanel.tsx@@ -5,6 +5,8 @@ import { useDocument } from '../../documents/editor/EditorContext';import ReaderBlock from '../../documents/reader/ReaderBlock';import { ReaderProvider } from '../../documents/reader/ReaderContext';+import TextEditorPanel from './helper/TextEditorPanel';+export default function HtmlPanel() {const document = useDocument();@@ -16,5 +18,5 @@ export default function HtmlPanel() {);}, [document]);- return <pre>{string}</pre>;+ return <TextEditorPanel value={string} />;}diff --git a/packages/editor-sample/src/App/TemplatePanel/JsonPanel.tsx b/packages/editor-sample/src/App/TemplatePanel/JsonPanel.tsxnew file mode 100644index 0000000..48ab291--- /dev/null+++ b/packages/editor-sample/src/App/TemplatePanel/JsonPanel.tsx@@ -0,0 +1,11 @@+import React, { useMemo } from 'react';++import { useEditorState } from '../../documents/editor/EditorContext';++import TextEditorPanel from './helper/TextEditorPanel';++export default function JsonPanel() {+ const [{ document }] = useEditorState();+ const string = useMemo(() => JSON.stringify(document, null, ' '), [document]);+ return <TextEditorPanel value={string} />;+}diff --git a/packages/editor-sample/src/App/TemplatePanel/ShareButton.tsx b/packages/editor-sample/src/App/TemplatePanel/ShareButton.tsxindex d68e2e4..b64d79b 100644--- a/packages/editor-sample/src/App/TemplatePanel/ShareButton.tsx+++ b/packages/editor-sample/src/App/TemplatePanel/ShareButton.tsx@@ -11,7 +11,6 @@ export default function ShareButton() {const onClick = async () => {const c = JSON.stringify(document);- localStorage.setItem('configuration', c);location.hash = `#${btoa(c)}`;if (navigator.clipboard) {await navigator.clipboard.writeText(location.href.toString());diff --git a/packages/editor-sample/src/App/TemplatePanel/helper/TextEditorPanel.tsx b/packages/editor-sample/src/App/TemplatePanel/helper/TextEditorPanel.tsxnew file mode 100644index 0000000..d19b43d--- /dev/null+++ b/packages/editor-sample/src/App/TemplatePanel/helper/TextEditorPanel.tsx@@ -0,0 +1,22 @@+import * as React from 'react';++type TextEditorPanelProps = {+ value: string;+};+export default function TextEditorPanel({ value }: TextEditorPanelProps) {+ return (+ <textarea+ style={{+ padding: 16,+ resize: 'none',+ borderWidth: 0,+ height: '100%',+ width: '100%',+ outline: 0,+ boxSizing: 'border-box',+ }}+ >+ {value}+ </textarea>+ );+}diff --git a/packages/editor-sample/src/App/TemplatePanel/index.tsx b/packages/editor-sample/src/App/TemplatePanel/index.tsxindex a1596ef..4ad9c9a 100644--- a/packages/editor-sample/src/App/TemplatePanel/index.tsx+++ b/packages/editor-sample/src/App/TemplatePanel/index.tsx@@ -11,6 +11,7 @@ import ToggleInspectorPanelButton from '../InspectorDrawer/ToggleInspectorPanelBimport ToggleSamplesPanelButton from '../SamplesDrawer/ToggleSamplesPanelButton';import HtmlPanel from './HtmlPanel';+import JsonPanel from './JsonPanel';import ShareButton from './ShareButton';export default function TemplatePanel() {@@ -30,11 +31,7 @@ export default function TemplatePanel() {case 'html':return <HtmlPanel />;case 'data':- return (- <Box p={3}>- <pre>{JSON.stringify(document, null, ' ')}</pre>- </Box>- );+ return <JsonPanel />;}};@@ -97,7 +94,7 @@ export default function TemplatePanel() {<ToggleInspectorPanelButton /></Stack>- <Box sx={{ height: 'calc(100% - 49px)', overflow: 'auto', minWidth: 370 }}>{renderMainPanel()}</Box>+ <Box sx={{ height: 'calc(100vh - 49px)', overflow: 'auto', minWidth: 370 }}>{renderMainPanel()}</Box></>);}diff --git a/packages/editor-sample/src/documents/blocks/helpers/EditorChildrenIds/AddBlockMenu/buttons.tsx b/packages/editor-sample/src/documents/blocks/helpers/EditorChildrenIds/AddBlockMenu/buttons.tsxindex 23ffa4a..b0667d5 100644--- a/packages/editor-sample/src/documents/blocks/helpers/EditorChildrenIds/AddBlockMenu/buttons.tsx+++ b/packages/editor-sample/src/documents/blocks/helpers/EditorChildrenIds/AddBlockMenu/buttons.tsx@@ -14,7 +14,6 @@ import {} from '@mui/icons-material';import { TEditorBlock } from '../../../../editor/core';-import ColumnsContainerPropsSchema from '../../../ColumnsContainer/ColumnsContainerPropsSchema';type TButtonProps = {label: string;@@ -42,6 +41,10 @@ export const BUTTONS: TButtonProps[] = [type: 'Text',data: {props: { text: 'My new text block' },+ style: {+ padding: { top: 16, bottom: 16, left: 24, right: 24 },+ fontWeight: 'normal',+ },},}),},@@ -56,6 +59,7 @@ export const BUTTONS: TButtonProps[] = [text: 'Button',url: 'https://www.usewaypoint.com',},+ style: { padding: { top: 16, bottom: 16, left: 24, right: 24 } },},}),},@@ -71,6 +75,7 @@ export const BUTTONS: TButtonProps[] = [contentAlignment: 'middle',linkHref: null,},+ style: { padding: { top: 16, bottom: 16, left: 24, right: 24 } },},}),},@@ -84,6 +89,7 @@ export const BUTTONS: TButtonProps[] = [imageUrl: 'https://ui-avatars.com/api/?size=128',shape: 'circle',},+ style: { padding: { top: 16, bottom: 16, left: 24, right: 24 } },},}),},@@ -93,9 +99,7 @@ export const BUTTONS: TButtonProps[] = [block: () => ({type: 'Divider',data: {- style: {- padding: { top: 16, right: 0, bottom: 16, left: 0 },- },+ style: { padding: { top: 16, right: 0, bottom: 16, left: 0 } },props: {lineColor: '#CCCCCC',},@@ -107,7 +111,7 @@ export const BUTTONS: TButtonProps[] = [icon: <Crop32Outlined />,block: () => ({type: 'Spacer',- data: { style: {}, props: {} },+ data: {},}),},{@@ -117,6 +121,11 @@ export const BUTTONS: TButtonProps[] = [type: 'Html',data: {props: { contents: 'Hello world' },+ style: {+ fontSize: 16,+ textAlign: null,+ padding: { top: 16, bottom: 16, left: 24, right: 24 },+ },},}),},@@ -125,12 +134,14 @@ export const BUTTONS: TButtonProps[] = [icon: <ViewColumnOutlined />,block: () => ({type: 'ColumnsContainer',- data: ColumnsContainerPropsSchema.parse({+ data: {props: {+ columnsGap: 16,columnsCount: 3,columns: [{ childrenIds: [] }, { childrenIds: [] }, { childrenIds: [] }],},- }),+ style: { padding: { top: 16, bottom: 16, left: 24, right: 24 } },+ },}),},{@@ -138,7 +149,9 @@ export const BUTTONS: TButtonProps[] = [icon: <LibraryAddOutlined />,block: () => ({type: 'Container',- data: {},+ data: {+ style: { padding: { top: 16, bottom: 16, left: 24, right: 24 } },+ },}),},diff --git a/packages/editor-sample/src/documents/blocks/helpers/block-wrappers/EditorBlockWrapper.tsx b/packages/editor-sample/src/documents/blocks/helpers/block-wrappers/EditorBlockWrapper.tsxindex 7564f8c..0678095 100644--- a/packages/editor-sample/src/documents/blocks/helpers/block-wrappers/EditorBlockWrapper.tsx+++ b/packages/editor-sample/src/documents/blocks/helpers/block-wrappers/EditorBlockWrapper.tsx@@ -42,12 +42,12 @@ export default function EditorBlockWrapper({ children }: TEditorBlockWrapperPropsetMouseInside(true);ev.stopPropagation();}}- onMouseLeave={(ev) => {+ onMouseLeave={() => {setMouseInside(false);- ev.stopPropagation();}}onClick={(ev) => {setEditorState({+ inspectorDrawerOpen: true,selectedSidebarTab: 'block-configuration',selectedBlockId: blockId,});diff --git a/packages/editor-sample/src/getConfiguration/index.tsx b/packages/editor-sample/src/getConfiguration/index.tsxindex d6aea4d..1a7d69f 100644--- a/packages/editor-sample/src/getConfiguration/index.tsx+++ b/packages/editor-sample/src/getConfiguration/index.tsx@@ -38,14 +38,5 @@ export default function getConfiguration(template: string) {}}- const configurationString = localStorage.getItem('configuration');- if (typeof configurationString === 'string') {- try {- return JSON.parse(configurationString);- } catch {- console.error(`Couldn't load configuration from localStorage.`);- }- }-return EMPTY_EMAIL_MESSAGE;}diff --git a/packages/editor-sample/src/getConfiguration/sample/one-time-passcode.ts b/packages/editor-sample/src/getConfiguration/sample/one-time-passcode.tsindex 43bbd98..190e5c0 100644--- a/packages/editor-sample/src/getConfiguration/sample/one-time-passcode.ts+++ b/packages/editor-sample/src/getConfiguration/sample/one-time-passcode.ts@@ -31,9 +31,8 @@ const ONE_TIME_PASSCODE: TEditorConfiguration = {textAlign: 'center',},props: {+ height: 24,url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_jc7ZfPvdHJ6rtH1W/&.png',- alt: '',- linkHref: null,contentAlignment: 'middle',},},diff --git a/packages/editor-sample/src/getConfiguration/sample/order-ecommerce.ts b/packages/editor-sample/src/getConfiguration/sample/order-ecommerce.tsindex 3de91e0..d3e228b 100644--- a/packages/editor-sample/src/getConfiguration/sample/order-ecommerce.ts+++ b/packages/editor-sample/src/getConfiguration/sample/order-ecommerce.ts@@ -350,27 +350,6 @@ const ORDER_ECOMMERCE: TEditorConfiguration = {},},},- block_JbZJ8FqT6GxQ4i6wEiWztp: {- type: 'Image',- data: {- style: {- backgroundColor: null,- padding: {- top: 0,- bottom: 0,- left: 0,- right: 0,- },- textAlign: 'left',- },- props: {- url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_vjmjV2NrQ52h1iLj/coupon.png',- alt: '',- linkHref: null,- contentAlignment: 'middle',- },- },- },block_92JgagxxVxzyfnbvj5iUUJ: {type: 'Container',data: {@@ -386,7 +365,7 @@ const ORDER_ECOMMERCE: TEditorConfiguration = {},},props: {- childrenIds: ['block_JbZJ8FqT6GxQ4i6wEiWztp'],+ childrenIds: [],},},},@@ -412,25 +391,6 @@ const ORDER_ECOMMERCE: TEditorConfiguration = {},},},- block_TdFvCzpv5j9SZgktRbSTwu: {- type: 'Container',- data: {- style: {- backgroundColor: null,- borderColor: null,- borderRadius: null,- padding: {- top: 0,- bottom: 0,- left: 0,- right: 0,- },- },- props: {- childrenIds: ['block_9bNBgfiJJyh65pfsy1fu7e'],- },- },- },block_7JwR5SHM2Bfjihamh45tRL: {type: 'Container',data: {@@ -450,34 +410,6 @@ const ORDER_ECOMMERCE: TEditorConfiguration = {},},},- block_S8F4TkiuTVLF2GTQn67eGY: {- type: 'ColumnsContainer',- data: {- style: {- backgroundColor: null,- padding: {- top: 0,- bottom: 0,- left: 0,- right: 0,- },- },- props: {- columnsCount: 2,- columns: [- {- childrenIds: ['block_92JgagxxVxzyfnbvj5iUUJ'],- },- {- childrenIds: ['block_TdFvCzpv5j9SZgktRbSTwu'],- },- {- childrenIds: ['block_7JwR5SHM2Bfjihamh45tRL'],- },- ],- },- },- },block_GQ77o7MDMwj48B5nocEJNq: {type: 'Container',data: {@@ -493,7 +425,7 @@ const ORDER_ECOMMERCE: TEditorConfiguration = {},},props: {- childrenIds: ['block_TBZZDHvoKHcW3j2nwQgmhC', 'block_KqpmZUcZajsnFMbTMhizZs', 'block_S8F4TkiuTVLF2GTQn67eGY'],+ childrenIds: ['block_TBZZDHvoKHcW3j2nwQgmhC', 'block_KqpmZUcZajsnFMbTMhizZs'],},},},@@ -568,12 +500,13 @@ const ORDER_ECOMMERCE: TEditorConfiguration = {padding: {top: 16,bottom: 16,- left: 0,right: 0,+ left: 0,},},props: {columnsCount: 3,+ columnsGap: 16,columns: [{childrenIds: ['block_4sAeV4cLVKV8y4QFGV3Gf7'],diff --git a/packages/editor-sample/src/getConfiguration/sample/post-metrics-report.ts b/packages/editor-sample/src/getConfiguration/sample/post-metrics-report.tsindex 8417782..9e49e1b 100644--- a/packages/editor-sample/src/getConfiguration/sample/post-metrics-report.ts+++ b/packages/editor-sample/src/getConfiguration/sample/post-metrics-report.ts@@ -36,9 +36,8 @@ const POST_METRICS_REPORT: TEditorConfiguration = {textAlign: 'left',},props: {+ height: 16,url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_n3eLjsf37dcjFaj5/Narrative.png',- alt: '',- linkHref: null,contentAlignment: 'middle',},},diff --git a/packages/editor-sample/src/getConfiguration/sample/reservation-reminder.ts b/packages/editor-sample/src/getConfiguration/sample/reservation-reminder.tsindex e40818a..d09b8be 100644--- a/packages/editor-sample/src/getConfiguration/sample/reservation-reminder.ts+++ b/packages/editor-sample/src/getConfiguration/sample/reservation-reminder.ts@@ -42,9 +42,8 @@ const RESERVATION_REMINDER: TEditorConfiguration = {textAlign: 'left',},props: {+ height: 32,url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_RAFATLGe3CN1wDsb/birdhouse.png',- alt: '',- linkHref: null,contentAlignment: 'middle',},},@@ -108,7 +107,7 @@ const RESERVATION_REMINDER: TEditorConfiguration = {props: {size: 64,shape: 'circle',- imageUrl: '',+ imageUrl: 'https://ui-avatars.com/api/?size=128&name=Elaina',alt: 'Elaina',},},diff --git a/packages/editor-sample/src/getConfiguration/sample/reset-password.ts b/packages/editor-sample/src/getConfiguration/sample/reset-password.tsindex 36bbfbb..a2bed94 100644--- a/packages/editor-sample/src/getConfiguration/sample/reset-password.ts+++ b/packages/editor-sample/src/getConfiguration/sample/reset-password.ts@@ -32,6 +32,7 @@ const RESET_PASSWORD: TEditorConfiguration = {textAlign: 'left',},props: {+ height: 40,url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_w9brVHZobEBhsJSK/marketbase.png',alt: '',linkHref: null,diff --git a/packages/editor-sample/src/getConfiguration/sample/respond-to-message.ts b/packages/editor-sample/src/getConfiguration/sample/respond-to-message.tsindex 7d4ca33..7b554af 100644--- a/packages/editor-sample/src/getConfiguration/sample/respond-to-message.ts+++ b/packages/editor-sample/src/getConfiguration/sample/respond-to-message.ts@@ -22,19 +22,16 @@ const RESPOND_TO_MESSAGE: TEditorConfiguration = {type: 'Image',data: {style: {- backgroundColor: null,padding: {top: 8,bottom: 24,left: 24,right: 24,},- textAlign: null,},props: {+ height: 32,url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_hW6RusynHUNTKoLm/boop.png',- alt: '',- linkHref: null,contentAlignment: 'middle',},},diff --git a/packages/editor-sample/src/getConfiguration/sample/subscription-receipt.ts b/packages/editor-sample/src/getConfiguration/sample/subscription-receipt.tsindex f54bb62..9755c77 100644--- a/packages/editor-sample/src/getConfiguration/sample/subscription-receipt.ts+++ b/packages/editor-sample/src/getConfiguration/sample/subscription-receipt.ts@@ -31,6 +31,7 @@ const SUBSCRIPTION_RECEIPT: TEditorConfiguration = {textAlign: 'left',},props: {+ height: 18,url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_9TcdHLq5SpEkRADB/REMIX.png',alt: 'Remix',linkHref: 'https://remix.example.com',@@ -292,7 +293,7 @@ const SUBSCRIPTION_RECEIPT: TEditorConfiguration = {left: 0,right: 0,},- textAlign: 'left',+ textAlign: 'right',},props: {url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_8yUGBZcXaAtTEofB/invoice-skeleton.png',diff --git a/packages/editor-sample/src/main.tsx b/packages/editor-sample/src/main.tsxindex e17649e..c9060ee 100644--- a/packages/editor-sample/src/main.tsx+++ b/packages/editor-sample/src/main.tsx@@ -1,8 +1,7 @@import React from 'react';import ReactDOM from 'react-dom/client';-import CssBaseline from '@mui/material/CssBaseline';-import { ThemeProvider } from '@mui/material/styles';+import { CssBaseline, ThemeProvider } from '@mui/material';import App from './App';import theme from './theme';