-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathindex.native.js
61 lines (53 loc) · 1.22 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
/**
* External dependencies
*/
import { last } from 'lodash';
/**
* WordPress dependencies
*/
import { withSelect } from '@wordpress/data';
import { getDefaultBlockName } from '@wordpress/blocks';
/**
* Internal dependencies
*/
import DefaultBlockAppender from '../default-block-appender';
import styles from './style.scss';
function BlockListAppender( {
blockClientIds,
rootClientId,
canInsertDefaultBlock,
isLocked,
renderAppender: CustomAppender,
} ) {
if ( isLocked ) {
return null;
}
if ( CustomAppender ) {
return (
<CustomAppender />
);
}
if ( canInsertDefaultBlock ) {
return (
<DefaultBlockAppender
rootClientId={ rootClientId }
lastBlockClientId={ last( blockClientIds ) }
containerStyle={ styles.blockListAppender }
placeholder={ blockClientIds.length > 0 ? '' : null }
/>
);
}
return null;
}
export default withSelect( ( select, { rootClientId } ) => {
const {
getBlockOrder,
canInsertBlockType,
getTemplateLock,
} = select( 'core/block-editor' );
return {
isLocked: !! getTemplateLock( rootClientId ),
blockClientIds: getBlockOrder( rootClientId ),
canInsertDefaultBlock: canInsertBlockType( getDefaultBlockName(), rootClientId ),
};
} )( BlockListAppender );