Giter Site home page Giter Site logo

Comments (3)

carylgaskell avatar carylgaskell commented on May 14, 2024 4

Jk. I figured it out. attaching the event listener in the onLoad like so

  onLoad = () => {
    const { design } = this.props.values;
    if (design) {
      window.unlayer.loadDesign(design);
    }
    window.unlayer.addEventListener('design:updated', (data) => {
      this.setState({ designUpdated: true });
    });
  }

from react-email-editor.

generalleger avatar generalleger commented on May 14, 2024

@carylgaskell does your event listener trigger on each keystroke? As far as I can tell. A user can click into the editor and start typing and the 'design:updated' listener does not trigger. If the user clicks out of the iframe, it triggers.

There used to be a bunch of different listeners, and one of them (not sure which) would trigger the call back on each keystroke if someone were typing into the iframe. It was convenient, because, like you, i needed to know when the form was 'dirty'.

In lieu of that, I added an event listener to tell me when the user clicks into the iframe, which assumes that they will start typing once they click, which is not entirely ideal.

var listener = window.addEventListener('blur', () => {
      if (document.activeElement.nodeName === "IFRAME") {
          //do something here
      }
      window.removeEventListener('blur', listener);
});

from react-email-editor.

ajiths10 avatar ajiths10 commented on May 14, 2024

Here is a sample, with on change and load existing design.
https://github.com/ajiths10/EmailEditor-ReactApp/blob/main/src/component/AdvancedEditor.tsx

from react-email-editor.

Related Issues (20)

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.