Installation and Usage
This page will help you install and run the email editor.
import React, { useState, useCallback, useRef } from "react";
import EmailEditor from "raven-react-email-editor";
const myStyle = {
div: {
height: "100vh",
},
nav: {
height: "8%",
borderBottom: "1px solid #a39f9f",
},
button: {
float: "right",
margin: "10px 20px 10px 10px",
padding: "10px 40px",
color: "white",
border: "1px solid rgba(88, 80, 236, 0.5)",
fontSize: "0.875rem",
backgroundColor: "#5850EC",
borderRadius: "4px",
cursor: "pointer",
},
editor: {
height: "91.9%",
},
};
function App() {
const [savedState, setSavedState] = useState({ state: "", html: "" });
const [isLoaded, setIsLoaded] = useState(false);
const editorRef = useRef(null);
const onLoad = () => {
setIsLoaded(true);
};
const onFetched = useCallback((state, html) => {
setSavedState((prevState) => ({
...prevState,
state: state,
html: html,
}));
setIsLoaded(true);
}, []);
const onEditorSave = useCallback(() => {
if (isLoaded) {
setIsLoaded(false);
editorRef.current.fetchState();
}
}, [isLoaded]);
return (
<div style={myStyle.div}>
<nav style={myStyle.nav}>
<button onClick={onEditorSave} style={myStyle.button}>
SAVE
</button>
</nav>
<div style={myStyle.editor}>
<EmailEditor
state={savedState.state}
onEditorLoad={onLoad}
onFetched={onFetched}
ref={editorRef}
//editorHostUrl={add your email editor's url}
/>
</div>
</div>
);
}
export default App;Props
Description
Last updated