Giter VIP home page Giter VIP logo

mailui-editor-react's Introduction

React MailUi Editor

Enhance your app with MailUi user-friendly React.js wrapper component for designing emails. Enjoy it's easy drag-and-drop editor, making email creation a breeze!

React MailUi Editor

Table of contents

Live Demo

A minimal demo page can be found in example directory.

Getting started

Installation

Install it from npm and include it in your React build process

npm install react-mailui-editor --save

OR

yarn add react-mailui-editor

Usage

Require the MailUiEditor component and render it with JSX:

import React, {useRef} from 'react';
import MailUiEditor, {MailUiEditorRef, MailUiEditorProps} from 'react-mailui-editor';

const ExampleComponent = () => {
    const ref = useRef < MailUiEditorRef > (null);

    const exportHtml = () => {
        const mailui = ref.current?.editor;

        mailui?.exportHtml((data) => {
            const {design, html} = data;
            console.log('exportHtml', html);
        });
    };

    const onReady: MailUiEditorProps['onReady'] = (mailui) => {
        // Editor is ready
        // You can load your template here;
        // The design JSON can be obtained by calling mailui.loadDesign(callback) or mailui.exportHtml(callback)

        // For example:
        // const templateJson = { DESIGN JSON GOES HERE };
        // mailui.loadDesign(templateJson);
    };

    return (
        <div>
            <div>
                <button onClick={exportHtml}>Export HTML</button>
            </div>

            <EmailEditor ref={emailEditorRef} onReady={onReady}/>
        </div>
    );
};

export default ExampleComponent;

See the example source for a reference implementation.

Methods

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

method params description
loadDesign Object data Takes the design JSON and loads it in the editor
saveDesign Function callback Returns the design JSON in a callback function
exportHtml Function callback Returns 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 MailUi editor instance (default {})
  • style {Object} style object for the editor container (default {})

Browser support

MailUi supports all modern browsers. It is tested with the latest versions of Chrome, Edge, Safari, Firefox, and Opera.

The following browsers are supported out of the box in MailUi v0.0.1.beta:

  • Chrome ≥40
  • Edge ≥17
  • Safari ≥11.1
  • Firefox ≥44
  • Opera ≥27

Please be aware that the MailUi editor is currently not compatible with Internet Explorer, and there are no plans to add support for it in the future.

React

To use the latest version of MailUi editor, your project needs to use React 15.5 or later.

If you use an older version of React, please refer to the table below to a find suitable MailUi version.

React version Newest compatible MailUi version
≥15.5 latest

Localization

You can submit new language translations by creating a PR on this GitHub repo: https://github.com/MailUi/mailui-editor-translations. Translations managed by PhraseApp

License

Copyright (c) 2023 MailUi. MIT Licensed.

mailui-editor-react's People

Contributors

santushnath avatar

Watchers

 avatar Siful Islam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.