File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
src/json-crdt-peritext-ui/plugins/toolbar/cursor/caret/CaretBottomOverlay Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 22import * as React from 'react' ;
33import { FormattingsManagePane } from '../../../formatting/FormattingsManagePane' ;
44import { BottomPanePortal } from '../../util/BottomPanePortal' ;
5+ import { useToolbarPlugin } from '../../../context' ;
6+ import { PeritextEventDetailMap } from '../../../../../events' ;
57import type { CaretViewProps } from '../../../../../web/react/cursor/CaretView' ;
68
9+ const isDirectCaretPlacement = ( event : PeritextEventDetailMap [ 'change' ] [ 'ev' ] | undefined ) : boolean => {
10+ if ( event && event . type === 'cursor' ) {
11+ const detail = event . detail ;
12+ const at = detail . at ;
13+ if ( Array . isArray ( at ) && at . length === 1 && typeof at [ 0 ] === 'number' ) return true ;
14+ const move = detail . move ;
15+ if ( Array . isArray ( move ) && move . length === 1 && Array . isArray ( move [ 0 ] ) && move [ 0 ] [ 0 ] === 'focus' && typeof move [ 0 ] [ 1 ] === 'number' ) return true ;
16+ }
17+ return false ;
18+ } ;
19+
720export interface CaretBottomOverlayProps extends CaretViewProps { }
821
922export const CaretBottomOverlay : React . FC < CaretBottomOverlayProps > = ( props ) => {
1023 const { fwd, bwd} = props ;
1124 const inline = fwd || bwd ;
25+ const { toolbar} = useToolbarPlugin ( ) ! ;
26+
27+ console . log ( toolbar . lastEvent ?. detail ) ;
1228
1329 if ( ! inline ) return ;
30+ if ( ! isDirectCaretPlacement ( toolbar . lastEvent ) ) return ;
1431
1532 return (
1633 < BottomPanePortal >
You can’t perform that action at this time.
0 commit comments