[Bug] editor.render with "blocks":[] breaks the editor
See original GitHub issue(Not sure if exact duplicate of https://github.com/codex-team/editor.js/pull/1741 )
Steps to reproduce:
- call editor.render with this json: {“time”:1655483036373,“blocks”:[],“version”:“2.24.3”}
- Observe editor gives errors in console, and it is now impossible to add blocks or type into the editor.
Expected behavior: Editor operates as normal, with either no blocks present or with one default block.
Workaround: If you make a blank document and save it, it returns “blocks”:[]. However you cannot load this to get back your blank document. I’ve had to manually change blank documents to have instead: “blocks”:[{“id”:“dvSFGiwGIy”,“type”:“paragraph”,“data”:{“text”:“”}}] With at least one block, the file loads correctly.
Screenshots: I get three different errors when clicking around on the broken editor:
Editor.js 2.24.3 There is no block at index -1 8 editor.js:1:3853
Uncaught TypeError: this.Editor.BlockManager.lastBlock is undefined
Uncaught TypeError: s is undefined value editor.js:1 value editor.js:1 value editor.js:1 on editor.js:1 value editor.js:1 value editor.js:1 t editor.js:1 l editor.js:1 _invoke editor.js:1 e editor.js:1 n editor.js:1 s editor.js:1 exports editor.js:1 exports editor.js:1 value editor.js:1 t editor.js:1 l editor.js:1 _invoke editor.js:1 e editor.js:1 n editor.js:1 s editor.js:1 exports editor.js:1 exports editor.js:1 value editor.js:1 t editor.js:1 l editor.js:1 _invoke editor.js:1 e editor.js:1 n editor.js:1 s editor.js:1 exports editor.js:1 exports editor.js:1 promise callback*t/</< editor.js:1 t editor.js:1 l editor.js:1 _invoke editor.js:1 e editor.js:1 n editor.js:1 s editor.js:1 exports editor.js:1 exports editor.js:1 value editor.js:1 t editor.js:1 l editor.js:1 _invoke editor.js:1 e editor.js:1 n editor.js:1 s editor.js:1 promise callback*n editor.js:1 s editor.js:1 promise callback*n editor.js:1 s editor.js:1 exports editor.js:1 exports editor.js:1 promise callback*t editor.js:1 t editor.js:1 <anonymous> book.js:1 <anonymous> book.js:1 <anonymous> book.js:1
Device, Browser, OS:
Device, Browser, OS: Desktop/Firefox/Windows 10
Editor.js version: 2.24.3
Plugins you use with their versions: paragraph@2.8.0 header@2.6.2 simple-image@1.4.1 delimiter@1.2.0
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:5
Top GitHub Comments
Instead of
blocks: []
, useblocks: [{ type: "paragraph", data: {} }]
Since the devs dont seem to care to address one of the most basic functionalities of an editor I resolved it by making sure the editor is never empty. Initialize it with a block saying „enter content here“ or something and dont save when the editor is empty.