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
Not listening to hash changes (#47)
cohitrec215214c0417
diff --git a/packages/editor-sample/src/App/SamplesDrawer/SidebarButton.tsx b/packages/editor-sample/src/App/SamplesDrawer/SidebarButton.tsxindex 1e160f3..2d020d6 100644--- a/packages/editor-sample/src/App/SamplesDrawer/SidebarButton.tsx+++ b/packages/editor-sample/src/App/SamplesDrawer/SidebarButton.tsx@@ -2,9 +2,16 @@ import React from 'react';import { Button } from '@mui/material';+import { setEditorState } from '../../documents/editor/EditorContext';+import getConfiguration from '../../getConfiguration';+export default function SidebarButton({ href, children }: { href: string; children: JSX.Element | string }) {+ const handleClick = () => {+ const document = getConfiguration(href);+ setEditorState({ document });+ };return (- <Button size="small" href={href}>+ <Button size="small" href={href} onClick={handleClick}>{children}</Button>);diff --git a/packages/editor-sample/src/App/index.tsx b/packages/editor-sample/src/App/index.tsxindex 03fd89f..8944c6b 100644--- a/packages/editor-sample/src/App/index.tsx+++ b/packages/editor-sample/src/App/index.tsx@@ -1,9 +1,8 @@-import React, { useEffect } from 'react';+import React from 'react';import { Stack, useTheme } from '@mui/material';-import { setEditorState, useInspectorDrawerOpen, useSamplesDrawerOpen } from '../documents/editor/EditorContext';-import getConfiguration from '../getConfiguration';+import { useInspectorDrawerOpen, useSamplesDrawerOpen } from '../documents/editor/EditorContext';import InspectorDrawer, { INSPECTOR_DRAWER_WIDTH } from './InspectorDrawer';import SamplesDrawer, { SAMPLES_DRAWER_WIDTH } from './SamplesDrawer';@@ -14,15 +13,6 @@ export default function App() {const inspectorDrawerOpen = useInspectorDrawerOpen();const samplesDrawerOpen = useSamplesDrawerOpen();- useEffect(() => {- function refresh() {- setEditorState({ document: getConfiguration(window.location.hash) });- }- refresh();- window.addEventListener('hashchange', refresh);- return () => window.removeEventListener('hashchange', refresh);- });-return (<><InspectorDrawer />diff --git a/packages/editor-sample/src/documents/editor/EditorContext.tsx b/packages/editor-sample/src/documents/editor/EditorContext.tsxindex 1a11df6..99918f3 100644--- a/packages/editor-sample/src/documents/editor/EditorContext.tsx+++ b/packages/editor-sample/src/documents/editor/EditorContext.tsx@@ -1,6 +1,6 @@import { create } from 'zustand';-import EMPTY_EMAIL_MESSAGE from '../../getConfiguration/sample/empty-email-message';+import getConfiguration from '../../getConfiguration';import { TEditorConfiguration } from './core';@@ -16,7 +16,7 @@ type TValue = {};const useEditorState = create<TValue>(() => ({- document: EMPTY_EMAIL_MESSAGE,+ document: getConfiguration(window.location.hash),selectedBlockId: null,selectedSidebarTab: 'styles',selectedMainTab: 'editor',