@@ -46,7 +46,11 @@ type SchemaItemProps = {
4646 isArrayItems ?: boolean ;
4747 isRequire ?: boolean ;
4848 schema : JSONSchema7 ;
49- changeSchema ?: ( namePath : number [ ] , value : any , propertyName : string ) => void ;
49+ changeSchema ?: (
50+ namePath : number [ ] ,
51+ value : any ,
52+ propertyName ?: string ,
53+ ) => void ;
5054 renameProperty ?: ( namePath : number [ ] , name : string ) => void ;
5155 removeProperty ?: ( namePath : number [ ] ) => void ;
5256 addProperty ?: ( path : number [ ] , isChild : boolean ) => void ;
@@ -55,6 +59,11 @@ type SchemaItemProps = {
5559 requiredProperty : string ,
5660 removed : boolean ,
5761 ) => void ;
62+ handleAdvancedSettingClick ?: (
63+ namePath : number [ ] ,
64+ schema : JSONSchema7 ,
65+ propertyName ?: string ,
66+ ) => boolean ;
5867} ;
5968
6069function SchemaItem ( props : SchemaItemProps ) {
@@ -70,6 +79,7 @@ function SchemaItem(props: SchemaItemProps) {
7079 removeProperty,
7180 addProperty,
7281 isRequire,
82+ handleAdvancedSettingClick,
7383 } = props ;
7484
7585 const [ schema , setSchema ] = useState ( props . schema ) ;
@@ -273,6 +283,18 @@ function SchemaItem(props: SchemaItemProps) {
273283 icon = { < SettingOutlined /> }
274284 style = { { color : 'green' } }
275285 onClick = { ( ) => {
286+ if (
287+ handleAdvancedSettingClick &&
288+ ! handleAdvancedSettingClick (
289+ namePath ,
290+ schema ,
291+ isRoot || schema . type === 'object'
292+ ? undefined
293+ : propertyName ,
294+ )
295+ ) {
296+ return ;
297+ }
276298 setFormSchema ( schema ) ;
277299 setAdvancedModal ( ! advancedModal ) ;
278300 } }
@@ -410,7 +432,7 @@ function SchemaItem(props: SchemaItemProps) {
410432 return ;
411433 }
412434 if ( isRoot || schema . type === 'object' ) {
413- changeSchema ( namePath , { ...schema , ...formSchema } , 'root' ) ;
435+ changeSchema ( namePath , { ...schema , ...formSchema } ) ;
414436 setAdvancedModal ( ! advancedModal ) ;
415437 return ;
416438 }
@@ -821,7 +843,7 @@ function SchemaItem(props: SchemaItemProps) {
821843 break ;
822844 }
823845 if ( changeSchema ) {
824- changeSchema ( [ ] , schema , 'root' ) ;
846+ changeSchema ( [ ] , schema ) ;
825847 setImportModal ( ! importModal ) ;
826848 setImportValue ( undefined ) ;
827849 }
0 commit comments