@gechiui/block-editor
Version:
45 lines (41 loc) • 1.36 kB
JavaScript
import { createElement, Fragment } from "@gechiui/element";
/**
* GeChiUI dependencies
*/
import { useSelect } from '@gechiui/data';
/**
* Internal dependencies
*/
import BlockControls from '../block-controls';
import UngroupButton from '../ungroup-button';
import { store as blockEditorStore } from '../../store';
export default function BlockToolbar() {
const {
blockClientIds,
isValid,
mode
} = useSelect(select => {
const {
getBlockMode,
getSelectedBlockClientIds,
isBlockValid
} = select(blockEditorStore);
const selectedBlockClientIds = getSelectedBlockClientIds();
return {
blockClientIds: selectedBlockClientIds,
isValid: selectedBlockClientIds.length === 1 ? isBlockValid(selectedBlockClientIds[0]) : null,
mode: selectedBlockClientIds.length === 1 ? getBlockMode(selectedBlockClientIds[0]) : null
};
}, []);
if (blockClientIds.length === 0) {
return null;
}
return createElement(Fragment, null, mode === 'visual' && isValid && createElement(Fragment, null, createElement(UngroupButton, null), createElement(BlockControls.Slot, {
group: "block"
}), createElement(BlockControls.Slot, null), createElement(BlockControls.Slot, {
group: "inline"
}), createElement(BlockControls.Slot, {
group: "other"
})));
}
//# sourceMappingURL=index.native.js.map