File size: 891 Bytes
1e92f2d |
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 |
import { get } from 'lodash';
import isClassicEditorForced from 'calypso/state/selectors/is-classic-editor-forced';
import 'calypso/state/selected-editor/init';
/**
* Returns the editor of the selected site
* @param {Object} state Global state tree
* @param {number} siteId Site ID
* @returns {string} "gutenberg-iframe", "gutenberg-redirect", "gutenberg-redirect-and-style" or "classic", or null if we
* have no data yet
*/
export const getSelectedEditor = ( state, siteId ) => {
const selectedEditor = get( state, [ 'selectedEditor', siteId ], null );
const validEditors = [
'gutenberg-iframe',
'gutenberg-redirect',
'gutenberg-redirect-and-style',
'classic',
];
if ( ! validEditors.includes( selectedEditor ) ) {
return null;
}
if ( isClassicEditorForced( state, siteId ) ) {
return 'classic';
}
return selectedEditor;
};
export default getSelectedEditor;
|