@gechiui/block-editor
Version:
73 lines (68 loc) • 2.43 kB
JavaScript
import { createElement, Fragment } from "@gechiui/element";
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* GeChiUI dependencies
*/
import { Button, VisuallyHidden } from '@gechiui/components';
import { useInstanceId } from '@gechiui/compose';
import { forwardRef } from '@gechiui/element';
import { __ } from '@gechiui/i18n';
/**
* Internal dependencies
*/
import BlockIcon from '../block-icon';
import useBlockDisplayInformation from '../use-block-display-information';
import { getBlockPositionDescription } from './utils';
import BlockTitle from '../block-title';
import ListViewExpander from './expander';
function ListViewBlockSelectButton(_ref, ref) {
let {
className,
block: {
clientId
},
isSelected,
onClick,
onToggleExpanded,
position,
siblingBlockCount,
level,
tabIndex,
onFocus,
onDragStart,
onDragEnd,
draggable
} = _ref;
const blockInformation = useBlockDisplayInformation(clientId);
const instanceId = useInstanceId(ListViewBlockSelectButton);
const descriptionId = `list-view-block-select-button__${instanceId}`;
const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level);
return createElement(Fragment, null, createElement(Button, {
className: classnames('block-editor-list-view-block-select-button', className),
onClick: onClick,
"aria-describedby": descriptionId,
ref: ref,
tabIndex: tabIndex,
onFocus: onFocus,
onDragStart: onDragStart,
onDragEnd: onDragEnd,
draggable: draggable
}, createElement(ListViewExpander, {
onClick: onToggleExpanded
}), createElement(BlockIcon, {
icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
showColors: true
}), createElement(BlockTitle, {
clientId: clientId
}), (blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.anchor) && createElement("span", {
className: "block-editor-list-view-block-select-button__anchor"
}, blockInformation.anchor), isSelected && createElement(VisuallyHidden, null, __('(选定的区块)'))), createElement("div", {
className: "block-editor-list-view-block-select-button__description",
id: descriptionId
}, blockPositionDescription));
}
export default forwardRef(ListViewBlockSelectButton);
//# sourceMappingURL=block-select-button.js.map