fix: fix duplicate display of Hello plugin
This commit is contained in:
		
							parent
							
								
									301a85d767
								
							
						
					
					
						commit
						b95f4a723a
					
				| @ -39,13 +39,22 @@ export const HelloBlockInitializer = (props) => { | ||||
| 
 | ||||
| const HelloProvider = React.memo((props) => { | ||||
|   const items = useContext<any>(SchemaInitializerContext); | ||||
|   const children = items.BlockInitializers.items[1].children; | ||||
|   children.push({ | ||||
|     key: 'hello', | ||||
|     type: 'item', | ||||
|     title: '{{t("Hello block")}}', | ||||
|     component: 'HelloBlockInitializer', | ||||
|   }); | ||||
|   const mediaItems = items.BlockInitializers.items.find((item) => item.key === 'media'); | ||||
| 
 | ||||
|   if (process.env.NODE_ENV !== 'production' && !mediaItems) { | ||||
|     throw new Error('media block initializer not found'); | ||||
|   } | ||||
| 
 | ||||
|   const children = mediaItems.children; | ||||
|   if (!children.find((item) => item.key === 'hello')) { | ||||
|     children.push({ | ||||
|       key: 'hello', | ||||
|       type: 'item', | ||||
|       title: '{{t("Hello block")}}', | ||||
|       component: 'HelloBlockInitializer', | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   return ( | ||||
|     <SettingsCenterProvider | ||||
|       settings={{ | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user