codex-team / codex-team/editor.js

Editor state getting reverted using header and console logs "Block «header» skipped because saved data is invalid".

Open
#2,767 10 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
31.9k
Forks
2.2k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

### Describe the bug.
I am using editorJs in my react application as a form component and when trying to add a Paragraph or Header I am getting following error in the console "Block «header» skipped because saved data is invalid" for header and "Block «paragraph» skipped because saved data is invalid" for Paragraph also the editor state gets reverted back to blocks -> 0 and I am not able to get the header or paragraph on the next line. Following is the sample react code attached how I have initialized editorJs in my application.

```
import React, { useEffect, useRef } from 'react';
import EditorJS from '@editorjs/editorjs';
import Header from '@editorjs/header';
import List from '@editorjs/list';
import Paragraph from '@editorjs/paragraph';

const Editor = ({ data, onChange }) => {
const ejInstance = useRef(null);
const editorContainer = useRef(null);

useEffect(() => {
if (!ejInstance.current) {
ejInstance.current = new EditorJS({
holder: editorContainer.current,
tools: {
header: Header,
list: List,
paragraph: {
class: Paragraph,
inlineToolbar: true,
},
},
data: data,
onChange: async () => {
const content = await ejInstance.current.save();
onChange(content);
},
});
}

return () => {
if (ejInstance.current && typeof ejInstance.current.destroy === 'function') {
ejInstance.current.destroy();
ejInstance.current = null;
}
};
}, [data, onChange]);

return

;
};

export default Editor;
```

### Screenshots:
![image](https://github.com/codex-team/editor.js/assets/132342163/d866e80b-8e73-4323-8f09-bf127cc71660)

### Device, Browser, OS: Windows, Google Chrome

### Editor.js version: 2.29.1

### Plugins you use with their versions: header 2.8.1, paragraph 2.11.6

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.