-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathprivate-selectors.js
51 lines (45 loc) · 1.19 KB
/
private-selectors.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
/**
* WordPress dependencies
*/
import { store as blockEditorStore } from '@wordpress/block-editor';
import { createRegistrySelector } from '@wordpress/data';
/**
* Internal dependencies
*/
import { getRenderingMode } from './selectors';
const EMPTY_INSERTION_POINT = {
rootClientId: undefined,
insertionIndex: undefined,
filterValue: undefined,
};
/**
* Get the insertion point for the inserter.
*
* @param {Object} state Global application state.
*
* @return {Object} The root client ID, index to insert at and starting filter value.
*/
export const getInsertionPoint = createRegistrySelector(
( select ) => ( state ) => {
if ( typeof state.blockInserterPanel === 'object' ) {
return state.blockInserterPanel;
}
if ( getRenderingMode( state ) === 'template-locked' ) {
const [ postContentClientId ] =
select( blockEditorStore ).__experimentalGetGlobalBlocksByName(
'core/post-content'
);
if ( postContentClientId ) {
return {
rootClientId: postContentClientId,
insertionIndex: undefined,
filterValue: undefined,
};
}
}
return EMPTY_INSERTION_POINT;
}
);
export function getListViewToggleRef( state ) {
return state.listViewToggleRef;
}