Coder Social home page Coder Social logo

Comments (6)

Rene-Montes avatar Rene-Montes commented on July 18, 2024 1

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

from prosemirror-menu.

nowakkamil avatar nowakkamil commented on July 18, 2024

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 up EditorView.

from prosemirror-menu.

marijnh avatar marijnh commented on July 18, 2024

By default, document.querySelector("#editor") is invoked while setting up EditorView.

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.

from prosemirror-menu.

nowakkamil avatar nowakkamil commented on July 18, 2024

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.

from prosemirror-menu.

Rene-Montes avatar Rene-Montes commented on July 18, 2024

We are hitting this constantly in production (we are working on a different editor that doesn't use prosemirror-menu):

+-----------------------------------------------------------------------+-------------------------------------------------------------+------+--------+
| function                                                              | file                                                        | line | column |
+-----------------------------------------------------------------------+-------------------------------------------------------------+------+--------+
| editorView.dom.parentNode.replaceChild(this.wrapper, editorView.dom); | webpack:///./node_modules/prosemirror-menu/dist/index.es.js | 670  | 28     |
| return new MenuBarView(editorView, options);                          | webpack:///./node_modules/prosemirror-menu/dist/index.es.js | 653  | 13     |
| this.pluginViews.push(plugin.spec.view(this));                        | webpack:///./node_modules/prosemirror-view/dist/index.es.js | 6771 | 42     |
| this.updatePluginViews();                                             | webpack:///./node_modules/prosemirror-view/dist/index.es.js | 6584 | 7      |
| let view = new EditorView(editor, {                                   | webpack:///./app/javascript/etc/prosemirror.js              | 16   | 15     |
| document.querySelectorAll('.markdown-content').forEach(mdc => {       | webpack:///./app/javascript/etc/prosemirror.js              | 12   | 49     |
| }), (null != u ? u : document).dispatchEvent(i), i;                   | webpack:///./node_modules/turbolinks/dist/turbolinks.js     | 75   | 39     |
| return null == t && (t = {}), e.dispatch("turbolinks:load", {         | webpack:///./node_modules/turbolinks/dist/turbolinks.js     | 994  | 42     |
| return this.notifyApplicationAfterPageLoad(t.getTimingMetrics());     | webpack:///./node_modules/turbolinks/dist/turbolinks.js     | 1007 | 22     |
+-----------------------------------------------------------------------+-------------------------------------------------------------+------+--------+

from prosemirror-menu.

marijnh avatar marijnh commented on July 18, 2024

That would happen when you create an editor that isn't in the DOM. We could add a condition to not call replaceChild in 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)

from prosemirror-menu.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.