-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathindex.native.js
67 lines (59 loc) · 1.45 KB
/
index.native.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* External dependencies
*/
import { Keyboard, View } from 'react-native';
/**
* WordPress dependencies
*/
import { ToolbarButton } from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
/**
* Internal dependencies
*/
import styles from './block-mobile-toolbar.scss';
import BlockMover from '../block-mover';
import { BlockSettingsButton } from '../block-settings';
const BlockMobileToolbar = ( {
clientId,
onDelete,
order,
} ) => (
<View style={ styles.toolbar }>
<BlockMover clientIds={ [ clientId ] } />
<View style={ styles.spacer } />
<BlockSettingsButton.Slot />
<ToolbarButton
title={
sprintf(
/* translators: accessibility text. %s: current block position (number). */
__( 'Remove block at row %s' ),
order + 1
)
}
onClick={ onDelete }
icon="trash"
extraProps={ { hint: __( 'Double tap to remove the block' ) } }
/>
</View>
);
export default compose(
withSelect( ( select, { clientId } ) => {
const {
getBlockIndex,
} = select( 'core/block-editor' );
return {
order: getBlockIndex( clientId ),
};
} ),
withDispatch( ( dispatch, { clientId, rootClientId } ) => {
const { removeBlock } = dispatch( 'core/block-editor' );
return {
onDelete: () => {
Keyboard.dismiss();
removeBlock( clientId, rootClientId );
},
};
} ),
)( BlockMobileToolbar );