1
1
/** @jsx jsx */
2
2
/** @jsxRuntime classic */
3
3
import { jsx , css } from '@emotion/react' ;
4
- import React from 'react' ;
5
- import { useRecoilState , useRecoilValue , useSetRecoilState } from 'recoil' ;
4
+ import React , { useRef } from 'react' ;
5
+ import { useRecoilState , useRecoilValue } from 'recoil' ;
6
6
7
7
import { BlockContent } from '@atoms/index' ;
8
8
import { BlockHandler , HoverArea } from '@components/molecules' ;
@@ -12,7 +12,6 @@ import {
12
12
focusState ,
13
13
blockRefState ,
14
14
blockMapState ,
15
- draggingBlockState ,
16
15
} from '@stores/page' ;
17
16
18
17
const isGridOrColumn = ( block : Block ) : boolean =>
@@ -45,18 +44,10 @@ function BlockComponent({ blockDTO }: Props): JSX.Element {
45
44
const [ focusId , setFocusId ] = useRecoilState < string > ( focusState ) ;
46
45
const [ hoverId , setHoverId ] = useRecoilState ( hoverState ) ;
47
46
const blockRef : any = blockRefState [ blockDTO . id ] ;
48
- const setDraggingBlock = useSetRecoilState ( draggingBlockState ) ;
49
-
50
- const dragStartHandler = ( event : React . DragEvent < HTMLDivElement > ) => {
51
- event . dataTransfer . effectAllowed = 'move' ;
52
- event . dataTransfer . dropEffect = 'move' ;
53
- event . dataTransfer . setData ( 'text/html' , event . currentTarget . innerHTML ) ;
54
-
55
- setDraggingBlock ( blockDTO ) ;
56
- } ;
47
+ const blockComponentRef = useRef ( null ) ;
57
48
58
49
return (
59
- < div css = { blockCss } draggable = "true" onDragStart = { dragStartHandler } >
50
+ < div css = { blockCss } ref = { blockComponentRef } >
60
51
< div
61
52
css = { { position : 'relative' } }
62
53
onMouseEnter = { ( ) => setHoverId ( blockDTO . id ) }
@@ -67,7 +58,12 @@ function BlockComponent({ blockDTO }: Props): JSX.Element {
67
58
>
68
59
< BlockContent { ...blockDTO } />
69
60
< HoverArea clickHandler = { ( ) => blockRef . current . focus ( ) } />
70
- { hoverId === blockDTO . id && < BlockHandler /> }
61
+ { hoverId === blockDTO . id && (
62
+ < BlockHandler
63
+ blockDTO = { blockDTO }
64
+ blockComponentRef = { blockComponentRef }
65
+ />
66
+ ) }
71
67
</ div >
72
68
{ blockDTO . childIdList . length ? (
73
69
< div css = { descendantsCss ( blockDTO ) } >
0 commit comments