Skip to content

Error occurred when calling renderFromHTML: Can't find a Block to remove. #2518

Open
@luichooy

Description

@luichooy

Describe a bug.
I need to call the editor.clear() method to clear the existing content in the editor before calling the editor.blocks.renderFromHTML() method.

However, doing so results in the error "Uncaught (in promise) Error: Can't find a Block to remove. "

The clear method is supposed to remove all Blocks and create a new empty initial type Block. So, after calling the clear method, a new default block should have been created.

I'm wondering why calling renderFromHTML after clear is causing the error "Can't find a Block to remove".

Additionally, even if there is an error, why isn't it caught by using renderFromHTML().catch()? Instead, the error is thrown directly. In a React development environment, this would result in a runtime error.

Steps to reproduce:

  1. call editor.clear()
  2. call editor.blocks.renderFromHTML( '<p>call renderFromHTML after editor.clear()</p>')
  3. The error message states "Can't find a Block to remove" and appeared in the console.

Expected behavior:
No error occur or some ways to avoid this, thanks!

Screenshots:
image

Device, Browser, OS:

Editor.js version:
https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest
Plugins you use with their versions:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions