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

Block Editor: Remove multiline prop from Richtext doc #61592

Merged
merged 1 commit into from May 13, 2024

Conversation

t-hamano
Copy link
Contributor

Closes #61580

What?

The multiline prop for RichText components is now deprecated, so I removed it from the README.

I thought about marking this prop as deprecated and keeping it, but just like when onSplit was deprecated, I removed the prop itself from the documentation.

@t-hamano t-hamano added the [Type] Developer Documentation Documentation for developers label May 12, 2024
@t-hamano t-hamano self-assigned this May 12, 2024
Copy link

github-actions bot commented May 12, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: andreawetzel <awetz583@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka
Copy link
Member

I think this property is more widely used than onSpit, and based on the #47395 discussion, we still don't have a clear migration guide to the Inner Blocks.

Noting the prop as deprecated and linking to the migration guide would be an ideal solution here.

@ellatrix, what do you think?

@t-hamano
Copy link
Contributor Author

Noting the prop as deprecated and linking to the migration guide would be an ideal solution here.

Indeed. If we want to add a migration guide, would it be better to use the Deprecation page?

@Mamaduka
Copy link
Member

That page is for Deprecation API; we might need to find a better place :)

@ellatrix
Copy link
Member

We do log the prop as deprecated and link to the inner blocks documentation:

deprecated( 'wp.blockEditor.RichText multiline prop', {
since: '6.1',
version: '6.3',
alternative: 'nested blocks (InnerBlocks)',
link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/nested-blocks-inner-blocks/',
} );

@t-hamano
Copy link
Contributor Author

I think what developers would like to know is how to implement deprecation for migrating custom blocks containing RichText components with multiline prop to innerBlocks. For example, something like this function in the List block.

export function migrateToListV2( attributes ) {
const { values, start, reversed, ordered, type, ...otherAttributes } =
attributes;
const list = document.createElement( ordered ? 'ol' : 'ul' );
list.innerHTML = values;
if ( start ) {
list.setAttribute( 'start', start );
}
if ( reversed ) {
list.setAttribute( 'reversed', true );
}
if ( type ) {
list.setAttribute( 'type', type );
}
const [ listBlock ] = rawHandler( { HTML: list.outerHTML } );
return [
{ ...otherAttributes, ...listBlock.attributes },
listBlock.innerBlocks,
];
}

Perhaps the Developer Blog is suitable for such implementation examples?

@Mamaduka
Copy link
Member

@ellatrix, right, the deprecation notice links to InnerBlocks documentation, but based on the feedback, it seems that people are still struggling with migrations.

@t-hamano, a post on the developers' blog sounds good to me. cc @ndiego @ryanwelcher

@t-hamano
Copy link
Contributor Author

a post on the developers' blog sounds good to me.

I have never written for the Developer blog, but if the migration guide is useful to many people, I would be happy to help.

By the way, I have already written code to test migrations in my personal repository: https://github.com/t-hamano/multiline-deprecation-example

  • In the trunk branch, the multiline prop is applied to the RichText component.
  • The v1 branch uses the InnerBlocks and also implements block migration.
  • Inserting a block on the trunk branch and switching to the v1 branch will perform the block migration.

I hope this code is useful.

In any case, I would like to merge this PR.

@Mamaduka
Copy link
Member

Sounds good. Thank you, @t-hamano!

@t-hamano t-hamano merged commit af03949 into trunk May 13, 2024
68 checks passed
@t-hamano t-hamano deleted the richtext-remove-multiline-doc branch May 13, 2024 15:48
@github-actions github-actions bot added this to the Gutenberg 18.4 milestone May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add note to RichText readme that multiline has been deprecated
3 participants