2.0/email-builder
parent
ade510a701
commit
31b854efab
@ -0,0 +1,83 @@
|
||||
import { useEffect, useState, useMemo } from 'react'
|
||||
import EmailBuilder, {
|
||||
createYooptaEmailEditor,
|
||||
// type EmailTemplateOptions,
|
||||
} from '@yoopta/email-builder'
|
||||
|
||||
const templateOptions = {
|
||||
head: {
|
||||
styles: [
|
||||
{
|
||||
id: 'font',
|
||||
content: `body { font-family: Verdana, sans-serif; }`,
|
||||
},
|
||||
],
|
||||
meta: [
|
||||
{ content: 'width=device-width', name: 'viewport' },
|
||||
{ charset: 'UTF-8' },
|
||||
{ content: 'IE=edge', httpEquiv: 'X-UA-Compatible' },
|
||||
{ content: 'telephone=no,address=no,email=no,date=no,url=no', name: 'format-detection' },
|
||||
{ content: 'light', name: 'color-scheme' },
|
||||
],
|
||||
},
|
||||
body: {
|
||||
attrs: {
|
||||
style: {
|
||||
backgroundColor: '#fafafa',
|
||||
width: '900px',
|
||||
margin: '0 auto',
|
||||
},
|
||||
},
|
||||
},
|
||||
container: {
|
||||
attrs: {
|
||||
style: {
|
||||
width: 800,
|
||||
margin: '0 auto',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
function EmailBuilderC() {
|
||||
const editor = useMemo(() => createYooptaEmailEditor({ template: templateOptions }), [])
|
||||
const [value, setValue] = useState({})
|
||||
|
||||
const uploadImageToServer = async () => {}
|
||||
const uploadVideoToServer = async () => {}
|
||||
const uploadPosterToServer = async () => {}
|
||||
const uploadFileToServer = async () => {}
|
||||
|
||||
// media upload handlers
|
||||
const mediaUploaders = {
|
||||
image: {
|
||||
upload: async (file) => {
|
||||
const url = await uploadImageToServer(file)
|
||||
return url
|
||||
},
|
||||
},
|
||||
video: {
|
||||
upload: async (file) => {
|
||||
const url = await uploadVideoToServer(file)
|
||||
return url
|
||||
},
|
||||
uploadPoster: async (file) => {
|
||||
const url = await uploadPosterToServer(file)
|
||||
return url
|
||||
},
|
||||
},
|
||||
file: {
|
||||
upload: async (file) => {
|
||||
const url = await uploadFileToServer(file)
|
||||
return url
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='h-96'>
|
||||
<EmailBuilder view='editor' className='h-96' editor={editor} value={value} onChange={setValue} media={mediaUploaders} header={null} autoFocus={true} placeholder='Write your email here...' />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default EmailBuilderC
|
Loading…
Reference in New Issue