News for hackers. Stuff that matters.
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.
Re:CodeMirror 6 by pier25 on Friday February 05, 2021 @01:51PM (#26039817)
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.

Re:CodeMirror 6 by jrv on Friday February 05, 2021 @02:51PM (#26040439)
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.
Re:CodeMirror 6 by joelg on Friday February 05, 2021 @01:49PM (#26039789)
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.
Re:CodeMirror 6 by nicoburns on Friday February 05, 2021 @02:20PM (#26040123)
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.
Re:CodeMirror 6 by gidan on Saturday February 06, 2021 @02:46AM (#26044916)
Take a look at draftjs, it’s an alternative built by facebook (I’m not affiliated with Facebook in any way)