-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
81 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 2 additions & 15 deletions
17
packages/editor-sample/src/App/TemplatePanel/HtmlPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,13 @@ | ||
import React, { useMemo } from 'react'; | ||
import { renderToStaticMarkup } from 'react-dom/server'; | ||
|
||
import Reader from '@usewaypoint/email-builder/dist/Reader/core'; | ||
import { renderToStaticMarkup } from '@usewaypoint/email-builder'; | ||
|
||
import { useDocument } from '../../documents/editor/EditorContext'; | ||
|
||
import HighlightedCodePanel from './helper/HighlightedCodePanel'; | ||
|
||
export default function HtmlPanel() { | ||
const document = useDocument(); | ||
const code = useMemo(() => { | ||
return ( | ||
'<!DOCTYPE html>' + | ||
renderToStaticMarkup( | ||
<html> | ||
<body> | ||
<Reader document={document} rootBlockId="root" /> | ||
</body> | ||
</html> | ||
) | ||
); | ||
}, [document]); | ||
|
||
const code = useMemo(() => renderToStaticMarkup(document, { rootBlockId: 'root' }), [document]); | ||
return <HighlightedCodePanel type="html" value={code} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export { default as renderToStaticMarkup } from './renderers/renderToStaticMarkup'; | ||
|
||
export { | ||
ReaderBlockSchema, | ||
TReaderBlock, | ||
// | ||
ReaderDocumentSchema, | ||
TReaderDocument, | ||
// | ||
ReaderBlock, | ||
TReaderBlockProps, | ||
// | ||
TReaderProps, | ||
default as Reader, | ||
} from './Reader/core'; |
20 changes: 20 additions & 0 deletions
20
packages/email-builder/src/renderers/renderToStaticMarkup.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import { renderToStaticMarkup as baseRenderToStaticMarkup } from 'react-dom/server'; | ||
|
||
import Reader, { TReaderDocument } from '../Reader/core'; | ||
|
||
type TOptions = { | ||
rootBlockId: string; | ||
}; | ||
export default function renderToStaticMarkup(document: TReaderDocument, { rootBlockId }: TOptions) { | ||
return ( | ||
'<!DOCTYPE html>' + | ||
baseRenderToStaticMarkup( | ||
<html> | ||
<body> | ||
<Reader document={document} rootBlockId={rootBlockId} /> | ||
</body> | ||
</html> | ||
) | ||
); | ||
} |