-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Editor: Update post excerpt panel with new designs
- Loading branch information
1 parent
058cc37
commit e4e9ad3
Showing
14 changed files
with
294 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
packages/editor/src/components/post-actions/private-actions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useSelect } from '@wordpress/data'; | ||
import { store as coreStore } from '@wordpress/core-data'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { useMemo } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import PostExcerpt from '../post-excerpt'; | ||
import PluginPostExcerpt from '../post-excerpt/plugin'; | ||
import { store as editorStore } from '../../store'; | ||
|
||
export function useEditExcerptAction() { | ||
const { canEditExcerpt, shouldUseDescriptionLabel } = useSelect( | ||
( select ) => { | ||
const { getCurrentPostType, isEditorPanelEnabled } = | ||
select( editorStore ); | ||
const { getPostType } = select( coreStore ); | ||
const postType = getPostType( getCurrentPostType() ); | ||
// TODO: When we are rendering the excerpt/description for templates, | ||
// template parts and patterns do not abide by the `isEnabled` panel flag. | ||
// It's not implemented here right now because the actions are to be consolidated | ||
// and this is rendered only for the rest post types. | ||
return { | ||
canEditExcerpt: | ||
isEditorPanelEnabled( 'post-excerpt' ) && | ||
postType?.supports?.excerpt, | ||
shouldUseDescriptionLabel: [ | ||
'wp_template', | ||
'wp_template_part', | ||
'wp_block', | ||
].includes( postType ), | ||
}; | ||
}, | ||
[] | ||
); | ||
const label = shouldUseDescriptionLabel | ||
? __( 'Edit description' ) | ||
: __( 'Edit excerpt' ); | ||
return useMemo( | ||
() => ( { | ||
id: 'edit-post-excerpt', | ||
label, | ||
isEligible() { | ||
return canEditExcerpt; | ||
}, | ||
RenderModal: () => { | ||
return ( | ||
<PluginPostExcerpt.Slot> | ||
{ ( fills ) => ( | ||
<> | ||
<PostExcerpt hideLabelFromVision /> | ||
{ fills } | ||
</> | ||
) } | ||
</PluginPostExcerpt.Slot> | ||
); | ||
}, | ||
} ), | ||
[ canEditExcerpt, label ] | ||
); | ||
} |
Oops, something went wrong.