1
1
import React , { useCallback , useEffect , useState } from 'react'
2
2
3
+ import { shift , offset , flip } from '@floating-ui/react-dom-interactions'
3
4
import { Icon } from '@iconify/react'
4
5
import useMergedRef from '@react-hook/merged-ref'
5
- import { getPlateEditorRef , getRangeBoundingClientRect , PortalBody , useEditorState , usePlateEditorRef , useVirtualFloating } from '@udecode/plate'
6
+ import {
7
+ getPlateEditorRef ,
8
+ getRangeBoundingClientRect ,
9
+ PortalBody ,
10
+ useEditorState ,
11
+ usePlateEditorRef ,
12
+ useVirtualFloating
13
+ } from '@udecode/plate'
6
14
import { useTheme } from 'styled-components'
7
15
8
- import { shift , offset , flip } from '@floating-ui/react-dom-interactions'
9
16
import { DisplayShortcut } from '@workduck-io/mex-components'
10
17
11
- import { mog , NodeEditorContent } from '@mexit/core'
18
+ import { mog , NodeEditorContent } from '@mexit/core'
12
19
import { ComboboxItem , ComboboxItemTitle , MexIcon , PreviewMeta } from '@mexit/shared'
13
20
import {
14
21
ActionTitle ,
@@ -107,7 +114,6 @@ export const Combobox = ({ onSelectItem, onRenderItem, isSlash, portalElement }:
107
114
const editor = usePlateEditorRef ( )
108
115
const theme = useTheme ( )
109
116
110
-
111
117
const menuProps = combobox ? combobox . getMenuProps ( { } , { suppressRefError : true } ) : { ref : null }
112
118
113
119
const comboProps = ( item , index ) => {
@@ -141,7 +147,7 @@ export const Combobox = ({ onSelectItem, onRenderItem, isSlash, portalElement }:
141
147
useEffect ( ( ) => {
142
148
return ( ) => closeMenu ( )
143
149
} , [ ] )
144
-
150
+
145
151
useEffect ( ( ) => {
146
152
const comboItem = items [ itemIndex ]
147
153
@@ -179,13 +185,9 @@ export const Combobox = ({ onSelectItem, onRenderItem, isSlash, portalElement }:
179
185
}
180
186
} , [ itemIndex , items , activeBlock , isOpen , search ] )
181
187
182
- const getBoundingClientRect = useCallback (
183
- ( ) => {
184
-
185
- return getRangeBoundingClientRect ( editor , targetRange )
186
-
187
- } , [ editor , targetRange ]
188
- )
188
+ const getBoundingClientRect = useCallback ( ( ) => {
189
+ return getRangeBoundingClientRect ( editor , targetRange )
190
+ } , [ editor , targetRange ] )
189
191
190
192
// Update popper position
191
193
const { style, floating } = useVirtualFloating ( {
@@ -201,9 +203,8 @@ const getBoundingClientRect = useCallback(
201
203
202
204
return (
203
205
< PortalBody >
204
- { isOpen && (
205
-
206
- < ComboboxRoot { ...menuProps } ref = { floating } style = { style } isOpen = { isOpen } >
206
+ { isOpen && (
207
+ < ComboboxRoot { ...menuProps } ref = { floating } style = { style } isOpen = { isOpen } >
207
208
< >
208
209
{ ! isBlockTriggered && (
209
210
< div id = "List" style = { { flex : 1 } } >
@@ -290,17 +291,16 @@ const getBoundingClientRect = useCallback(
290
291
readOnly
291
292
draftView
292
293
editorId = {
293
- isBlockTriggered && activeBlock ? activeBlock . blockId : `${ items [ itemIndex ] ?. key } _Preview_Block`
294
+ isBlockTriggered && activeBlock ? activeBlock ? .blockId : `${ items [ itemIndex ] ?. key } _Preview_Block`
294
295
}
295
296
/>
296
297
</ section >
297
298
{ preview && < PreviewMeta meta = { metaData } /> }
298
299
</ ComboSeperator >
299
300
) }
300
301
</ >
301
- </ ComboboxRoot >
302
- ) }
303
-
302
+ </ ComboboxRoot >
303
+ ) }
304
304
</ PortalBody >
305
305
)
306
306
}
0 commit comments