I am using Editor.js. I’ve tried adding a new block to the editor but it doesn’t work
<html>
<script src="https://cdn.jsdelivr.net/npm/@editorjs/[email protected]/dist/editorjs.umd.js" type="text/javascript"></script>
</head>
<body>
<div id="editorjs" class="editor-holder"></div>
<script>
var editor = new EditorJS({
holder: 'editorjs',
autofocus: true,
data: {
"time": 1550476186479,
"blocks": [{
type: 'paragraph',
data: {
text: 'Hello world'
}}
]}
})
const newBlock = {
type: 'paragraph',
data: {
text: 'Hello world'
}
};
editor.blocks.insert(newBlock.type, newBlock.data);
</script>
</body>
I’m facing the following error:
Uncaught TypeError: Cannot read properties of undefined (reading 'insert')
I’ve also tried following:
editor.blocks.insert(newBlock);
editor.configuration.data.blocks.push(newBlock);
editor.api.blocks.insert(newBlock);
but I get errors