11import * as React from 'react' ;
22import { rule } from 'nano-theme' ;
33import { CaretToolbar } from 'nice-ui/lib/4-card/Toolbar/ToolbarMenu/CaretToolbar' ;
4+ import { MoveToViewport } from 'nice-ui/lib/utils/popup/MoveToViewport' ;
45import { useToolbarPlugin } from './context' ;
56import { useSyncStore , useSyncStoreOpt , useTimeout } from '../../web/react/hooks' ;
67import type { CaretViewProps } from '../../web/react/cursor/CaretView' ;
@@ -31,7 +32,7 @@ export const RenderFocus: React.FC<RenderFocusProps> = ({children, cursor}) => {
3132 const { toolbar} = useToolbarPlugin ( ) ! ;
3233 const showInlineToolbar = toolbar . showInlineToolbar ;
3334 const [ showInlineToolbarValue , toolbarVisibilityChangeTime ] = useSyncStore ( showInlineToolbar ) ;
34- const enableAfterCoolDown = useTimeout ( 500 , [ toolbarVisibilityChangeTime ] ) ;
35+ const enableAfterCoolDown = useTimeout ( 300 , [ toolbarVisibilityChangeTime ] ) ;
3536 const isScrubbing = useSyncStoreOpt ( toolbar . surface . dom ?. cursor . mouseDown ) || false ;
3637 // const focus = useSyncStoreOpt(toolbar.surface.dom?.cursor.focus) || false;
3738 // const blurTimeout = useTimeout(300, [focus]);
@@ -45,11 +46,13 @@ export const RenderFocus: React.FC<RenderFocusProps> = ({children, cursor}) => {
4546
4647 if ( showInlineToolbarValue && ! isScrubbing && ( toolbar . txt . editor . mainCursor ( ) === cursor ) )
4748 toolbarElement = (
48- < CaretToolbar
49- disabled = { ! enableAfterCoolDown /* || (!focus && blurTimeout) */ }
50- menu = { toolbar . getSelectionMenu ( ) }
51- onPopupClose = { handleClose }
52- />
49+ < MoveToViewport >
50+ < CaretToolbar
51+ disabled = { ! enableAfterCoolDown /* || (!focus && blurTimeout) */ }
52+ menu = { toolbar . getSelectionMenu ( ) }
53+ onPopupClose = { handleClose }
54+ />
55+ </ MoveToViewport >
5356 ) ;
5457
5558 return (
0 commit comments