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 Jun 18, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent c6e7ddb commit 5f422e4
Showing 7 changed files with 19 additions and 148 deletions.
2 changes: 0 additions & 2 deletions packages/editor/src/components/sidebar/index.js
Original file line number Diff line number Diff line change
@@ -111,9 +111,7 @@ const SidebarContent = ( {
<Tabs.TabPanel tabId={ sidebars.document } focusable={ false }>
<PostSummary onActionPerformed={ onActionPerformed } />
<PluginDocumentSettingPanel.Slot />
{ renderingMode !== 'post-only' && (
<TemplateContentPanel />
) }
<PostTransformPanel />
<PostTaxonomiesPanel />
<PatternOverridesPanel />
2 changes: 0 additions & 2 deletions packages/editor/src/components/sidebar/post-summary.js
Original file line number Diff line number Diff line change
@@ -29,7 +29,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';
import { PrivatePostLastRevision } from '../post-last-revision';

/**
@@ -86,7 +85,6 @@ export default function PostSummary( { onActionPerformed } ) {
<PostFormatPanel />
<PostStickyPanel />
</VStack>
<TemplateAreas />
{ fills }
</VStack>
) }
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
@@ -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 );

@@ -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' ) }>
24 changes: 0 additions & 24 deletions packages/editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
@@ -25,8 +25,6 @@ import {
getCurrentPost,
__experimentalGetDefaultTemplatePartAreas,
} from './selectors';
import { TEMPLATE_PART_POST_TYPE } from './constants';
import { getFilteredTemplatePartBlocks } from './utils/get-filtered-template-parts';
import { getEntityActions as _getEntityActions } from '../dataviews/store/private-selectors';

const EMPTY_INSERTION_POINT = {
@@ -120,28 +118,6 @@ 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 );
}
);

/**
* Returns true if there are unsaved changes to the
1 change: 0 additions & 1 deletion packages/editor/src/style.scss
Original file line number Diff line number Diff line change
@@ -54,6 +54,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 5f422e4

Please sign in to comment.