-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathindex.native.js
73 lines (65 loc) · 1.75 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
68
69
70
71
72
73
/**
* 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';
import { trash } from '@wordpress/icons';
/**
* Internal dependencies
*/
import styles from './style.scss';
import BlockMover from '../block-mover';
import { BlockSettingsButton } from '../block-settings';
const BlockMobileToolbar = ( {
clientId,
onDelete,
order,
isStackedHorizontally,
} ) => (
<View style={ styles.toolbar }>
<BlockMover
clientIds={ [ clientId ] }
isStackedHorizontally={ isStackedHorizontally }
/>
<View style={ styles.spacer } />
<BlockSettingsButton.Slot>
{ /* Render only one settings icon even if we have more than one fill - need for hooks with controls */ }
{ ( fills = [ null ] ) => fills[ 0 ] }
</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, onDelete } ) => {
const { removeBlock } = dispatch( 'core/block-editor' );
return {
onDelete:
onDelete ||
( () => {
Keyboard.dismiss();
removeBlock( clientId, rootClientId );
} ),
};
} )
)( BlockMobileToolbar );