-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #2506 - Updating react codemirror package that we use #3077
Changes from 8 commits
25d0c2d
ebc3923
337326c
2577cc0
1a04dcf
c5f716c
7937e26
bc46cba
6e10790
09b3998
e477f13
9796ad9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,6 @@ | ||
import React from "react"; | ||
import { UnControlled as CodeMirror } from "react-codemirror2"; | ||
import "codemirror/mode/javascript/javascript"; | ||
|
||
const cmOptions = { | ||
theme: "default", | ||
height: "auto", | ||
viewportMargin: Infinity, | ||
mode: { | ||
name: "javascript", | ||
json: true, | ||
statementIndent: 2, | ||
}, | ||
lineNumbers: true, | ||
lineWrapping: true, | ||
indentWithTabs: false, | ||
tabSize: 2, | ||
}; | ||
import CodeMirror, { ViewUpdate } from "@uiw/react-codemirror"; | ||
import { langs } from "@uiw/codemirror-extensions-langs"; | ||
|
||
type Props = { | ||
readonly: boolean; | ||
|
@@ -30,7 +15,7 @@ export default function JSONEditor({ | |
value, | ||
onChange, | ||
}: Props) { | ||
const onCodeChange = (editor: Object, metadata: any, code: string) => { | ||
const onCodeChange = (code: string, viewUpdate: ViewUpdate) => { | ||
onChange(code); | ||
}; | ||
|
||
|
@@ -39,9 +24,11 @@ export default function JSONEditor({ | |
) : ( | ||
<CodeMirror | ||
value={value} | ||
autoCursor={false} | ||
onChange={onCodeChange} | ||
options={cmOptions} | ||
height="auto" | ||
style={{}} | ||
extensions={[langs.json()]} | ||
indentWithTab={true} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We had There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, that was my bad. I also had an empty style object in there because I wasn't sure if I was going to need to tweak things. Switched indentWithTabs to false. Indentation size appears to be 2 by default so I didn't try to change it. But if we want to, it looks like we set that in extensions. |
||
/> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not necessary anymore? Shall we just remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, missed that one.