@@ -112,6 +112,7 @@ const customTheme = {
112112 ' --w-rjv-background-color' : ' #1e1e1e' ,
113113 ' --w-rjv-line-color' : ' #323232' ,
114114 ' --w-rjv-arrow-color' : ' var(--w-rjv-color)' ,
115+ ' --w-rjv-edit-color' : ' var(--w-rjv-color)' ,
115116 ' --w-rjv-info-color' : ' #656565' ,
116117 ' --w-rjv-update-color' : ' #ebcb8b' ,
117118 ' --w-rjv-copied-color' : ' #9cdcfe' ,
@@ -144,9 +145,9 @@ export default function Demo() {
144145Online custom style example, please check in the [ documentation website] ( https://uiwjs.github.io/react-json-view/ )
145146
146147``` tsx mdx:preview:&title=Online Editing Theme
147- import React , { useState , useEffect , useRef } from ' react' ;
148+ import React , { useState , useEffect } from ' react' ;
148149import Colorful from ' @uiw/react-color-colorful' ;
149- import JsonView from ' @uiw/react-json-view' ;
150+ import JsonView from ' @uiw/react-json-view/editor ' ;
150151
151152const object = {
152153 avatar: ' https://i.imgur.com/MK3eW3As.jpg' ,
@@ -176,6 +177,7 @@ const customTheme = {
176177 ' --w-rjv-background-color' : ' #1e1e1e' ,
177178 ' --w-rjv-line-color' : ' #323232' ,
178179 ' --w-rjv-arrow-color' : ' #9cdcfe' ,
180+ ' --w-rjv-edit-color' : ' #9cdcfe' ,
179181 ' --w-rjv-info-color' : ' #656565' ,
180182 ' --w-rjv-update-color' : ' #ebcb8b' ,
181183 ' --w-rjv-copied-color' : ' #0184a6' ,
@@ -199,6 +201,7 @@ const customTheme = {
199201export default function Demo() {
200202 const [cssvar, setCssvar] = useState (' --w-rjv-background-color' );
201203 const [hex, setHex] = useState (" #1e1e1e" );
204+ const [editable, setEditable] = useState (false );
202205 const [theme, setTheme] = useState (customTheme );
203206 const onChange = ({ hexa }) => {
204207 setHex (hexa );
@@ -217,13 +220,17 @@ export default function Demo() {
217220 return () => clearInterval (id )
218221 }, []);
219222
223+ const changeEditable = (evn ) => setEditable (evn .target .checked );
220224 return (
221225 <React.Fragment >
222- <div style = { { display: ' flex' , gap: ' 1rem' }} >
223- <JsonView value = { src } keyName = " root" style = { { flex: 1 , ... theme }} />
226+ <label >
227+ <input type = " checkbox" checked = { editable } onChange = { changeEditable } /> Editable
228+ </label >
229+ <div style = { { display: ' flex' , gap: ' 1rem' , alignItems: ' flex-start' }} >
230+ <JsonView editable = { editable } value = { src } keyName = " root" style = { { flex: 1 , overflow: ' auto' , ... theme }} />
224231 <div >
225232 <Colorful color = { hex } onChange = { onChange } />
226- <div style = { { display: ' flex' , gap: ' 0.4rem' , flexWrap : ' wrap ' }} >
233+ <div style = { { display: ' flex' , gap: ' 0.4rem' , flexDirection : ' column ' }} >
227234 { Object .keys (customTheme ).map ((varname , idx ) => {
228235 const click = () => {
229236 setCssvar (varname );
@@ -577,6 +584,8 @@ export default function Demo() {
577584
578585## Props
579586
587+ ### JsonView Props
588+
580589``` ts
581590import React from ' react' ;
582591import { MetaProps , SemicolonProps , EllipsisProps , ValueViewProps } from ' @uiw/react-json-view' ;
@@ -624,6 +633,26 @@ declare const JsonView: React.ForwardRefExoticComponent<Omit<JsonViewProps<objec
624633export default JsonView ;
625634```
626635
636+ ### JsonView Editor Props
637+
638+ ``` ts
639+ import { JsonViewProps } from ' @uiw/react-json-view' ;
640+ export interface JsonViewEditorProps <T extends object > extends JsonViewProps <T > {
641+ /** Callback when value edit functionality */
642+ onEdit? : (option : {
643+ value: unknown ;
644+ oldValue: unknown ;
645+ keyName? : string | number ;
646+ parentName? : string | number ;
647+ type? : ' value' | ' key' ;
648+ }) => void ;
649+ /** Whether enable edit feature. @default true */
650+ editable? : boolean ;
651+ }
652+ declare const JsonViewEditor: import (" react" ).ForwardRefExoticComponent <Omit <JsonViewEditorProps <object >, " ref" > & import (" react" ).RefAttributes <HTMLDivElement >>;
653+ export default JsonViewEditor ;
654+ ```
655+
627656## Size and dependencies
628657
629658Here is the size benchmark (using [ bundlephobia.com] ( https://bundlephobia.com ) ) against similar React libraries (found by [ ` npmjs.com/search ` ] ( https://www.npmjs.com/search?q=react%20json&ranking=popularity ) ):
0 commit comments