UNPKG

@wordpress/block-editor

Version:
41 lines (38 loc) 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = BlockEditVisuallyButton; var _components = require("@wordpress/components"); var _i18n = require("@wordpress/i18n"); var _data = require("@wordpress/data"); var _store = require("../../store"); var _jsxRuntime = require("react/jsx-runtime"); /** * WordPress dependencies */ /** * Internal dependencies */ function BlockEditVisuallyButton({ clientIds }) { // Edit visually only works for single block selection. const clientId = clientIds.length === 1 ? clientIds[0] : undefined; const canEditVisually = (0, _data.useSelect)(select => !!clientId && select(_store.store).getBlockMode(clientId) === 'html', [clientId]); const { toggleBlockMode } = (0, _data.useDispatch)(_store.store); if (!canEditVisually) { return null; } return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarGroup, { children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarButton, { onClick: () => { toggleBlockMode(clientId); }, children: (0, _i18n.__)('Edit visually') }) }); } //# sourceMappingURL=index.js.map