ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
29.97k stars 3.25k forks source link

Spellcheck causes slow load? #448

Closed anilgulecha closed 7 years ago

anilgulecha commented 7 years ago

I'm trying out slate post the recent thread on HN. There's a performance issue I'd like to note compared to prosemirror:

  1. Open the large document: http://slatejs.org/#/large?_k=tdn4em .. this should take upto 20 seconds, depending on computer speed.

  2. Copy the contents.

  3. Head over to https://prosemirror.net/demo/dino.html

  4. Inspect element on the top level editor $(".ProseMirror-content"), and set spellcheck to true.

  5. Paste in the contents. You'll note that the content loads up much quicker. Spell check is only activated on visiting a node.

The performance different is large. Please let me know if you have trouble reproducing this issue.

anilgulecha commented 7 years ago

The same can be seen by pasting in http://substance.io/examples/inline-node/ to (after turning on spell check).

ianstormtaylor commented 7 years ago

Hey @anilgulecha, thanks for asking this!

Question for you: do you know what behavior specifically causes the spellcheck to only be active after visiting a node? It seems like it's even intra-node as far as Prosemirror is concerned. And are you able to get Slate to exhibit that behavior?

I think there are going to be other concerns for performance besides the spellchecking, so I'd like to be able to control the experiment to just Slate with and without whole-document spellcheck if possible. Since I'm sure there are lots of differences in how rendering works across editors.

ianstormtaylor commented 7 years ago

Nevermind, it looks like the intra-node behavior is just a result of enabling spellcheck="true" on the DOM node midway through, instead of a specific behavior that Prosemirror or another editor is triggering. You can get Slate to do the same thing if you change the spellcheck attribute in developer tools.

It doesn't look like spellcheck on or off for Slate has a noticeable difference in performance, even on the large document. I was considering defaulting it to false if that was the case, but since it doesn't appear to be I think we should keep it the same.

My guess is that the performance issue lies somewhere else in how Slate is deserializing initial state.

Thanks for reporting @anilgulecha!