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

Added explanation of isEmpty function; extra line removed #61300

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

Lovor01
Copy link
Contributor

@Lovor01 Lovor01 commented May 1, 2024

isEmpty method of RichText object was not documented

Copy link

github-actions bot commented May 1, 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: Lovor01 <lovor@git.wordpress.org>

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

@Lovor01 Lovor01 marked this pull request as draft May 1, 2024 23:45
@Lovor01 Lovor01 changed the title Added explanation of isEmpty function; extra line removed Added explanation of isEmpty function; extra line removed [Type] Developer Documentation May 2, 2024
@Lovor01 Lovor01 changed the title Added explanation of isEmpty function; extra line removed [Type] Developer Documentation Added explanation of isEmpty function; extra line removed May 2, 2024

Helper function to test if supplied variable (e.g. content of RichText) is empty. It tests if value of variable is empty or if variable is an empty array.

### `value: String | Array`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array is deprecated so I wouldn't document it here. Note that it can also be RichTextData

@@ -121,14 +121,22 @@ registerBlockType( /* ... */, {
} );
```

## RichText.isEmpty

Helper function to test if supplied variable (e.g. content of RichText) is empty. It tests if value of variable is empty or if variable is an empty array.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the first line is explanatory enough?


### Example

Some [attributes in paragraph block](https://github.com/WordPress/gutenberg/blob/59ed45e2d9db32e50b17b5801f0841f6d7489b0c/packages/block-library/src/paragraph/edit.js#L174) are set differrently if content of `RichText` is empty.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably better to give an inline example as done in other places.

@ellatrix
Copy link
Member

ellatrix commented May 2, 2024

Thank you for the PR! Looks good, just left some comments.

@ellatrix ellatrix added the [Type] Developer Documentation Documentation for developers label May 2, 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.

None yet

2 participants