Closed indusee closed 1 year ago
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
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
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:
And also using the other plugins you mentioned, underline and change-case:
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.
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)
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
Closing this as the usage instructions for React have been added and released on version 2.0.14
!
Precheck
Description
A clear and concise description of what the bug is.
Environment
Current behavior
Include code samples, errors and stack traces if appropriate. If reporting a bug, please include the reproducing steps.
Expected behavior
A clear and concise description of what you expected to happen.
Additional context
Add any other context about the problem here.