Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post Excerpt: add previewPlaceholder attribute #49036

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ Display a post's excerpt. ([Source](https://github.com/WordPress/gutenberg/tree/
- **Name:** core/post-excerpt
- **Category:** theme
- **Supports:** anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** excerptLength, moreText, showMoreOnNewLine, textAlign
- **Attributes:** excerptLength, moreText, previewPlaceholder, showMoreOnNewLine, textAlign

## Post Featured Image

Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/post-excerpt/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"excerptLength": {
"type": "number",
"default": 55
},
"previewPlaceholder": {
"type": "string"
}
},
"usesContext": [ "postId", "postType", "queryId" ],
Expand Down
21 changes: 12 additions & 9 deletions packages/block-library/src/post-excerpt/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ import { __, _x } from '@wordpress/i18n';
import { useCanEditEntity } from '../utils/hooks';

export default function PostExcerptEditor( {
attributes: { textAlign, moreText, showMoreOnNewLine, excerptLength },
attributes: {
textAlign,
moreText,
showMoreOnNewLine,
excerptLength,
previewPlaceholder,
},
setAttributes,
isSelected,
context: { postId, postType, queryId },
Expand Down Expand Up @@ -78,14 +84,11 @@ export default function PostExcerptEditor( {
</BlockControls>
<div { ...blockProps }>
<p>
{ __(
'This is the Post Excerpt block, it will display the excerpt from single posts.'
) }
</p>
<p>
{ __(
'If there are any Custom Post Types with support for excerpts, the Post Excerpt block can display the excerpts of those entries as well.'
) }
{ previewPlaceholder
? previewPlaceholder
: __(
'This is the Post Excerpt block, it will display the excerpt'
) }
</p>
</div>
</>
Expand Down