mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-05-26 08:08:17 +08:00

Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: jZonG <jzongcode@gmail.com>
32 lines
877 B
TypeScript
32 lines
877 B
TypeScript
import { MenuOption } from '@lexical/react/LexicalTypeaheadMenuPlugin'
|
|
import { Fragment } from 'react'
|
|
|
|
/**
|
|
* Corresponds to the `MenuRenderFn` type from `@lexical/react/LexicalTypeaheadMenuPlugin`.
|
|
*/
|
|
type MenuOptionRenderProps = {
|
|
isSelected: boolean
|
|
onSelect: () => void
|
|
onSetHighlight: () => void
|
|
queryString: string | null
|
|
}
|
|
|
|
export class PickerBlockMenuOption extends MenuOption {
|
|
public group?: string
|
|
|
|
constructor(
|
|
private data: {
|
|
key: string
|
|
group?: string
|
|
onSelect?: () => void
|
|
render: (menuRenderProps: MenuOptionRenderProps) => React.JSX.Element
|
|
},
|
|
) {
|
|
super(data.key)
|
|
this.group = data.group
|
|
}
|
|
|
|
public onSelectMenuOption = () => this.data.onSelect?.()
|
|
public renderMenuOption = (menuRenderProps: MenuOptionRenderProps) => <Fragment key={this.data.key}>{this.data.render(menuRenderProps)}</Fragment>
|
|
}
|