Re:CodeMirror 6
by swalsh on Friday February 05, 2021 @01:46PM
(#26039770)
Anyone know how this works with React? The old version has a wrapper, but it's pretty crude.
[ Parent
| on HN ]
I've never used CodeMirror, but I'm using ProseMirror by the same author and it relies a lot on having control of the DOM.
I'm guessing the integration will be basically a wrapper component with a ref of a DOM node where CodeMirror will do its thing.
Re:CodeMirror 6
by dmitryminkovsky on Friday February 05, 2021 @04:37PM
(#26041520)
> I'm guessing the integration will be basically a wrapper component with a ref of a DOM node where CodeMirror will do its thing.
Pretty much. This is how my React ProseMirror integration works: https://github.com/dminkovsky/use-prosemirror/blob/main/src/.... Though there are some complexities. I believe CodeMirror would be the same.
I use it in React by pointing the setup code at a ref of the CodeMirror div container and then I store the CodeMirror View object in another separate ref of the component so I have access to it from other places. Slightly awkward, but seems to work fine.
Re:CodeMirror 6
by CoffeePython on Friday February 05, 2021 @03:16PM
(#26040670)
Not sure on using CodeMirror but I’m using Ace on my vim learning tool because it has vim key bindings. It’s been a great tool!
Would like to check out code mirror also though too and see if I like it better.
I've been using it with React for a couple months now. In my experience it's been a little awkward but overall fairly usable. It seems like it would be easy to write a wrapper for.
You'd likely be better off using the library directly and writing your own wrapper. You could probably setup a basic one in 10 lines of code.