Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Drag-n-Drop Email Editor Component for React.js

License

NotificationsYou must be signed in to change notification settings

unlayer/react-email-editor

Repository files navigation

The excellent drag-n-drop email editor byUnlayer as aReact.jswrapper component. This is the most powerful and developer friendly visual email builder for your app.

Video Overview
React Email Editor
Watch video overview:https://youtu.be/MIWhX-NF3j8

Live Demo

Check out the live demo here:https://react-email-editor-demo.netlify.app/ (Source Code)

Blog Post

Here's a blog post with a quickstart guide:https://medium.com/unlayer-blog/creating-a-drag-n-drop-email-editor-with-react-db1e9eb42386

Installation

The easiest way to use React Email Editor is to install it from NPM and include it in your own React build process.

npm install react-email-editor --save

Usage

Require the EmailEditor component and render it with JSX:

importReact,{useRef}from'react';import{render}from'react-dom';importEmailEditor,{EditorRef,EmailEditorProps}from'react-email-editor';constApp=(props)=>{constemailEditorRef=useRef<EditorRef>(null);constexportHtml=()=>{constunlayer=emailEditorRef.current?.editor;unlayer?.exportHtml((data)=>{const{ design, html}=data;console.log('exportHtml',html);});};constonReady:EmailEditorProps['onReady']=(unlayer)=>{// editor is ready// you can load your template here;// the design json can be obtained by calling// unlayer.loadDesign(callback) or unlayer.exportHtml(callback)// const templateJson = { DESIGN JSON GOES HERE };// unlayer.loadDesign(templateJson);};return(<div><div><buttononClick={exportHtml}>Export HTML</button></div><EmailEditorref={emailEditorRef}onReady={onReady}/></div>);};render(<App/>,document.getElementById('app'));

See theexample source for a reference implementation.

Methods

All unlayer methods are available in the editor instance (emailEditorRef.current.editor). See theUnlayer Docs for more information, or log the object in the console to explore it. Here are the most used ones:

methodparamsdescription
loadDesignObject dataTakes the design JSON and loads it in the editor
saveDesignFunction callbackReturns the design JSON in a callback function
exportHtmlFunction callbackReturns the design HTML and JSON in a callback function

Properties

  • editorId {String} HTML div id of the container where the editor will be embedded (optional)
  • minHeight {String} minimum height to initialize the editor with (default 500px)
  • onLoad {Function} called when the editor instance is created
  • onReady {Function} called when the editor has finished loading
  • options {Object} options passed to the Unlayer editor instance (default {})
  • style {Object} style object for the editor container (default {})

Custom Tools

Custom tools can help you add your own content blocks to the editor. Every application is different and needs different tools to reach it's full potential.Learn More

Custom Tools

Localization

You can submit new language translations by creating a PR on this GitHub repo:https://github.com/unlayer/translations. Translations managed byPhraseApp

License

Copyright (c) 2024 Unlayer.MIT Licensed.


[8]ページ先頭

©2009-2025 Movatter.jp