admin管理员组

文章数量:1277398

I want to get the same color CSS styling as shown on / for theme: dark and language: JSON

But when I tried it with react-codemirror ("@uiw/react-codemirror": "^4.23.8"):

                        <CodeMirror
                            value={{ JSON .... }}
                            minHeight={"120px"}
                            theme={basicDark}
                            extensions={[
                                basicDark,
                                javascript({ jsx: true }),
                                // EditorView.lineWrapping
                            ]}
                            onChange={onChange}
                        />

it looks like this instead:

On the online example the HTML for the JSON "message": "Network Error" have seperate CSS classes for the JSON key and value:

But the one on my localhost both JSON key and value have the same class:

It seems my localhost react-codemirror is missing alot of classes and styling, why is that?

Does anyone know why this is happening?

Why is it that the outcome is different from the example shown on /?

I want to get the same color CSS styling as shown on https://uiwjs.github.io/react-codemirror/ for theme: dark and language: JSON

But when I tried it with react-codemirror ("@uiw/react-codemirror": "^4.23.8"):

                        <CodeMirror
                            value={{ JSON .... }}
                            minHeight={"120px"}
                            theme={basicDark}
                            extensions={[
                                basicDark,
                                javascript({ jsx: true }),
                                // EditorView.lineWrapping
                            ]}
                            onChange={onChange}
                        />

it looks like this instead:

On the online example the HTML for the JSON "message": "Network Error" have seperate CSS classes for the JSON key and value:

But the one on my localhost both JSON key and value have the same class:

It seems my localhost react-codemirror is missing alot of classes and styling, why is that?

Does anyone know why this is happening?

Why is it that the outcome is different from the example shown on https://uiwjs.github.io/react-codemirror/?

Share Improve this question asked Feb 25 at 12:30 yelnyeln 7653 gold badges14 silver badges36 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Is it enough? I think you need to replace the JS extension with the JSON language extension to achieve this functionality as shown in the official demo. Instead of using basicDark, javascript({ jsx: true }), you should use extensions={[json()]} to achieve the desired result.

本文标签: