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 API: Normalize function arguments #5227

Closed
mtias opened this issue Feb 23, 2018 · 5 comments
Closed

Block API: Normalize function arguments #5227

mtias opened this issue Feb 23, 2018 · 5 comments
Assignees
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Code Quality Issues or PRs that relate to code quality

Comments

@mtias
Copy link
Member

mtias commented Feb 23, 2018

We have several functions that take arguments like blockType, attributes, innerHtml, but the order is not always consistent.

Since this is an often repeated pattern, we should consolidate usage.

Examples:

isValidBlock — innerHTML, blockType, attributes.
getBlockAttributes — blockType, innerHTML, attributes.
getAttributesFromDeprecatedVersion — blockType, innerHTML, attributes.
createBlock — name, attributes, innerBlocks.
getSaveContent — blockType, attributes.

@mtias mtias added the [Feature] Block API API that allows to express the block paradigm. label Feb 23, 2018
@aduth
Copy link
Member

aduth commented Feb 23, 2018

Maybe we could prefer to pass name instead of blockType, assuming that its more readily accessible and that these functions have access to the registry?

Proposed:

isValidBlock( name, attributes, innerHTML )
getBlockAttributes( name, attributes, innerHTML )
getAttributesFromDeprecatedVersion( name, attributes, innerHTML )
createBlock( name, attributes, innerBlocks )
getSaveContent( name, attributes, innerBlocks )

@aduth aduth changed the title Block API function arguments Block API: Normalize function arguments Mar 6, 2018
@mtias mtias added the [Type] Code Quality Issues or PRs that relate to code quality label Jul 17, 2018
@mtias mtias added this to the API Freeze milestone Oct 7, 2018
@mtias
Copy link
Member Author

mtias commented Oct 7, 2018

This needs a quick proposal or closing.

@gziolo gziolo self-assigned this Oct 22, 2018
@gziolo
Copy link
Member

gziolo commented Oct 22, 2018

I will work on the proposal shared by @aduth.

@gziolo
Copy link
Member

gziolo commented Oct 22, 2018

getAttributesFromDeprecatedVersion - I no longer see this method.

@gziolo
Copy link
Member

gziolo commented Oct 29, 2018

On the point of name vs. type as an argument; I'd actually be okay with allowing the convenience here of specifying one or the other, as long as it's supported consistently across all functions. Maybe we need an internal function to normalize?

We should address this before 5.0 lands. This won't be a breaking change but it should simplify using the following API methods at least:

  • getBlockAttributes
  • getSaveContent
  • getSaveElement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

No branches or pull requests

3 participants