@@ -23,8 +23,7 @@ import { useBlockNoteEditor } from "@blocknote/react";
2323import { AIInlineToolbarProsemirrorPlugin } from "../../../../core" ;
2424import { useAIDictionary } from "../../../hooks/useAIDictionary" ;
2525
26- // TODO: name?
27- export const AIButton = ( ) => {
26+ export const AIButtonCombobox = ( ) => {
2827 const dict = useAIDictionary ( ) ;
2928 const Components = useComponentsContext ( ) ! ;
3029
@@ -110,6 +109,48 @@ export const AIButton = () => {
110109 setSelectedIndex ( 0 ) ;
111110 } , [ currentEditingPrompt , setSelectedIndex ] ) ;
112111
112+ return (
113+ < >
114+ < Components . Generic . Form . Root >
115+ < Components . Generic . Form . TextInput
116+ name = { "ai-prompt" }
117+ icon = { < RiSparkling2Fill /> }
118+ value = { currentEditingPrompt || "" }
119+ autoFocus = { true }
120+ placeholder = { dict . formatting_toolbar . ai . input_placeholder }
121+ onKeyDown = { handleKeyDown }
122+ onChange = { handleChange }
123+ />
124+ </ Components . Generic . Form . Root >
125+ < Components . SuggestionMenu . Root
126+ className = { "bn-ai-menu" }
127+ id = { "ai-suggestion-menu" } >
128+ { items . map ( ( item , index ) => (
129+ < Components . SuggestionMenu . Item
130+ key = { item . name }
131+ className = { "bn-suggestion-menu-item" }
132+ id = { item . name }
133+ isSelected = { index === selectedIndex }
134+ onClick = { item . onItemClick }
135+ item = { item }
136+ />
137+ ) ) }
138+ </ Components . SuggestionMenu . Root >
139+ </ >
140+ ) ;
141+ } ;
142+
143+ // TODO: name?
144+ export const AIButton = ( ) => {
145+ const dict = useAIDictionary ( ) ;
146+ const Components = useComponentsContext ( ) ! ;
147+
148+ const editor = useBlockNoteEditor <
149+ BlockSchema ,
150+ InlineContentSchema ,
151+ StyleSchema
152+ > ( ) ;
153+
113154 if ( ! editor . isEditable ) {
114155 return null ;
115156 }
@@ -127,31 +168,7 @@ export const AIButton = () => {
127168 < Components . Generic . Popover . Content
128169 variant = "form-popover"
129170 className = { "bn-popover-content bn-form-popover" } >
130- < Components . Generic . Form . Root >
131- < Components . Generic . Form . TextInput
132- name = { "ai-prompt" }
133- icon = { < RiSparkling2Fill /> }
134- value = { currentEditingPrompt || "" }
135- autoFocus = { true }
136- placeholder = { dict . formatting_toolbar . ai . input_placeholder }
137- onKeyDown = { handleKeyDown }
138- onChange = { handleChange }
139- />
140- </ Components . Generic . Form . Root >
141- < Components . SuggestionMenu . Root
142- className = { "bn-ai-menu" }
143- id = { "ai-suggestion-menu" } >
144- { items . map ( ( item , index ) => (
145- < Components . SuggestionMenu . Item
146- key = { item . name }
147- className = { "bn-suggestion-menu-item" }
148- id = { item . name }
149- isSelected = { index === selectedIndex }
150- onClick = { item . onItemClick }
151- item = { item }
152- />
153- ) ) }
154- </ Components . SuggestionMenu . Root >
171+ < AIButtonCombobox />
155172 </ Components . Generic . Popover . Content >
156173 </ Components . Generic . Popover . Root >
157174 ) ;
0 commit comments