zhugenmin / react-email-editor

Email Editor is a React component that allows users to create emails using a drag-and-drop interface.
23 stars 11 forks source link

Cannot drag anything into the email body #4

Open jpdelopes opened 7 months ago

jpdelopes commented 7 months ago

Hi,

I copied your example to my project and was able to show the email editor, but I can't add (drag and drop) anything to it. As you can see from the screenshot below, I was trying to drag Column to it, but nothing happens.

From your live demo (second image), when you try to drag and drop something to the email body, it shows a blue placeholder saying "Drag block here". In my case, that does not happen, not sure why. Essentially, I end up having a blank canvas and I cannot drag and drop any block/component to it, or at least, nothing happens.

image

image

Do you have an idea why this may be happening?

Thank you for your help, João

I'll leave my code below:

` import EmailEditor from "@editex/react-email-editor"; import React, { createElement, useEffect, useRef, useState } from "react";

export function Editor() {

const emailEditorRef = useRef(null);
const [emailData, setEmailData] = useState(null);

useEffect(() => {
    setTimeout(() => {
        setEmailData([]);
    }, 1000);
}, []);

const exportHtml = () => {
    const html = emailEditorRef.current.exportHtml();
    const blob = new Blob([html], { type: "text/html" });
    const a = document.createElement("a");
    a.download = "email.html";
    a.href = URL.createObjectURL(blob);
    a.click();
};

const showEmailData = () => {
    console.log(emailEditorRef.current.blockList);
};

return (
    <div class="page">
        <div className="page-header">
            <button onClick={exportHtml}>Export HTML</button>
            <button onClick={showEmailData}>Show email data</button>
        </div>
        <div className="page-content">{emailData ? <EmailEditor ref={emailEditorRef} defaultBlockList={emailData} /> : <>Loading....</>}</div>
    </div>
);`
Yazeed2 commented 2 months ago

I am facing the same issue. Did you find a solution?