Skip to content

Commit

Permalink
Update: Move template areas into a panel.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed May 29, 2024
1 parent 4119044 commit d24098a
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 150 deletions.
4 changes: 1 addition & 3 deletions packages/editor/src/components/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ const SidebarContent = ( {
<Tabs.TabPanel tabId={ sidebars.document } focusable={ false }>
<PostSummary onActionPerformed={ onActionPerformed } />
<PluginDocumentSettingPanel.Slot />
{ renderingMode !== 'post-only' && (
<TemplateContentPanel />
) }
<TemplateContentPanel />
<PostTransformPanel />
<PostTaxonomiesPanel />
<PageAttributesPanel />
Expand Down
2 changes: 0 additions & 2 deletions packages/editor/src/components/sidebar/post-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import BlogTitle from '../blog-title';
import PostsPerPage from '../posts-per-page';
import SiteDiscussion from '../site-discussion';
import { store as editorStore } from '../../store';
import TemplateAreas from '../template-areas';

/**
* Module Constants
Expand Down Expand Up @@ -82,7 +81,6 @@ export default function PostSummary( { onActionPerformed } ) {
<PostFormatPanel />
<PostStickyPanel />
</VStack>
<TemplateAreas />
{ fills }
</VStack>
) }
Expand Down
94 changes: 0 additions & 94 deletions packages/editor/src/components/template-areas/index.js

This file was deleted.

22 changes: 0 additions & 22 deletions packages/editor/src/components/template-areas/style.scss

This file was deleted.

22 changes: 19 additions & 3 deletions packages/editor/src/components/template-content-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { __ } from '@wordpress/i18n';
* Internal dependencies
*/
import { unlock } from '../../lock-unlock';
import { TEMPLATE_POST_TYPE } from '../../store/constants';
import { store as editorStore } from '../../store';

const { BlockQuickNavigation } = unlock( blockEditorPrivateApis );

Expand All @@ -22,11 +24,25 @@ const PAGE_CONTENT_BLOCKS = [
'core/post-title',
];

export default function TemplateContentPanel() {
const clientIds = useSelect( ( select ) => {
const TEMPLATE_PART_BLOCK = 'core/template-part';

export default function TemplateContentPanel( { renderingMode } ) {
const { clientIds, postType } = useSelect( ( select ) => {
const { getBlocksByName } = select( blockEditorStore );
return getBlocksByName( PAGE_CONTENT_BLOCKS );
const { getCurrentPostType } = select( editorStore );
const _postType = getCurrentPostType();
return {
postType: _postType,
clientIds: getBlocksByName(
TEMPLATE_POST_TYPE === _postType
? TEMPLATE_PART_BLOCK
: PAGE_CONTENT_BLOCKS
),
};
}, [] );
if ( renderingMode !== 'post-only' && postType !== TEMPLATE_POST_TYPE ) {
return null;
}

return (
<PanelBody title={ __( 'Content' ) }>
Expand Down
25 changes: 0 additions & 25 deletions packages/editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {
getRenderingMode,
__experimentalGetDefaultTemplatePartAreas,
} from './selectors';
import { TEMPLATE_PART_POST_TYPE } from './constants';
import { getFilteredTemplatePartBlocks } from './utils/get-filtered-template-parts';

const EMPTY_INSERTION_POINT = {
rootClientId: undefined,
Expand Down Expand Up @@ -112,26 +110,3 @@ export const getPostIcon = createRegistrySelector(
}
}
);

/**
* Returns the template parts and their blocks for the current edited template.
*
* @param {Object} state Global application state.
* @return {Array} Template parts and their blocks in an array.
*/
export const getCurrentTemplateTemplateParts = createRegistrySelector(
( select ) => () => {
const templateParts = select( coreStore ).getEntityRecords(
'postType',
TEMPLATE_PART_POST_TYPE,
{ per_page: -1 }
);

const clientIds =
select( blockEditorStore ).getBlocksByName( 'core/template-part' );
const blocks =
select( blockEditorStore ).getBlocksByClientId( clientIds );

return getFilteredTemplatePartBlocks( blocks, templateParts );
}
);
1 change: 0 additions & 1 deletion packages/editor/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@
@import "./components/sidebar/style.scss";
@import "./components/site-discussion/style.scss";
@import "./components/table-of-contents/style.scss";
@import "./components/template-areas/style.scss";
@import "./components/text-editor/style.scss";
@import "./components/visual-editor/style.scss";

0 comments on commit d24098a

Please sign in to comment.