Code blocks!!! Now without major lag!!
A very annoying bug with a solution I can’t believe I missed. Basically, to get large code blocks to work, MDXEditor gives you a codeMirrorPlugin. This plugin lets you pass a list of languages to have in the selector and to have syntax highlighting support for (codemirror provides a very large data set of them, luckily). The problem was, this list was very large and caused lag when typing.
I ended up asking the discussions page and (after an unhelpful AI response), we figured out my onChange handler setting a content state that the markdown editor used was causing the whole thing to re-render every time you typed, and with the large language array, causing a lot of lag. You’ll notice in the video the language selector in the toolbar.
So it was a very, very simple fix. I even went through and implemented auto-saving instead (every 5 seconds). It even stops you from leaving if it hasn’t saved yet!
I also fixed a whole slew of scrolling issues with long markdown files. It was the stupidest thing ever and I’m not proud of the fix, but it works now.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.