Giter Site home page Giter Site logo

Comments (6)

karolrojas07 avatar karolrojas07 commented on August 16, 2024 1

Hi, @indusee. I have great news, here a left you a Sandbox, where you can see how to use this Undo plugin using react-editor-js into a React class component :
https://codesandbox.io/embed/react-editor-js-v2-forked-kct1je?fontsize=14&hidenavigation=1&theme=dark

// Other imports ...

// Import the Undo library
import Undo from "editorjs-undo";
const ReactEditorJS = createReactEditorJS();

class ReactEditor extends Component {
// Add this constructor
  constructor(props) {
    super(props);
    this.editorCore = React.createRef();
  }

// Add these two following functions
  handleInitialize = (instance) => {
    this.editorCore.current = instance;
  };

  handleReady = () => {
    const editor = this.editorCore.current._editorJS;
    new Undo({ editor });
  };

// And add the "onInitialize" and "OnReady"
  render() {
    return (
      <ReactEditorJS
        onInitialize={this.handleInitialize}
        onReady={this.handleReady}
        tools={EDITOR_JS_TOOLS}
        defaultValue={ ... }
       />
    );
  }
}

You can see that it is working using the underline and change-case plugins
UndoSandbox

from editorjs-undo.

indusee avatar indusee commented on August 16, 2024

Plugins you use with their versions: "@editorjs/underline": "^1.0.0", "editorjs-change-case": "0.0.3", "editorjs-undo": "^2.0.9",
Device, Browser, OS: Dell , Googlecrome Version 106.0.5249.121 (Official Build) (64-bit), Microsoft Windows 10pro, editorjs:ReactEditorJs

from editorjs-undo.

indusee avatar indusee commented on August 16, 2024

i am getting this error in console
client.js:36 Uncaught (in promise) TypeError: Cannot destructure property 'blocks' of 'editor' as it is undefined.
at new Undo (index.js:33:1)
at onReady (ViewOnBoarding.js:1192:1)
at editor.js:2:1

from editorjs-undo.

karolrojas07 avatar karolrojas07 commented on August 16, 2024

Hi, @indusee, I hope you are doing well.
I have been trying to reproduce the error you mentioned.
And, I did undo and redo actions for only text blocks:

text

And also using the other plugins you mentioned, underline and change-case:
Text2

But, I can't get your error. So, please, can you provide us a detailed description with steps to reproduce the error you reported? Or a code sandbox? (https://codesandbox.io/)

Thanks.

from editorjs-undo.

indusee avatar indusee commented on August 16, 2024

https://codesandbox.io/p/github/indusee/undo-redo_bug/draft/exciting-austin?file=%2Fsrc%2F
(please once run this code, I was tested here undo redo not working for underline plugin, please mention where I did mistake)

from editorjs-undo.

miguelnietoa avatar miguelnietoa commented on August 16, 2024

Closing this as the usage instructions for React have been added and released on version 2.0.14!

from editorjs-undo.

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.