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

Stabilize <PlainText> v2 and deprecate v1. #39817

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Draft
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: 2 additions & 0 deletions packages/block-editor/src/components/plain-text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ wp.blocks.registerBlockType( /* ... */, {

edit: function( props ) {
return wp.element.createElement( wp.editor.PlainText, {
version: 2,
className: props.className,
value: props.attributes.content,
onChange: function( content ) {
Expand Down Expand Up @@ -63,6 +64,7 @@ registerBlockType( /* ... */, {
edit( { className, attributes, setAttributes } ) {
return (
<PlainText
version={ 2 }
className={ className }
value={ attributes.content }
onChange={ ( content ) => setAttributes( { content } ) }
Expand Down
10 changes: 8 additions & 2 deletions packages/block-editor/src/components/plain-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';
import { forwardRef } from '@wordpress/element';

/**
Expand All @@ -17,11 +18,16 @@ import EditableText from '../editable-text';
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/plain-text/README.md
*/
const PlainText = forwardRef( ( { __experimentalVersion, ...props }, ref ) => {
if ( __experimentalVersion === 2 ) {
const PlainText = forwardRef( ( { version, ...props }, ref ) => {
if ( version === 2 ) {
return <EditableText ref={ ref } { ...props } />;
}

deprecated( 'Version 1 of `<PlainText>`', {
since: '6.0',
alternative: '`version={2}`',
} );

const { className, onChange, ...remainingProps } = props;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function CommentsPaginationNextEdit( {
{ ...useBlockProps() }
>
<PlainText
__experimentalVersion={ 2 }
version={ 2 }
tagName="span"
aria-label={ __( 'Newer comments page link' ) }
placeholder={ __( 'Newer Comments' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function CommentsPaginationPreviousEdit( {
</span>
) }
<PlainText
__experimentalVersion={ 2 }
version={ 2 }
tagName="span"
aria-label={ __( 'Older comments page link' ) }
placeholder={ __( 'Older Comments' ) }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/html/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default function HTMLEdit( { attributes, setAttributes, isSelected } ) {
/>
) : (
<PlainText
version={ 2 }
value={ attributes.content }
onChange={ ( content ) => setAttributes( { content } ) }
placeholder={ __( 'Write HTML…' ) }
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/post-title/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export default function PostTitleEdit( {
titleElement =
userCanEdit && ! isDescendentOfQueryLoop ? (
<PlainText
version={ 2 }
tagName={ TagName }
placeholder={ __( 'No Title' ) }
value={ rawTitle }
onChange={ setTitle }
__experimentalVersion={ 2 }
{ ...blockProps }
/>
) : (
Expand All @@ -72,6 +72,7 @@ export default function PostTitleEdit( {
userCanEdit && ! isDescendentOfQueryLoop ? (
<TagName { ...blockProps }>
<PlainText
version={ 2 }
tagName="a"
href={ link }
target={ linkTarget }
Expand All @@ -81,7 +82,6 @@ export default function PostTitleEdit( {
}
value={ rawTitle }
onChange={ setTitle }
__experimentalVersion={ 2 }
/>
</TagName>
) : (
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/query-pagination-next/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function QueryPaginationNextEdit( {
{ ...useBlockProps() }
>
<PlainText
__experimentalVersion={ 2 }
version={ 2 }
tagName="span"
aria-label={ __( 'Next page link' ) }
placeholder={ __( 'Next Page' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function QueryPaginationPreviousEdit( {
</span>
) }
<PlainText
__experimentalVersion={ 2 }
version={ 2 }
tagName="span"
aria-label={ __( 'Previous page link' ) }
placeholder={ __( 'Previous Page' ) }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/shortcode/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function ShortcodeEdit( { attributes, setAttributes } ) {
{ __( 'Shortcode' ) }
</label>
<PlainText
version={ 2 }
className="blocks-shortcode__textarea"
id={ inputId }
value={ attributes.text }
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/shortcode/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function ShortcodeEdit( props ) {
<Text style={ titleStyle }>{ __( 'Shortcode' ) }</Text>
<View style={ shortcodeContainerStyle }>
<PlainText
__experimentalVersion={ 2 }
version={ 2 }
value={ attributes.text }
style={ shortcodeStyle }
onChange={ onChange }
Expand Down