mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-26 06:35:51 +00:00
Use @uiw/react-codemirror and react@18
Updating redocly to latest and leveraging `@uiw/react-codemirror` which it also uses.
This commit is contained in:
26
content/shared/editor/json-editor.tsx
Normal file
26
content/shared/editor/json-editor.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { linter, lintGutter } from '@codemirror/lint'
|
||||
import { json, jsonParseLinter } from '@codemirror/lang-json'
|
||||
import { Extension } from '@codemirror/state'
|
||||
|
||||
import { Editor, EditorWrapperProps } from './editor'
|
||||
|
||||
export const JsonEditor = ({value, onChange, readOnly, lineNumbers }: EditorWrapperProps) => {
|
||||
const extensions: Extension[] = [
|
||||
json()
|
||||
]
|
||||
|
||||
if(!readOnly) {
|
||||
extensions.push(
|
||||
lintGutter(),
|
||||
linter(jsonParseLinter())
|
||||
)
|
||||
}
|
||||
|
||||
return <Editor
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
readOnly={readOnly}
|
||||
extensions={extensions}
|
||||
lineNumbers={lineNumbers}
|
||||
/>
|
||||
}
|
||||
Reference in New Issue
Block a user