-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error occurred when calling renderFromHTML: Can't find a Block to remove. #2518
Comments
I had same issue when I called clear() twice in a row, while not waiting for first clear to finish. renderFromHTML actually also calls internally clear(), so check that you wait for the first clear() to finish before calling the renderFromHTML either by using await before clear or by calling renderFromHTML inside .then() block. |
Hey @luichooy found a way? I am in a react dev and facing the same problem. wanted to clear and render a new block programmatically |
I have the same error |
Describe a bug.
I need to call the
editor.clear()
method to clear the existing content in the editor before calling theeditor.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
afterclear
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:
editor.clear()
editor.blocks.renderFromHTML( '<p>call renderFromHTML after editor.clear()</p>')
Expected behavior:
No error occur or some ways to avoid this, thanks!
Screenshots:
![image](https://private-user-images.githubusercontent.com/26423033/276933372-f0487111-fae0-4415-9a38-cd74361fa221.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM1MDM3OTgsIm5iZiI6MTcyMzUwMzQ5OCwicGF0aCI6Ii8yNjQyMzAzMy8yNzY5MzMzNzItZjA0ODcxMTEtZmFlMC00NDE1LTlhMzgtY2Q3NDM2MWZhMjIxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODEyVDIyNTgxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQxZDQyZGJlZTRmNGVjOTgzOTYzNTExMDFiMTBiMWQxNTI0NGZiZjdhZmZhNDk3NTc0MGMyM2E4MjQ3ZDA4YzMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.TcPf_4YCt_hIDw-2Gj20c6bLPxSYj3McTNe1aKzBcng)
Device, Browser, OS:
Editor.js version:
https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest
Plugins you use with their versions:
The text was updated successfully, but these errors were encountered: