Giter VIP home page Giter VIP logo

dnde's Introduction



Drag and Drop E-mail Editor

release npm license

screens / live demo here

Installation

# Yarn
yarn add dnd-email-editor

# NPM
npm install dnd-email-editor

What's included

Props that can be passed to the component:

Prop Type Default Optional Description
preview boolean true true show/hide the inbuilt preview button.
showUndoRedo boolean true true show/hide the inbuilt undo/redo button.

You can create your own undoredo functionality with undoredo from api methods below

Editor exposes these api methods

  • getHtml - export the design as html content
  • getJson - export as json string, this string can then be used with loadJson
  • loadJson - load an existing design from json string
  • undoredo - undo and redo actions

Usage

  • Importing
import Editor from 'dnd-email-editor';

return <Editor />;
  • Setup a ref using useRef and pass it to editor
const ref = React.useRef(null);

return <Editor ref={ref} />;
  • Using getHtml(), getJson(), loadJson(), undoredo
const logValues = () => {
  if (ref.current) {
    const html = ref.current.getHtml();
    const json = ref.current.getJson();
    console.log(html, json);
  }
};

const loadJson = (json: string) => {
  if (ref.current) {
    ref.current.loadJson(json);
  }
};

const performUndoAction = () => {
  if (ref.current) {
    ref.current.undoActionCallback();

    // to check if undo is possible
    console.log('is undo empty: ', ref.current.isUndoEmpty());
  }
};

const performRedoAction = () => {
  if (ref.current) {
    ref.current.redoActionCallback();

    // to check if redo is possible
    console.log('is redo empty: ', ref.current.isRedoEmpty());
  }
};
  • Typescript

Inorder to use typescript and get cool definitions, just pass the type to the ref

import Editor from 'dnd-email-editor';

const ExampleComponent = () => {

- const ref = useRef(null);
+ const ref = useRef<Editor>(null);

  return (
    <Editor ref={ref}/>
  );

}

Purpose

There are soo many drag and drop editors that helps in creating website but not mails, because mails differ a lot from a normal html webpage

  • even if there are mail editors available, they are paid and not open-source.

One such example would be unlayer, It claims to be opensource but its not.

  • Looking at their source code, they only provide their loader-script and call it as open-source
  • later they ask you to pay for its features.

the above reasons and also I was inspired by drag-n-drop editors in general, so I decided to make one.

Features

  • Responsive and mobile friendly emails
  • Design emails by drag and drop
  • Import/Export designs
    • Export/Import as JSON
    • Export as HTML
  • Manage Fonts
    • add custom fonts
    • list / add/ deletefonts
  • Go back and forth with Undo / Redo
  • Preview the design in the browser (Mobile & PC)

Built with

Inspired by

dnde's People

Contributors

aghontpi avatar eswaramoorthykarthikeyan avatar fr0st1n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dnde's Issues

add operation got complex, refactor by seperating append, insert, copy operation...

// todo: add operation got complex, refactor by seperating append, insert, copy operations
if (!insert) {
// if tag name is mj-section, generate uniqueId for all mj-column tags
if (droppedConfig.tagName === 'mj-section') {
droppedConfig = generateUiqueIdForColumns(droppedConfig, uid);
}


This issue was generated by todo based on a todo comment in 8865202. It's been assigned to @aghontpi because they committed the code.

URL without protocol points to same domain

Linking a url using the popover dialog or using the sidebar to link href is not working as intended.

Possible sus line below

'<a href="' + link + '" target="_blank">' + document.getSelection() + '</a>'

fix all key realted errors

// todo: fix all key realted errors
if (element.classList.contains('mjml-tag')) {
// const ReactNode = React.createElement(nodeName, { key: ++counter, ...attributes }, children);
// return React.createElement(
// 'div',


This issue was generated by todo based on a todo comment in df285b9. It's been assigned to @aghontpi because they committed the code.

unable to set background image to the entire body

handling emails that has background image to the entire body - unable to handle mihoyo promotional email

Able to create the exact design but unable to

  • add background image to entire body of the email

ex: the following image is used as background image to the entire content. (open the image in new tab and check the height)

the image of the original promotional mail

promotional email image

the original mails source code in zip

mihoyo-promotional-mail.html.zip

Invalid HTML causes crash

Problem

Editing inside the html content without the table element causes crash.

Video

2021-10-25.11-38-20.mp4

check if changing directly to mjmlJson causes perfomance impact

//todo: check if changing directly to mjmlJson causes perfomance impact
// if so, then maintain a local state, then on change change the value first,
// then by using useeffect listen for the in localvalue, then update the mjmlJson.
const handleChange = useMemo(
() => (e: ChangeEvent<HTMLInputElement>) => {
let value = e.currentTarget.value;


This issue was generated by todo based on a todo comment in 59380b0. It's been assigned to @aghontpi because they committed the code.

optimize this

// todo: optimize this
const getValue = () => {
let value = '';
if (path && visible) {
let element = _.get(mjmlJson, path);
if (element && element.attributes) {


This issue was generated by todo based on a todo comment in 3db1701. It's been assigned to @aghontpi because they committed the code.

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.