@@ -19,12 +19,7 @@ import {
19
19
import { useTranslation } from "react-i18next" ;
20
20
import { useHover } from "usehooks-ts" ;
21
21
22
- export default function Area ( {
23
- data,
24
- onPointerDown,
25
- setResize,
26
- setInitDimensions,
27
- } ) {
22
+ export default function Area ( { data, setResize, setInitDimensions } ) {
28
23
const ref = useRef ( null ) ;
29
24
const isHovered = useHover ( ref ) ;
30
25
const { layout } = useLayout ( ) ;
@@ -48,11 +43,47 @@ export default function Area({
48
43
} ) ;
49
44
} ;
50
45
51
- const lockUnlockArea = ( ) => {
52
- setBulkSelectedElements ( ( prev ) =>
53
- prev . filter ( ( el ) => el . id !== data . id || el . type !== ObjectType . AREA ) ,
54
- ) ;
55
- updateArea ( data . id , { locked : ! data . locked } ) ;
46
+ const lockUnlockArea = ( e ) => {
47
+ const locking = ! data . locked ;
48
+ updateArea ( data . id , { locked : locking } ) ;
49
+
50
+ const lockArea = ( ) => {
51
+ setSelectedElement ( {
52
+ ...selectedElement ,
53
+ element : ObjectType . NONE ,
54
+ id : - 1 ,
55
+ open : false ,
56
+ } ) ;
57
+ setBulkSelectedElements ( ( prev ) =>
58
+ prev . filter ( ( el ) => el . id !== data . id || el . type !== ObjectType . AREA ) ,
59
+ ) ;
60
+ } ;
61
+
62
+ const unlockArea = ( ) => {
63
+ if ( e . ctrlKey ) {
64
+ setBulkSelectedElements ( ( prev ) => [
65
+ ...prev ,
66
+ {
67
+ id : data . id ,
68
+ type : ObjectType . AREA ,
69
+ initialCoords : { x : data . x , y : data . y } ,
70
+ currentCoords : { x : data . x , y : data . y } ,
71
+ } ,
72
+ ] ) ;
73
+ }
74
+ setSelectedElement ( ( prev ) => ( {
75
+ ...prev ,
76
+ element : ObjectType . AREA ,
77
+ id : data . id ,
78
+ open : false ,
79
+ } ) ) ;
80
+ } ;
81
+
82
+ if ( locking ) {
83
+ lockArea ( ) ;
84
+ } else {
85
+ unlockArea ( ) ;
86
+ }
56
87
} ;
57
88
58
89
const edit = ( ) => {
@@ -116,7 +147,6 @@ export default function Area({
116
147
y = { data . y }
117
148
width = { data . width > 0 ? data . width : 0 }
118
149
height = { data . height > 0 ? data . height : 0 }
119
- onPointerDown = { onPointerDown }
120
150
>
121
151
< div
122
152
className = { `w-full h-full p-2 rounded cursor-move border-2 ${
0 commit comments