@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
66 lines (63 loc) • 2.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = TemplateContentPanel;
var _data = require("@wordpress/data");
var _blockEditor = require("@wordpress/block-editor");
var _components = require("@wordpress/components");
var _i18n = require("@wordpress/i18n");
var _interface = require("@wordpress/interface");
var _hooks = require("@wordpress/hooks");
var _element = require("@wordpress/element");
var _lockUnlock = require("../../lock-unlock");
var _constants = require("../../store/constants");
var _store = require("../../store");
var _jsxRuntime = require("react/jsx-runtime");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
const {
BlockQuickNavigation
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
const POST_CONTENT_BLOCK_TYPES = ['core/post-title', 'core/post-featured-image', 'core/post-content'];
const TEMPLATE_PART_BLOCK = 'core/template-part';
function TemplateContentPanel() {
const postContentBlockTypes = (0, _element.useMemo)(() => (0, _hooks.applyFilters)('editor.postContentBlockTypes', POST_CONTENT_BLOCK_TYPES), []);
const {
clientIds,
postType,
renderingMode
} = (0, _data.useSelect)(select => {
const {
getCurrentPostType,
getPostBlocksByName,
getRenderingMode
} = (0, _lockUnlock.unlock)(select(_store.store));
const _postType = getCurrentPostType();
return {
postType: _postType,
clientIds: getPostBlocksByName(_constants.TEMPLATE_POST_TYPE === _postType ? TEMPLATE_PART_BLOCK : postContentBlockTypes),
renderingMode: getRenderingMode()
};
}, [postContentBlockTypes]);
const {
enableComplementaryArea
} = (0, _data.useDispatch)(_interface.store);
if (renderingMode === 'post-only' && postType !== _constants.TEMPLATE_POST_TYPE || clientIds.length === 0) {
return null;
}
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.PanelBody, {
title: (0, _i18n.__)('Content'),
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockQuickNavigation, {
clientIds: clientIds,
onSelect: () => {
enableComplementaryArea('core', 'edit-post/document');
}
})
});
}
//# sourceMappingURL=index.js.map