@@ -4,14 +4,15 @@ import { ArrowDownwardOutlined, ArrowUpwardOutlined, DeleteOutlined } from '@mui
4
4
import { IconButton , Paper , Stack , Tooltip } from '@mui/material' ;
5
5
6
6
import { TEditorBlock } from '../../../editor/core' ;
7
- import { resetDocument , useDocument } from '../../../editor/EditorContext' ;
7
+ import { resetDocument , setSelectedBlockId , useDocument } from '../../../editor/EditorContext' ;
8
8
import { ColumnsContainerProps } from '../../ColumnsContainer/ColumnsContainerPropsSchema' ;
9
9
10
10
const STYLE : CSSProperties = {
11
11
position : 'absolute' ,
12
12
top : 0 ,
13
13
left : - 52 ,
14
14
borderRadius : 64 ,
15
+ padding : 2 ,
15
16
} ;
16
17
17
18
type Props = {
@@ -78,19 +79,20 @@ export default function TuneMenu({ blockId }: Props) {
78
79
} ;
79
80
80
81
const handleMoveClick = ( direction : 'up' | 'down' ) => {
81
- const moveChildrenIds = ( childrenIds : string [ ] | null | undefined ) => {
82
- if ( ! childrenIds ) {
83
- return childrenIds ;
82
+ const moveChildrenIds = ( ids : string [ ] | null | undefined ) => {
83
+ if ( ! ids ) {
84
+ return ids ;
84
85
}
85
- const index = childrenIds . indexOf ( blockId ) ;
86
- if ( index !== - 1 ) {
87
- if ( direction === 'up' && index > 0 ) {
88
- [ childrenIds [ index ] , childrenIds [ index - 1 ] ] = [ childrenIds [ index - 1 ] , childrenIds [ index ] ] ;
89
- } else if ( direction === 'down' && index < childrenIds . length - 1 ) {
90
- [ childrenIds [ index ] , childrenIds [ index + 1 ] ] = [ childrenIds [ index + 1 ] , childrenIds [ index ] ] ;
91
- }
86
+ const index = ids . indexOf ( blockId ) ;
87
+ if ( index < 0 ) {
88
+ return ids ;
89
+ }
90
+ const childrenIds = [ ...ids ] ;
91
+ if ( direction === 'up' && index > 0 ) {
92
+ [ childrenIds [ index ] , childrenIds [ index - 1 ] ] = [ childrenIds [ index - 1 ] , childrenIds [ index ] ] ;
93
+ } else if ( direction === 'down' && index < childrenIds . length - 1 ) {
94
+ [ childrenIds [ index ] , childrenIds [ index + 1 ] ] = [ childrenIds [ index + 1 ] , childrenIds [ index ] ] ;
92
95
}
93
-
94
96
return childrenIds ;
95
97
} ;
96
98
const nDocument : typeof document = { ...document } ;
@@ -139,8 +141,9 @@ export default function TuneMenu({ blockId }: Props) {
139
141
nDocument [ id ] = block ;
140
142
}
141
143
}
142
- console . log ( nDocument ) ;
144
+
143
145
resetDocument ( nDocument ) ;
146
+ setSelectedBlockId ( blockId ) ;
144
147
} ;
145
148
146
149
return (
0 commit comments