TypeError: Cannot read property 'replaceChild' of null #22
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Getting this error
I'm not sure if what I'm about to suggest would resolve this issue, but let's give it a shot. Are you sure that there is a div with editor id in your DOM? By default,
document.querySelector("#editor")is invoked while setting upEditorView.No, that's not accurate—the library will append to the element is it given, and doesn't hard-code any specific ids.
Not sure why I missed this issue initially. @rj-david Did you solve this? If not, you're going to have to provide more details.
Yes, I missed one crucial piece of information, and as such, my previous comment is not accurate. I wanted to point out that the code resulting in the error might have originated from the basic example. If so, it seems that the div with editor id was not present in DOM. I used the code snippet from the URL above and had an error with the same title. After adding a div with editor id to DOM prior to the script execution, the issue was resolved for me.
We are hitting this constantly in production (we are working on a different editor that doesn't use prosemirror-menu):
That would happen when you create an editor that isn't in the DOM. We could add a condition to not call
replaceChildin that situation, but that would mean you wouldn't see the menu bar, which is probably also not what you're looking for. So for now my advice would be to make sure you're not using the menu with 'detached' editors (that were created with null as first constructor argument)Probably would have saved us time if it just said that I was missing an editorView element :) We were unintentionally initializing an editor without an element