diff --git a/packages/dataviews/CHANGELOG.md b/packages/dataviews/CHANGELOG.md index f74de60f765c69..26f0e8c69b0c25 100644 --- a/packages/dataviews/CHANGELOG.md +++ b/packages/dataviews/CHANGELOG.md @@ -7,6 +7,10 @@ - DataViews: Use intersectionObserver to improve performance by unloading invisible items. Change how infinite scroll is enabled to require only 2 view properties: `infiniteScrollEnabled` and `startPosition`. [#74378](https://github.com/WordPress/gutenberg/pull/74378) - DataForm: The card layout now uses `Card` and `CollapsibleCard` from `@wordpress/ui` instead of `Card`, `CardHeader`, and `CardBody` from `@wordpress/components`. This changes the card's visual appearance (spacing, typography, and removal of the header/content separator). Custom CSS targeting `.components-card__body` within DataViews has been removed. Consumers wrapping DataViews or DataForm in a card should migrate to the `Card` and `CollapsibleCard` components from `@wordpress/ui`. [#76282](https://github.com/WordPress/gutenberg/pull/76282) +### Enhancements + +- DataViews: Field's description can accept ReactElements. [#76829](https://github.com/WordPress/gutenberg/pull/76829) + ## 13.1.0 (2026-03-18) ### Enhancements diff --git a/packages/dataviews/src/types/field-api.ts b/packages/dataviews/src/types/field-api.ts index cd219c5cf839ae..1475c799182f3d 100644 --- a/packages/dataviews/src/types/field-api.ts +++ b/packages/dataviews/src/types/field-api.ts @@ -200,7 +200,7 @@ export type Field< Item > = { /** * A description of the field. */ - description?: string; + description?: string | ReactElement; /** * Placeholder for the field. diff --git a/packages/editor/src/components/sidebar/dataform-post-summary.js b/packages/editor/src/components/sidebar/dataform-post-summary.js index c76989a49d54b4..736459c67481d8 100644 --- a/packages/editor/src/components/sidebar/dataform-post-summary.js +++ b/packages/editor/src/components/sidebar/dataform-post-summary.js @@ -38,6 +38,7 @@ const form = { labelPosition: 'none', }, }, + 'excerpt', { id: 'status', label: __( 'Status' ), diff --git a/packages/editor/src/dataviews/store/private-actions.ts b/packages/editor/src/dataviews/store/private-actions.ts index f343fbbd62d376..ec8f566d1c8472 100644 --- a/packages/editor/src/dataviews/store/private-actions.ts +++ b/packages/editor/src/dataviews/store/private-actions.ts @@ -19,6 +19,7 @@ import { resetPost, deletePost, duplicateTemplatePart, + excerptField, featuredImageField, dateField, parentField, @@ -267,6 +268,9 @@ export const registerPostTypeSchema = ! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) && scheduledDateField, slugField, + ! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) && + postTypeConfig.supports?.excerpt && + excerptField, postTypeConfig.supports?.[ 'page-attributes' ] && parentField, postTypeConfig.supports?.comments && commentStatusField, postTypeConfig.supports?.trackbacks && pingStatusField, diff --git a/packages/fields/README.md b/packages/fields/README.md index 5fdebc9c401ec7..012cb6fbb4edca 100644 --- a/packages/fields/README.md +++ b/packages/fields/README.md @@ -63,6 +63,10 @@ Duplicate action for BasePost. Duplicate action for TemplatePart. +### excerptField + +Excerpt field for BasePost. + ### exportPattern Export action as JSON for Pattern. diff --git a/packages/fields/src/fields/excerpt/index.tsx b/packages/fields/src/fields/excerpt/index.tsx new file mode 100644 index 00000000000000..af17796199f80c --- /dev/null +++ b/packages/fields/src/fields/excerpt/index.tsx @@ -0,0 +1,57 @@ +/** + * WordPress dependencies + */ +import type { Field } from '@wordpress/dataviews'; +import { decodeEntities } from '@wordpress/html-entities'; +import { __ } from '@wordpress/i18n'; +import { + ExternalLink, + __experimentalText as Text, +} from '@wordpress/components'; + +/** + * Internal dependencies + */ +import type { BasePost } from '../../types'; + +const excerptField: Field< BasePost > = { + id: 'excerpt', + type: 'text', + label: __( 'Excerpt' ), + placeholder: __( 'Add an excerpt' ), + description: ( + + { __( 'Learn more about manual excerpts' ) } + + ), + render: ( { item } ) => { + let excerpt; + if ( typeof item.excerpt === 'string' ) { + excerpt = !! item.excerpt + ? decodeEntities( item.excerpt ) + : __( 'Add an excerpt' ); + } else { + excerpt = decodeEntities( item.excerpt?.raw || '' ); + } + return ( + + { excerpt } + + ); + }, + Edit: { + control: 'textarea', + rows: 4, + }, + enableSorting: false, + filterBy: false, +}; + +/** + * Excerpt field for BasePost. + */ +export default excerptField; diff --git a/packages/fields/src/fields/index.ts b/packages/fields/src/fields/index.ts index f2a6b90ccedacc..f0377a1ca07749 100644 --- a/packages/fields/src/fields/index.ts +++ b/packages/fields/src/fields/index.ts @@ -16,5 +16,6 @@ export { default as dateField } from './date'; export { default as scheduledDateField } from './date/scheduled'; export { default as authorField } from './author'; export { default as notesField } from './notes'; +export { default as excerptField } from './excerpt'; export { default as formatField } from './format'; export { default as postContentInfoField } from './post-content-info'; diff --git a/packages/fields/src/types.ts b/packages/fields/src/types.ts index 75af437cf59fcf..ddba0847102a8a 100644 --- a/packages/fields/src/types.ts +++ b/packages/fields/src/types.ts @@ -127,6 +127,7 @@ export interface PostType { supports?: { 'page-attributes'?: boolean; title?: boolean; + excerpt?: boolean; revisions?: boolean; author?: string; thumbnail?: string;